[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / sen.py
blobd8f14ecdc064deb1102965fe89fe939b4725a68b
1 from .common import InfoExtractor
2 from ..utils import url_or_none
3 from ..utils.traversal import traverse_obj
6 class SenIE(InfoExtractor):
7 _VALID_URL = r'https?://(?:www\.)?sen\.com/video/(?P<id>[0-9a-f-]+)'
8 _TEST = {
9 'url': 'https://www.sen.com/video/eef46eb1-4d79-4e28-be9d-bd937767f8c4',
10 'md5': 'ff615aca9691053c94f8f10d96cd7884',
11 'info_dict': {
12 'id': 'eef46eb1-4d79-4e28-be9d-bd937767f8c4',
13 'ext': 'mp4',
14 'description': 'Florida, 28 Sep 2022',
15 'title': 'Hurricane Ian',
16 'tags': ['North America', 'Storm', 'Weather'],
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
23 api_data = self._download_json(f'https://api.sen.com/content/public/video/{video_id}', video_id)
24 m3u8_url = (traverse_obj(api_data, (
25 'data', 'nodes', lambda _, v: v['id'] == 'player', 'video', 'url', {url_or_none}, any))
26 or f'https://vod.sen.com/videos/{video_id}/manifest.m3u8')
28 return {
29 'id': video_id,
30 'formats': self._extract_m3u8_formats(m3u8_url, video_id, 'mp4'),
31 **traverse_obj(api_data, ('data', 'nodes', lambda _, v: v['id'] == 'details', any, 'content', {
32 'title': ('title', 'text', {str}),
33 'description': ('descriptions', 0, 'text', {str}),
34 'tags': ('badges', ..., 'text', {str}),
35 })),