before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
elif error_code == 11010:
raise ExtractorError('Playlist is no longer available', expected=True)
raise ExtractorError(f'Could not access playlist: {error_code} {error_message}')
query = {
'ps': 20,
'with_current': False,
**traverse_obj... | Or just:
```suggestion
'timestamp': ('ctime', {lambda x: int(x) or None}),
``` | if error_code == -400 and list_id == 'watchlater':
self.raise_login_required('You need to login to access your watchlater playlist')
elif error_code == -403:
self.raise_login_required('This is a private playlist. You need to login as its owner')
elif e... | @@ -1414,7 +1578,7 @@ def _real_extract(self, url):
'title': ('title', {str}),
'uploader': ('upper', 'name', {str}),
'uploader_id': ('upper', 'mid', {str_or_none}),
- 'timestamp': ('ctime', {int_or_none}),
+ 'timestamp': ('ctime', {int_or_... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 97 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | c-basalt |
'uploader_id': '8469526',
'view_count': int,
'like_count': int,
'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)$',
'_old_archive_ids': ['bilibili 778246196_part1'],
},
}, {
'note': 'legacy flv/mp4 video',
'url': 'https://www.bilibili... | ```suggestion
'params': {'extractor_args': {'bilibili': {'prefer_multi_flv': ['32']}}},
``` | 'uploader': '果蝇轰',
'duration': 1111.722,
'uploader_id': '8469526',
'view_count': int,
'like_count': int,
'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)$',
'_old_archive_ids': ['bilibili 778246196_part1'],
},
}, {
'no... | @@ -406,8 +463,57 @@ class BiliBiliIE(BilibiliBaseIE):
'view_count': int,
'like_count': int,
'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)$',
+ '_old_archive_ids': ['bilibili 778246196_part1'],
+ },
+ }, {
+ 'note': 'legacy flv/mp4 video',
+ 'ur... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | refactor | 101 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'_old_archive_ids': [make_archive_id(self, old_video_id)] if old_video_id else None,
'title': title,
'http_headers': {'Referer': url},
}
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist... | ```suggestion
if not self._configuration_arg('prefer_multi_flv'):
``` | }, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_old_archive_ids': [make_archive_id(self, old_video_id)] if old_video_id else None,
'title': title,
'http_headers': {'Referer': url},
}
is_interactive = traverse_obj... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.643 | suggestion | 91 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
make_archive_id,
merge_dicts,
mimetype2ext,
parse_count,
parse_qs,
parse_resolution,
qualities,
smuggle_url,
srt_subtitles_timecode,
str_or_none,
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliB... | ```suggestion
@property
def is_logged_in(self):
return bool(self._get_cookies('https://api.bilibili.com').get('SESSDATA'))
``` | make_archive_id,
merge_dicts,
mimetype2ext,
parse_count,
parse_qs,
parse_resolution,
qualities,
smuggle_url,
srt_subtitles_timecode,
str_or_none,
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliB... | @@ -47,6 +47,21 @@
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
+ _WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeout is unclear, use 30s for one session
+ _wbi_key_cache = {}
+
+ def _has_no_login_cookie(self):
+ return self._get_cookies('https://api.bilibil... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.714 | suggestion | 146 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'keyword': '',
'mid': playlist_id,
'order': traverse_obj(parse_qs(url), ('order', 0)) or 'pubdate',
'order_avoided': 'true',
'platform': 'web',
'pn': page_idx + 1,
'ps': 30,
'tid': 0,
... | ```suggestion
elif status_code == -352 and not self.is_logged_in:
``` | 'To download audios, add a "/audio" to the URL')
def fetch_page(page_idx):
query = {
'keyword': '',
'mid': playlist_id,
'order': traverse_obj(parse_qs(url), ('order', 0)) or 'pubdate',
'order_avoided': 'true'... | @@ -988,73 +1164,53 @@ class BilibiliSpaceVideoIE(BilibiliSpaceBaseIE):
'id': '3985676',
},
'playlist_mincount': 178,
+ 'skip': 'login required',
}, {
'url': 'https://space.bilibili.com/313580179/video',
'info_dict': {
'id': '313580179',
... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 83 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
mimetype2ext,
parse_count,
parse_qs,
parse_resolution,
qualities,
smuggle_url,
srt_subtitles_timecode,
str_or_none,
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_R... | private method
```suggestion
def _check_missing_formats(self, play_info, formats):
``` | mimetype2ext,
parse_count,
parse_qs,
parse_resolution,
qualities,
smuggle_url,
srt_subtitles_timecode,
str_or_none,
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_R... | @@ -47,6 +47,21 @@
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
+ _WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeout is unclear, use 30s for one session
+ _wbi_key_cache = {}
+
+ def _has_no_login_cookie(self):
+ return self._get_cookies('https://api.bilibil... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 93 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'vcodec': 'none',
'tbr': float_or_none(audio.get('bandwidth'), scale=1000),
'filesize': int_or_none(audio.get('size')),
'format_id': str_or_none(audio.get('id')),
} for audio in audios]
formats.extend({
'url': traverse_obj(video, 'baseUrl', 'b... | ```suggestion
self._check_missing_formats(play_info, formats)
``` | 'ext': mimetype2ext(traverse_obj(audio, 'mimeType', 'mime_type')),
'acodec': traverse_obj(audio, ('codecs', {str.lower})),
'vcodec': 'none',
'tbr': float_or_none(audio.get('bandwidth'), scale=1000),
'filesize': int_or_none(audio.get('size')),
'form... | @@ -86,18 +101,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 79 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'view_count': (('viewCount', ('stat', 'view')), {int_or_none}),
'comment_count': ('stat', 'reply', {int_or_none}),
}, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_old_archive_ids': [make_archive_id(self, old_video_id)] if... | ```suggestion
self._check_missing_formats(play_info, formats)
``` | 'description': 'desc',
'timestamp': ('pubdate', {int_or_none}),
'view_count': (('viewCount', ('stat', 'view')), {int_or_none}),
'comment_count': ('stat', 'reply', {int_or_none}),
}, get_all=False),
'id': f'{video_id}{format_field(pa... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 83 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
smuggle_url,
srt_subtitles_timecode,
str_or_none,
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
_WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeo... | ```suggestion
parsed_qualities = set(traverse_obj(formats, (..., 'quality')))
missing_formats = join_nonempty(*[
traverse_obj(fmt, 'new_description', 'display_desc', 'quality')
for fmt in traverse_obj(play_info, (
'support_formats', lambda _, v: v['quality'] ... | smuggle_url,
srt_subtitles_timecode,
str_or_none,
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
_WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeo... | @@ -47,6 +47,21 @@
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
+ _WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeout is unclear, use 30s for one session
+ _wbi_key_cache = {}
+
+ def _has_no_login_cookie(self):
+ return self._get_cookies('https://api.bilibil... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | suggestion | 364 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
_WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeout is unclear, use 30s for one session
_wbi_key_cache = {}... | ```suggestion
self.to_screen(
f'Format(s) {missing_formats} are missing; you have to login or '
f'become a premium member to download them. {self._login_hint()}')
``` | traverse_obj,
unified_timestamp,
unsmuggle_url,
url_or_none,
urlencode_postdata,
variadic,
)
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
_WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeout is unclear, use 30s for one session
_wbi_key_cache = {}... | @@ -47,6 +47,21 @@
class BilibiliBaseIE(InfoExtractor):
_FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?')
+ _WBI_KEY_CACHE_TIMEOUT = 30 # exact expire timeout is unclear, use 30s for one session
+ _wbi_key_cache = {}
+
+ def _has_no_login_cookie(self):
+ return self._get_cookies('https://api.bilibil... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | suggestion | 214 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
} for audio in audios]
formats.extend({
'url': traverse_obj(video, 'baseUrl', 'base_url', 'url'),
'ext': mimetype2ext(traverse_obj(video, 'mimeType', 'mime_type')),
'fps': float_or_none(traverse_obj(video, 'frameRate', 'frame_rate')),
'width': int_or_none... | ```suggestion
'duration': ('length', {functools.partial(float_or_none, scale=1000)}),
``` | 'filesize': int_or_none(audio.get('size')),
'format_id': str_or_none(audio.get('id')),
} for audio in audios]
formats.extend({
'url': traverse_obj(video, 'baseUrl', 'base_url', 'url'),
'ext': mimetype2ext(traverse_obj(video, 'mimeType', 'mime_type')),
... | @@ -86,18 +101,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.714 | suggestion | 103 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
video, (('baseUrl', 'base_url'), {self._FORMAT_ID_RE.search}, 1),
('id', {str_or_none}), get_all=False),
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
if formats:
self.check_missing_fo... | ```suggestion
'duration': ('timelength', {functools.partial(float_or_none, scale=1000)}),
``` | 'quality': int_or_none(video.get('id')),
'format_id': traverse_obj(
video, (('baseUrl', 'base_url'), {self._FORMAT_ID_RE.search}, 1),
('id', {str_or_none}), get_all=False),
'format': format_names.get(video.get('id')),
} for video in traverse_ob... | @@ -86,18 +101,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.714 | suggestion | 115 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'duration': ('timelength', {lambda x: float_or_none(x, scale=1000)}),
}),
**parse_resolution(format_names.get(play_info.get('quality'))),
})
return formats
def _get_wbi_key(self, video_id):
if time.time() < self._wbi_key_cache.get('ts'... | if possible, it would be nice to add a comment with a reference to where this came from (in case it changes) | 'format_id': ('quality', {str_or_none}),
'format_note': ('quality', {lambda x: format_names.get(x)}),
'duration': ('timelength', {functools.partial(float_or_none, scale=1000)}),
}),
**parse_resolution(format_names.get(play_info.... | @@ -86,18 +101,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.429 | suggestion | 108 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'https://api.bilibili.com/x/player/wbi/playurl', bvid,
query=self._sign_wbi(params, bvid), headers=headers,
note=f'Downloading video formats for cid {cid} {qn or ""}')['data']
def json2srt(self, json_data):
srt_data = ''
for idx, line in enumerate(json_data.get('... | ```suggestion
self.report_warning(
f'Subtitles are only available when logged in. {self._login_hint()}', only_once=True)
``` | if qn:
params['qn'] = qn
return self._download_json(
'https://api.bilibili.com/x/player/wbi/playurl', bvid,
query=self._sign_wbi(params, bvid), headers=headers,
note=f'Downloading video formats for cid {cid} {qn or ""}')['data']
def json2srt(self, jso... | @@ -115,14 +186,15 @@ def _get_subtitles(self, video_id, cid, aid=None):
}],
}
- subtitle_info = traverse_obj(self._download_json(
+ video_info = self._download_json(
'https://api.bilibili.com/x/player/v2', video_id,
query={'aid': aid, 'cid': cid} if aid e... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.714 | suggestion | 155 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
def json2srt(self, json_data):
srt_data = ''
for idx, line in enumerate(json_data.get('body') or []):
srt_data += (f'{idx + 1}\n'
f'{srt_subtitles_timecode(line["from"])} --> {srt_subtitles_timecode(line["to"])}\n'
f'{line["content"]}\n\n... | ```suggestion
for s in traverse_obj(video_info, (
'data', 'subtitle', 'subtitles', lambda _, v: v['subtitle_url'] and v['lan'])):
``` | query=self._sign_wbi(params, bvid), headers=headers,
note=f'Downloading video formats for cid {cid} {qn or ""}')['data']
def json2srt(self, json_data):
srt_data = ''
for idx, line in enumerate(json_data.get('body') or []):
srt_data += (f'{idx + 1}\n'
... | @@ -115,14 +186,15 @@ def _get_subtitles(self, video_id, cid, aid=None):
}],
}
- subtitle_info = traverse_obj(self._download_json(
+ video_info = self._download_json(
'https://api.bilibili.com/x/player/v2', video_id,
query={'aid': aid, 'cid': cid} if aid e... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.714 | suggestion | 160 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
}, {
'url': 'https://www.bilibili.com/video/BV1Ks411f7aQ/',
'info_dict': {
'id': 'BV1Ks411f7aQ',
'title': '【BD1080P】狼与香辛料I【华盟】',
'ext': 'mp4',
},
'skip': 'login required',
}, {
'url': 'https://www.bilibili.com/video/BV1GJ411x7h7/',
... | ```suggestion
headers['Referer'] = url
``` | },
'skip': 'supporter-only video',
}, {
'url': 'https://www.bilibili.com/video/BV1Ks411f7aQ/',
'info_dict': {
'id': 'BV1Ks411f7aQ',
'title': '【BD1080P】狼与香辛料I【华盟】',
'ext': 'mp4',
},
'skip': 'login required',
}, {
'url': '... | @@ -498,8 +629,9 @@ def _real_extract(self, url):
if not self._match_valid_url(urlh.url):
return self.url_result(urlh.url)
- initial_state = self._search_json(r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', video_id)
+ headers = {**headers, 'Referer': url} | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 52 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'timestamp': ('pubdate', {int_or_none}),
'view_count': (('viewCount', ('stat', 'view')), {int_or_none}),
'comment_count': ('stat', 'reply', {int_or_none}),
}, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_o... | ```suggestion
lambda _, v: not has_qn(v['quality'])))
``` | **traverse_obj(video_data, {
'description': 'desc',
'timestamp': ('pubdate', {int_or_none}),
'view_count': (('viewCount', ('stat', 'view')), {int_or_none}),
'comment_count': ('stat', 'reply', {int_or_none}),
}, get_all=False),
... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 83 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'season': '立志篇',
'season_id': '26801',
'season_number': 1,
'episode': '炭治郎篇',
'episode_id': '345120',
'episode_number': 27,
'title': '#1 炭治郎篇',
'duration': 1922.129,
'timestamp': 1602853860,
'upload_d... | ```suggestion
headers['Referer'] = url
``` | 'info_dict': {
'id': '345120',
'ext': 'mp4',
'series': '鬼灭之刃',
'series_id': '4358',
'season': '立志篇',
'season_id': '26801',
'season_number': 1,
'episode': '炭治郎篇',
'episode_id': '345120',
'episo... | @@ -674,7 +849,8 @@ def _real_extract(self, url):
elif '正在观看预览,大会员免费看全片' in webpage:
self.raise_login_required('This video is for premium members only')
- headers['Referer'] = url
+ headers = {**headers, 'Referer': url}
+ | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 52 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
}, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_old_archive_ids': [make_archive_id(self, old_video_id)] if old_video_id else None,
'title': title,
'http_headers': {'Referer': url},
}
is_interactive = traverse_obj... | ```suggestion
flv_formats = traverse_obj(formats, lambda _, v: v['fragments'])
if flv_formats and len(flv_formats) < len(formats):
# Flv and mp4 are incompatible due to `multi_video` workaround, so drop one
``` | 'view_count': (('viewCount', ('stat', 'view')), {int_or_none}),
'comment_count': ('stat', 'reply', {int_or_none}),
}, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_old_archive_ids': [make_archive_id(self, old_video_id)] if... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | suggestion | 266 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'http_headers': {'Referer': url},
}
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
self._get_interactive_entries(video_id, cid, metainfo, headers=headers), **metainfo,
... | ```suggestion
dropped_fmts = ', '.join(
f'{f.get("format_note")} ({f.get("format_id")})' for f in flv_formats)
``` | '_old_archive_ids': [make_archive_id(self, old_video_id)] if old_video_id else None,
'title': title,
'http_headers': {'Referer': url},
}
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.714 | suggestion | 169 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
formats = self.extract_formats(play_info)
if not traverse_obj(play_info, ('dash')):
# we only have legacy fo... |
```suggestion
formats = traverse_obj(
# XXX: Filtering by extractor-arg is for testing purposes
formats, lambda _, v: v['quality'] == int(self._configuration_arg('prefer_multi_flv')[0]),
) or [max(flv_formats, ... | return self.playlist_result(
self._get_interactive_entries(video_id, cid, metainfo, headers=headers), **metainfo,
duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.857 | refactor | 353 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
else:
formats = self.extract_formats(play_info)
if not traverse_obj(play_info, ('dash')):
# we only have legacy formats and need additional work
has_qn = lambda x: x in traverse_obj(formats, (..., 'quality'))
for qn in traverse_obj(play_in... | ```suggestion
if traverse_obj(formats, (0, 'fragments')):
``` | duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
formats = self.extract_formats(play_info)
if not traverse_obj(play_info, ('dash')):
# we only have legacy fo... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 75 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
else:
formats = traverse_obj(
formats, lambda _, v: v['quality'] == int(self._configuration_arg('_prefer_multi_flv')[0]),
) or [max(traverse_obj(formats, lambda _, v: v['fragments']), key=lambda x: x['quality'])]
... | Should these be on the playlist instead of the first entry? | if dropped_fmts:
self.to_screen(
f'Dropping incompatible flv format(s) {dropped_fmts} since mp4 is available. '
'To extract flv, pass --extractor-args "bilibili:prefer_multi_flv"')
els... | @@ -586,18 +717,62 @@ def _real_extract(self, url):
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
- self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
+ self._get_intera... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.286 | question | 59 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'title': '靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
},
'playlist': [{
'info_dict': {
'id': 'BV1n44y1Q7sc',
'ext': 'mp4',
'title': '“出道一年,我怎么还在等你单推的女人睡觉后开播啊?”【一分钟了解靡烟miya】',
'timestamp': 1669889987,
'upload_date': ... | to be safe we could include the subdomain in the check. and we could set with a leading dot (which is technically correct, although it doesn't matter to python)
```suggestion
if not self._get_cookies('https://api.bilibili.com').get('buvid3'):
self._set_cookie('.bilibili.com', 'buvid3', f'{uuid.uu... | 'title': '靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
},
'playlist': [{
'info_dict': {
'id': 'BV1n44y1Q7sc',
'ext': 'mp4',
'title': '“出道一年,我怎么还在等你单推的女人睡觉后开播啊?”【一分钟了解靡烟miya】',
'timestamp': 1669889987,
'upload_date': ... | @@ -1464,8 +1465,37 @@ class BiliBiliSearchIE(SearchInfoExtractor):
IE_DESC = 'Bilibili video search'
_MAX_RESULTS = 100000
_SEARCH_KEY = 'bilisearch'
+ _TESTS = [{
+ 'url': 'bilisearch3:靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
+ 'playlist_count': 3,
+ 'info_dict': {
+ 'id': '靡烟 出道... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.857 | suggestion | 338 | 51 | 51 | false | [extractor/bilibili] fix BiliBiliSearch HTTP 412 banned | 9,119 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
_MAX_RESULTS = 100000
_SEARCH_KEY = 'bilisearch'
_TESTS = [{
'url': 'bilisearch3:靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
'playlist_count': 3,
'info_dict': {
'id': '靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
'title': '靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
},
'playlist': [{
... | ```suggestion
'_old_archive_ids': ['bilibili 988222410_part1'],
``` | _MAX_RESULTS = 100000
_SEARCH_KEY = 'bilisearch'
_TESTS = [{
'url': 'bilisearch3:靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
'playlist_count': 3,
'info_dict': {
'id': '靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
'title': '靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
},
'playlist': [{
... | @@ -1464,8 +1465,37 @@ class BiliBiliSearchIE(SearchInfoExtractor):
IE_DESC = 'Bilibili video search'
_MAX_RESULTS = 100000
_SEARCH_KEY = 'bilisearch'
+ _TESTS = [{
+ 'url': 'bilisearch3:靡烟 出道一年,我怎么还在等你单推的女人睡觉后开播啊',
+ 'playlist_count': 3,
+ 'info_dict': {
+ 'id': '靡烟 出道... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 85 | 51 | 51 | false | [extractor/bilibili] fix BiliBiliSearch HTTP 412 banned | 9,119 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
_TESTS = [{
'url': 'https://radio1.be/luister/select/de-ochtend/komt-n-va-volgend-jaar-op-in-wallonie',
'info_dict': {
'id': 'eb6c22e9-544f-44f4-af39-cf8cccd29e22',
'title': 'Komt N-VA volgend jaar op in Wallonië?',
'display_id': 'komt-n-va-volgend-jaar-op-in-wall... | We can already check that all entries have a mediaReference
```suggestion
video_data = traverse_obj(
next_js_data, ((None, ('paragraphs', ...)), {lambda x: x if x['mediaReference'] else None}))
``` | 'url': 'https://radio1.be/luister/select/de-ochtend/komt-n-va-volgend-jaar-op-in-wallonie',
'info_dict': {
'id': 'eb6c22e9-544f-44f4-af39-cf8cccd29e22',
'title': 'Komt N-VA volgend jaar op in Wallonië?',
'display_id': 'de-ochtend/komt-n-va-volgend-jaar-op-in-wallonie'... | @@ -425,3 +427,74 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/\w+(/[\w-]+/[\w-]+)?/(?P<di... | yt_dlp/extractor/vrt.py | 26 | Python | 0.786 | suggestion | 221 | 51 | 51 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
'display_id': 'komt-n-va-volgend-jaar-op-in-wallonie',
'description': 'md5:b374ea1c9302f38362df9dea1931468e',
'thumbnail': r're:https?://cds\.vrt\.radio/[^/#\?&]+'
},
'playlist_mincount': 1
}, {
'url': 'https://radio1.be/lees/europese-unie-wil-onmiddellijk... | ```suggestion
media_reference = data['mediaReference']
formats, subtitles = self._extract_formats_and_subtitles(
self._call_api(media_reference), display_id)
``` | 'description': 'md5:b374ea1c9302f38362df9dea1931468e',
'thumbnail': r're:https?://cds\.vrt\.radio/[^/#\?&]+'
},
'playlist_mincount': 1
}, {
'url': 'https://radio1.be/lees/europese-unie-wil-onmiddellijke-humanitaire-pauze-en-duurzaam-staakt-het-vuren-in-gaza?view=web',... | @@ -425,3 +427,74 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/\w+(/[\w-]+/[\w-]+)?/(?P<di... | yt_dlp/extractor/vrt.py | 26 | Python | 0.857 | refactor | 205 | 51 | 51 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
'info_dict': {
'id': '5d47f102-dbdb-4fa0-832b-26c1870311f2',
'title': 'Europese Unie wil "onmiddellijke humanitaire pauze" en "duurzaam staakt-het-vuren" in Gaza',
'description': 'md5:1aad1fae7d39edeffde5d3e67d276b64',
'thumbnail': r're:https?://cds\.vrt\.radio/[^... | Just to be sure, let's also validate the type
```suggestion
'title': ('title', {str}),
``` | 'id': '5d47f102-dbdb-4fa0-832b-26c1870311f2',
'title': 'Europese Unie wil "onmiddellijke humanitaire pauze" en "duurzaam staakt-het-vuren" in Gaza',
'description': 'md5:1aad1fae7d39edeffde5d3e67d276b64',
'thumbnail': r're:https?://cds\.vrt\.radio/[^/#\?&]+',
'... | @@ -425,3 +427,74 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/\w+(/[\w-]+/[\w-]+)?/(?P<di... | yt_dlp/extractor/vrt.py | 26 | Python | 0.857 | suggestion | 113 | 51 | 45 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
return entries
def _real_extract(self, url):
display_id = self._match_valid_url(url).group('display_id')
webpage = self._download_webpage(url, display_id)
next_js_data = self._search_nextjs_data(webpage, display_id)['props']['pageProps']['item']
entries = self._extract_vide... | ```suggestion
return self.playlist_result(
entries, **merge_dicts(traverse_obj(
next_js_data, ({
'id': ('id', {str}),
'title': ('title', {str}),
'description': (('description', 'content'), {clean_html}),
... | import functools
import json
import time
import urllib.parse
from .gigya import GigyaBaseIE
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
clean_html,
extract_attributes,
float_or_none,
get_element_by_class,
get_element_html_by_class,
int_or_none,
jo... | @@ -425,3 +427,74 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/\w+(/[\w-]+/[\w-]+)?/(?P<di... | yt_dlp/extractor/vrt.py | 26 | Python | 0.786 | suggestion | 725 | 27 | 490 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
video_id = self._html_search_regex(
r'data-url=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'video id', group='id')
data = self._call_api(video_id, 'dako@prod', ... | How about, like this?
```suggestion
_VALID_URL = r'https?://radio1\.be/(?:lees|luister/select)/(?P<display_id>[\w/-]+)'
``` | def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
video_id = self._html_search_regex(
r'data-url=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'video id', group='id')
data = self._call_api(video_id, 'dako@prod', v... | @@ -425,3 +427,74 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/\w+(/[\w-]+/[\w-]+)?/(?P<di... | yt_dlp/extractor/vrt.py | 26 | Python | 0.714 | question | 130 | 51 | 51 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
'description': 'md5:1aad1fae7d39edeffde5d3e67d276b64',
'thumbnail': r're:https?://cds\.vrt\.radio/[^/#\?&]+',
'display_id': 'europese-unie-wil-onmiddellijke-humanitaire-pauze-en-duurzaam-staakt-het-vuren-in-gaza'
},
'playlist_mincount': 1
}]
def _extract_vide... | ```suggestion
def _extract_video_entries(self, next_js_data, display_id):
video_data = traverse_obj(
next_js_data, ((None, ('paragraphs', ...)), {lambda x: x if x['mediaReference'] else None}))
for data in video_data:
media_reference = data['mediaReference']
... | 'description': 'md5:1aad1fae7d39edeffde5d3e67d276b64',
'thumbnail': r're:https?://cds\.vrt\.radio/[^/#\?&]+',
'display_id': 'europese-unie-wil-onmiddellijke-humanitaire-pauze-en-duurzaam-staakt-het-vuren-in-gaza'
},
'playlist_mincount': 1
}]
def _extract_vide... | @@ -425,3 +426,66 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/(?:lees|luister/select)/(?P... | yt_dlp/extractor/vrt.py | 26 | Python | 0.857 | refactor | 769 | 45 | 43 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
video_data = traverse_obj(
next_js_data, ((None, ('paragraphs', ...)), {lambda x: x if x['mediaReference'] else None}))
for data in video_data:
media_reference = data['mediaReference']
formats, subtitles = self._extract_formats_and_subtitles(
self._cal... | ```suggestion
return self.playlist_result(
self._extract_video_entries(next_js_data, display_id), **merge_dicts(traverse_obj(
``` | next_js_data, ((None, ('paragraphs', ...)), {lambda x: x if x['mediaReference'] else None}))
for data in video_data:
media_reference = data['mediaReference']
formats, subtitles = self._extract_formats_and_subtitles(
self._call_api(media_reference), display_id)... | @@ -425,3 +426,66 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/(?:lees|luister/select)/(?P... | yt_dlp/extractor/vrt.py | 26 | Python | 0.786 | refactor | 152 | 36 | 34 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'formats': formats,
'subtitles': subtitles,
**traverse_obj(data, {
'title': ('title', {str}),
'description': ('body', {clean_html})
})
})
return entries
def _real_extract(self, url):
... | ```suggestion
'thumbnail': self._html_search_meta(['og:image', 'twitter:image'], webpage),
}))
``` | import functools
import json
import time
import urllib.parse
from .gigya import GigyaBaseIE
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
clean_html,
extract_attributes,
float_or_none,
get_element_by_class,
get_element_html_by_class,
int_or_none,
jo... | @@ -425,3 +426,66 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/(?:lees|luister/select)/(?P... | yt_dlp/extractor/vrt.py | 26 | Python | 0.714 | suggestion | 137 | 27 | 490 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
VKWallPostIE,
VKPlayIE,
VKPlayLiveIE,
)
from .vocaroo import VocarooIE
from .vodpl import VODPlIE
from .vodplatform import VODPlatformIE
from .voicy import (
VoicyIE,
VoicyChannelIE,
)
from .volejtv import VolejTVIE
from .voot import (
VootIE,
VootSeriesIE,
)
from .voxmedia import (
VoxM... | ```suggestion
Radio1BeIE,
``` | VKWallPostIE,
VKPlayIE,
VKPlayLiveIE,
)
from .vocaroo import VocarooIE
from .vodpl import VODPlIE
from .vodplatform import VODPlatformIE
from .voicy import (
VoicyIE,
VoicyChannelIE,
)
from .volejtv import VolejTVIE
from .voot import (
VootIE,
VootSeriesIE,
)
from .voxmedia import (
VoxM... | @@ -2289,6 +2289,7 @@
VrtNUIE,
KetnetIE,
DagelijkseKostIE,
+ Radio1BeIE | yt_dlp/extractor/_extractors.py | 26 | Python | 0.429 | suggestion | 35 | 51 | 51 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'id': media_reference,
'formats': formats,
'subtitles': subtitles,
**traverse_obj(data, {
'title': ('title', {str}),
'description': ('body', {clean_html})
}),
}
def _real_extract(self... | ```suggestion
}))
``` | 'id': media_reference,
'formats': formats,
'subtitles': subtitles,
**traverse_obj(data, {
'title': ('title', {str}),
'description': ('body', {clean_html})
}),
}
def _real_extract(self... | @@ -425,3 +426,64 @@ def _real_extract(self, url):
['description', 'twitter:description', 'og:description'], webpage),
'_old_archive_ids': [make_archive_id('Canvas', video_id)],
}
+
+
+class Radio1BeIE(VRTBaseIE):
+ _VALID_URL = r'https?://radio1\.be/(?:lees|luister/select)/(?P... | yt_dlp/extractor/vrt.py | 26 | Python | 0.429 | suggestion | 35 | 27 | 27 | false | [ie/Radio1Be] Add extractor | 9,122 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
import json
from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_iso8601,
str_or_none,
traverse_obj,
url_or_none,
urljoin,
)
class KhanAcademyBaseIE(InfoExtractor):
_VALID_URL_TEMPL = r'https?://(?:www\.)?khanacademy\.org/(?P<id>(?:[^/]+/){%s}%s[^?#/&]+)'
def _p... | ```suggestion
'url': video['youtubeId'],
'id': video['youtubeId'],
'ie_key': 'Youtube',
**traverse_obj(video, {
'display_id': ('id', {str_or_none}),
```
`id` should be same as inner extractor (youtube). It's mistake in old IE | import json
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
parse_iso8601,
str_or_none,
traverse_obj,
url_or_none,
urljoin,
)
class KhanAcademyBaseIE(InfoExtractor):
_VALID_URL_TEMPL = r'https?://(?:www\.)?khanacademy\.org/(?P<id>(?:[^/]+/){%s}%s[... | @@ -14,97 +17,118 @@ class KhanAcademyBaseIE(InfoExtractor):
def _parse_video(self, video):
return {
'_type': 'url_transparent',
- 'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUr... | yt_dlp/extractor/khanacademy.py | 23 | Python | 0.857 | refactor | 298 | 48 | 48 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | c-basalt |
class KhanAcademyBaseIE(InfoExtractor):
_VALID_URL_TEMPL = r'https?://(?:www\.)?khanacademy\.org/(?P<id>(?:[^/]+/){%s}%s[^?#/&]+)'
def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
'id': video['youtubeId'],
'ie... | Okay, this doesn't work right now. This hash value is the hash of the graphql query, with this being the hash function:
```javascript
e.exports = function(e) {
for (var t = 5381, n = e.length; n; )
t = 33 * t ^ e.charCodeAt(--n);
return t >>> 0
}
````
Let's just update the value for now, but if ... |
class KhanAcademyBaseIE(InfoExtractor):
_VALID_URL_TEMPL = r'https?://(?:www\.)?khanacademy\.org/(?P<id>(?:[^/]+/){%s}%s[^?#/&]+)'
_PUBLISHED_CONTENT_VERSION = '171419ab20465d931b356f22d20527f13969bb70'
def _parse_video(self, video):
return {
'_type': 'url_transparent',
'u... | @@ -15,96 +18,118 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.857 | refactor | 684 | 51 | 51 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'live_status': 'not_live',
'channel': 'Khan Academy',
'channel_id': 'UC4a-Gbdw7vOaccHmFo40b9g',
'channel_url': 'https://www.youtube.com/channel/UC4a-Gbdw7vOaccHmFo40b9g',
'channel_is_verified': True,
'playable_in_embed': True,
'categori... | I think I would go with creators instead of uploader
```suggestion
'creators': ('authorNames', ..., {str}),
``` | 'uploader_url': 'https://www.youtube.com/@khanacademy',
'upload_date': '20120411',
'timestamp': 1334170113,
'license': 'cc-by-nc-sa',
'live_status': 'not_live',
'channel': 'Khan Academy',
'channel_id': 'UC4a-Gbdw7vOaccHmFo40b9g',
... | @@ -15,96 +18,118 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.786 | security | 130 | 51 | 51 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
class KhanAcademyUnitIE(KhanAcademyBaseIE):
IE_NAME = 'khanacademy:unit'
_VALID_URL = (KhanAcademyBaseIE._VALID_URL_TEMPL % ('1,2', '')) + '/?(?:[?#&]|$)'
_TESTS = [{
'url': 'https://www.khanacademy.org/computing/computer-science/cryptography',
'info_dict': {
'id': 'cryptography... | I was thinking a bit on how to improve this. What do you think of this?
```suggestion
selected_unit = traverse_obj(course, (
'unitChildren', lambda _, v: v['relativeUrl'] == f'/{display_id}'), get_all=False) or course
``` | }),
}
class KhanAcademyUnitIE(KhanAcademyBaseIE):
IE_NAME = 'khanacademy:unit'
_VALID_URL = (KhanAcademyBaseIE._VALID_URL_TEMPL % ('1,2', '')) + '/?(?:[?#&]|$)'
_TESTS = [{
'url': 'https://www.khanacademy.org/computing/computer-science/cryptography',
'info_dict': {
... | @@ -15,96 +18,120 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.786 | suggestion | 245 | 37 | 51 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
_TESTS = [{
'url': 'https://www.khanacademy.org/computing/computer-science/cryptography',
'info_dict': {
'id': 'cryptography',
'title': 'Cryptography',
'description': 'How have humans protected their secret messages through history? What has changed today?',
... | ```suggestion
def build_entry(entry):
return self.url_result(urljoin(
'https://www.khanacademy.org', entry['canonicalUrl']),
KhanAcademyIE, title=entry.get('translatedTitle'))
entries = traverse_obj(selected_unit, (
(('unitChildren', ...), ... | class KhanAcademyUnitIE(KhanAcademyBaseIE):
IE_NAME = 'khanacademy:unit'
_VALID_URL = (KhanAcademyBaseIE._VALID_URL_TEMPL % ('1,2', '')) + '/?(?:[?#&]|$)'
_TESTS = [{
'url': 'https://www.khanacademy.org/computing/computer-science/cryptography',
'info_dict': {
'id': 'x48c910b6',
... | @@ -15,96 +18,120 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.786 | suggestion | 470 | 33 | 49 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
},
'playlist_mincount': 31,
}, {
'url': 'https://www.khanacademy.org/computing/computer-science',
'info_dict': {
'id': 'computer-science',
'title': 'Computer science theory',
'description': 'md5:4b472a4646e6cf6ec4ccb52c4062f8ba',
},
... | I am tempted to change the ID here to the actual ID instead of the slug. The slug seems like a value that could be the same across different courses.
Do you think that makes sense?
```suggestion
return self.playlist_result(
entries,
display_id=display_id,
**traverse_obj... | 'id': 'x48c910b6',
'title': 'Cryptography',
'description': 'How have humans protected their secret messages through history? What has changed today?',
'display_id': 'computing/computer-science/cryptography',
'_old_archive_ids': ['khanacademyunit cryptography']... | @@ -15,96 +18,120 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.857 | suggestion | 609 | 27 | 43 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
},
'playlist_mincount': 50,
}]
def _parse_component_props(self, component_props, display_id):
course = component_props['course']
selected_unit = traverse_obj(course, (
'unitChildren', lambda _, v: v['relativeUrl'] == f'/{display_id}'), get_all=False) or course
... | ```suggestion
'_old_archive_ids': ('slug', {str}, {lambda x: [make_archive_id(self, x)] if x else None}),
``` | 'display_id': 'computing/computer-science',
'_old_archive_ids': ['khanacademyunit computer-science'],
},
'playlist_mincount': 50,
}]
def _parse_component_props(self, component_props, display_id):
course = component_props['course']
selected_unit = traverse... | @@ -15,96 +19,133 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.714 | suggestion | 127 | 28 | 30 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
_TESTS = [{
'url': 'https://www.khanacademy.org/computing/computer-science/cryptography',
'info_dict': {
'id': 'x48c910b6',
'title': 'Cryptography',
'description': 'How have humans protected their secret messages through history? What has changed today?',
... | ```suggestion
'unitChildren', lambda _, v: v['relativeUrl'] == f'/{display_id}', any)) or course
``` | IE_NAME = 'khanacademy:unit'
_VALID_URL = (KhanAcademyBaseIE._VALID_URL_TEMPL % ('1,2', '')) + '/?(?:[?#&]|$)'
_TESTS = [{
'url': 'https://www.khanacademy.org/computing/computer-science/cryptography',
'info_dict': {
'id': 'x48c910b6',
'title': 'Cryptography',
... | @@ -15,96 +19,133 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.714 | suggestion | 114 | 46 | 48 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'channel_id': 'UC4a-Gbdw7vOaccHmFo40b9g',
'channel_url': 'https://www.youtube.com/channel/UC4a-Gbdw7vOaccHmFo40b9g',
'channel_is_verified': True,
'playable_in_embed': True,
'categories': ['Education'],
'creators': ['Brit Cruise'],
'tags... | ```suggestion
'timestamp': ('dateAdded', {parse_iso8601}),
``` | 'live_status': 'not_live',
'channel': 'Khan Academy',
'channel_id': 'UC4a-Gbdw7vOaccHmFo40b9g',
'channel_url': 'https://www.youtube.com/channel/UC4a-Gbdw7vOaccHmFo40b9g',
'channel_is_verified': True,
'playable_in_embed': True,
'categori... | @@ -15,96 +19,133 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.571 | suggestion | 80 | 51 | 51 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
class KhanAcademyBaseIE(InfoExtractor):
_VALID_URL_TEMPL = r'https?://(?:www\.)?khanacademy\.org/(?P<id>(?:[^/]+/){%s}%s[^?#/&]+)'
def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
'id': video['youtubeId'],
'i... | might be worth making this `pcv` value a class var since it's used in multiple places, and if/when it needs to be changed then it will presumably need to be changed all over |
class KhanAcademyBaseIE(InfoExtractor):
_VALID_URL_TEMPL = r'https?://(?:www\.)?khanacademy\.org/(?P<id>(?:[^/]+/){%s}%s[^?#/&]+)'
_PUBLISHED_CONTENT_VERSION = '171419ab20465d931b356f22d20527f13969bb70'
def _parse_video(self, video):
return {
'_type': 'url_transparent',
'u... | @@ -15,96 +19,133 @@ def _parse_video(self, video):
return {
'_type': 'url_transparent',
'url': video['youtubeId'],
- 'id': video.get('slug'),
- 'title': video.get('title'),
- 'thumbnail': video.get('imageUrl') or video.get('thumbnailUrl'),
- ... | yt_dlp/extractor/khanacademy.py | 26 | Python | 0.571 | suggestion | 173 | 51 | 51 | false | [ie/khanacademy] Fix extractors | 9,136 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'url': 'https://beta.nebula.tv/videos/money-episode-1-the-draw',
'only_matching': True,
}]
def _real_extract(self, url):
slug = self._match_id(url)
url, smuggled_data = unsmuggle_url(url, {})
if smuggled_data.get('id'):
return {
'id': smuggled... | the `/` in the `IE_NAME` will make for some strange-looking commit msgs, but it doesn't actually mess up the changelog, so I guess it's ok | }, {
'url': 'https://beta.nebula.tv/videos/money-episode-1-the-draw',
'only_matching': True,
}]
def _real_extract(self, url):
slug = self._match_id(url)
url, smuggled_data = unsmuggle_url(url, {})
if smuggled_data.get('id'):
return {
'id':... | @@ -236,8 +237,8 @@ def _real_extract(self, url):
class NebulaClassIE(NebulaBaseIE):
- IE_NAME = 'nebula:class'
- _VALID_URL = rf'{_BASE_URL_RE}/(?P<id>[-\w]+)/(?P<ep>\d+)'
+ IE_NAME = 'nebula:class/podcast' | yt_dlp/extractor/nebula.py | 26 | Python | 0.571 | suggestion | 138 | 51 | 51 | false | [ie/nebula] Add podcast support | 9,140 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'only_matching': True,
}]
def _real_extract(self, url):
slug = self._match_id(url)
url, smuggled_data = unsmuggle_url(url, {})
if smuggled_data.get('id'):
return {
'id': smuggled_data['id'],
'display_id': slug,
'title':... | - is the `/` after `videos` intentional?
- I know this is how the old code does it, and it doesn't actually make a difference here, but it's bugging me: should put a literal `-` at the end of a character class
```suggestion
_VALID_URL = rf'{_BASE_URL_RE}/(?!myshows|library|videos)(?P<id>[\w-]+)/(?P<ep>[\w-]+)/?... | 'url': 'https://beta.nebula.tv/videos/money-episode-1-the-draw',
'only_matching': True,
}]
def _real_extract(self, url):
slug = self._match_id(url)
url, smuggled_data = unsmuggle_url(url, {})
if smuggled_data.get('id'):
return {
'id': smuggled... | @@ -236,8 +237,8 @@ def _real_extract(self, url):
class NebulaClassIE(NebulaBaseIE):
- IE_NAME = 'nebula:class'
- _VALID_URL = rf'{_BASE_URL_RE}/(?P<id>[-\w]+)/(?P<ep>\d+)'
+ IE_NAME = 'nebula:class/podcast'
+ _VALID_URL = rf'{_BASE_URL_RE}/(?!myshows|library|videos/)(?P<id>[-\w]+)/(?P<ep>[-\w]+)/?(?:$... | yt_dlp/extractor/nebula.py | 26 | Python | 1 | bug | 336 | 51 | 51 | false | [ie/nebula] Add podcast support | 9,140 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
_VALID_URL = r'https?://(?:www\.)?tv5monde\.com/tv/video/(?P<id>[^/?#]+)'
_TESTS = [{
# documentary
'url': 'https://www.tv5monde.com/tv/video/65931-baudouin-l-heritage-d-un-roi-baudouin-l-heritage-d-un-roi',
'md5': 'd2a708902d3df230a357c99701aece05',
'info_dict': {
'i... | ```suggestion
'description': 'md5:da441d0b328793dfb4059884fbee6af3',
``` | _VALID_URL = r'https?://(?:www\.)?tv5monde\.com/tv/video/(?P<id>[^/?#]+)'
_TESTS = [{
# documentary
'url': 'https://www.tv5monde.com/tv/video/65931-baudouin-l-heritage-d-un-roi-baudouin-l-heritage-d-un-roi',
'md5': 'd2a708902d3df230a357c99701aece05',
'info_dict': {
'i... | @@ -14,73 +15,69 @@
class TV5MondePlusIE(InfoExtractor):
IE_DESC = 'TV5MONDE+'
- _VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
+ _VALID_URL = r'https?://(?:www\.)?tv5monde\.com/tv/video/(?P<id>[^/?#]+)'
_TESTS = [{
- # movie
-... | yt_dlp/extractor/tv5mondeplus.py | 26 | Python | 0.571 | suggestion | 86 | 51 | 51 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | alard |
import re
import urllib.parse
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
parse_duration,
traverse_obj,
try_get,
url_or_none,
)
class TV5MondePlusIE(InfoExtractor):
IE_DESC = 'TV5MONDE+'
_VALID_URL = r'https?://(?:www\.)?... | As the extractor no longer works with TV5MONDE+ this should be renamed.
```suggestion
IE_DESC = 'TV5MONDE'
```
It is a bit odd to have the extractor still named `TV5MondePlusIE`, but due to the ID space seemingly being the same, I would not rename it. | import urllib.parse
from .common import InfoExtractor
from ..utils import (
clean_html,
determine_ext,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
int_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TV5MondePlusIE(InfoExtractor):
IE_NA... | @@ -14,73 +15,69 @@
class TV5MondePlusIE(InfoExtractor):
IE_DESC = 'TV5MONDE+' | yt_dlp/extractor/tv5mondeplus.py | 17 | Python | 0.857 | refactor | 259 | 42 | 42 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | alard |
if video_format == 'm3u8':
formats.extend(self._extract_m3u8_formats(
v_url, display_id, 'mp4', 'm3u8_native',
m3u8_id='hls', fatal=False))
elif video_format == 'mpd':
formats.extend(self._extract_mpd... | I know the extractor previously did something similar, but I am not sure if we should touch the title. Maybe just return subtitle always as the episode title, and then the user can use output templates to set the title they want? e.g. `-o "%(series)s - %(episode)s.%(ext)s"`
At least change this to use f-strings. | # data-guid from the webpage isn't stable, use the material id from the json urls
video_id = self._search_regex(
r'materials/([\da-zA-Z]{10}_[\da-fA-F]{7})/', v_url, 'video id', default=None)
process_video_files(deferred_json)
... | @@ -151,16 +147,20 @@ def process_video_files(v):
duration = (int_or_none(try_get(metadata, lambda x: x['content']['duration']))
or parse_duration(self._html_search_meta('duration', webpage)))
- description = self._html_search_regex(
- r'(?s)<div[^>]+class=["\']episode-... | yt_dlp/extractor/tv5mondeplus.py | 26 | Python | 0.643 | refactor | 316 | 51 | 49 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | alard |
video_id = self._search_regex(
r'materials/([\da-zA-Z]{10}_[\da-fA-F]{7})/', v_url, 'video id', default=None)
process_video_files(deferred_json)
video_format = video_file.get('format') or determine_ext(v_url)
if video_forma... | This does not need to be fatal. | f'https://api.tv5monde.com/player/asset/{d_param}/resolve?condenseKS=true', display_id,
note='Downloading deferred info', headers={'Authorization': f'Bearer {token}'}, fatal=False)
v_url = traverse_obj(deferred_json, (0, 'url', {url_or_none}))
... | @@ -151,16 +147,20 @@ def process_video_files(v):
duration = (int_or_none(try_get(metadata, lambda x: x['content']['duration']))
or parse_duration(self._html_search_meta('duration', webpage)))
- description = self._html_search_regex(
- r'(?s)<div[^>]+class=["\']episode-... | yt_dlp/extractor/tv5mondeplus.py | 26 | Python | 0.071 | suggestion | 31 | 51 | 51 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | alard |
import re
import urllib.parse
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
parse_duration,
traverse_obj,
try_get,
url_or_none,
)
class TV5MondePlusIE(InfoExtractor):
IE_NAME = 'TV5MONDE'
IE_DESC = 'TV5MONDE'
_VALID_URL... | if they're the same, `IE_NAME` alone should suffice
```suggestion
``` | import urllib.parse
from .common import InfoExtractor
from ..utils import (
clean_html,
determine_ext,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
int_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TV5MondePlusIE(InfoExtractor):
IE_NA... | @@ -13,74 +14,71 @@
class TV5MondePlusIE(InfoExtractor):
- IE_DESC = 'TV5MONDE+'
- _VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
+ IE_NAME = 'TV5MONDE'
+ IE_DESC = 'TV5MONDE' | yt_dlp/extractor/tv5mondeplus.py | 18 | Python | 0.643 | suggestion | 71 | 43 | 43 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alard |
r'materials/([\da-zA-Z]{10}_[\da-fA-F]{7})/', v_url, 'video id', default=None)
process_video_files(deferred_json)
video_format = video_file.get('format') or determine_ext(v_url)
if video_format == 'm3u8':
formats.extend(sel... | since `series` isn't used anywhere else anymore, we can inline in the return | v_url = traverse_obj(deferred_json, (0, 'url', {url_or_none}))
if not v_url:
continue
# data-guid from the webpage isn't stable, use the material id from the json urls
video_id = self._search_regex(
... | @@ -151,16 +148,19 @@ def process_video_files(v):
duration = (int_or_none(try_get(metadata, lambda x: x['content']['duration']))
or parse_duration(self._html_search_meta('duration', webpage)))
- description = self._html_search_regex(
- r'(?s)<div[^>]+class=["\']episode-... | yt_dlp/extractor/tv5mondeplus.py | 26 | Python | 0.429 | suggestion | 76 | 51 | 51 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alard |
else:
formats.append({
'url': v_url,
'format_id': video_format,
})
process_video_files(video_files)
metadata = self._parse_json(
vpl_data['data-metadata'], display_id)
duration =... | could we simplify this with `get_element_by_class` (utils)? | v_url, display_id, 'mp4', 'm3u8_native',
m3u8_id='hls', fatal=False))
elif video_format == 'mpd':
formats.extend(self._extract_mpd_formats(
v_url, display_id, fatal=False))
else:
... | @@ -151,16 +148,19 @@ def process_video_files(v):
duration = (int_or_none(try_get(metadata, lambda x: x['content']['duration']))
or parse_duration(self._html_search_meta('duration', webpage)))
- description = self._html_search_regex(
- r'(?s)<div[^>]+class=["\']episode-... | yt_dlp/extractor/tv5mondeplus.py | 26 | Python | 0.429 | refactor | 59 | 51 | 41 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alard |
})
process_video_files(video_files)
metadata = self._parse_json(
vpl_data.get('data-metadata') or '{}', display_id, fatal=False)
if not video_id:
video_id = self._search_regex(
(r'data-guid=["\']([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da... | this is fatal if we don't do this:
```suggestion
'description': clean_html(get_element_by_class('text', get_element_html_by_class('ep-summary', webpage) or '')),
``` | })
process_video_files(video_files)
metadata = self._parse_json(
vpl_data.get('data-metadata') or '{}', display_id, fatal=False)
if not video_id:
video_id = self._search_regex(
(r'data-guid=["\']([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da... | @@ -175,16 +158,20 @@ def process_video_files(v):
default=display_id)
return {
+ **traverse_obj(metadata, ('content', {
+ 'id': ('id', {str}),
+ 'title': ('title', {str}),
+ 'episode': ('title', {str}),
+ 'series': ('seri... | yt_dlp/extractor/tv5mondeplus.py | 26 | Python | 0.714 | suggestion | 180 | 32 | 32 | false | [ie/TV5Monde] Fix extractor | 9,143 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alard |
# youtube fields
'age_limit': 0,
'availability': 'public',
'categories': list,
'channel_follower_count': int,
'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
'channel_is_verified': bool,
'channel_url': r're:^https://www.youtube.co... | ```suggestion
post = self._download_json(
f'https://api.boosty.to/v1/blog/{user}/post/{post_id}', post_id,
note='Downloading post data', errnote='Unable to download post data')
``` | 'duration': 25704,
'view_count': int,
'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
},
}, {
'info_dict': {
'id': '4a3bba32-78c8-422a-9432-2791aff60b42',
'title': 'то что не пропустил юта6',
... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 26 | Python | 0.857 | suggestion | 218 | 51 | 51 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
# one of: 'tiny', 'low', etc.; see _get_quality for full list
formats.append({
'url': url,
'ext': 'mp4',
'format_id': _type,
})
for format in formats:
# .../type/<d>/... or ...&type=<d>&...
... | This can be simplified. I also prefer explicitly naming all hls/dash formats instead of checking if the string contains either.
```suggestion
def _extract_formats(self, player_urls, video_id):
formats = []
mp4_types = ('tiny', 'lowest', 'low', 'medium', 'high', 'full_hd', 'quad_hd', 'ultra_hd')
... | from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
int_or_none,
qualities,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class BoostyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/po... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 26 | Python | 1 | refactor | 1,306 | 27 | 210 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
from .common import InfoExtractor
from ..utils import ExtractorError, dict_get, qualities, traverse_obj
class BoostyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
_TESTS = [{
# single ok_video
'url': 'https://boosty.to/kuplinov/pos... | Escape `.` in these
```suggestion
'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
``` | from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
int_or_none,
qualities,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class BoostyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/po... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 23 | Python | 0.714 | security | 109 | 48 | 48 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
'age_limit': 0,
'availability': 'public',
'categories': list,
'channel_follower_count': int,
'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
'channel_is_verified': bool,
'channel_url': r're:^https://www.youtube.com/',
'comment_cou... | I think it is better to inline title/entries extraction and construct a common metadata dict:
```suggestion
post_title = post.get('title')
if not post_title:
self.report_warning('Unable to extract post title. Falling back to parsing html page')
webpage = self._download_webpa... | 'view_count': int,
'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
},
}, {
'info_dict': {
'id': '4a3bba32-78c8-422a-9432-2791aff60b42',
'title': 'то что не пропустил юта6',
'channel': 'Илья Давыдов',... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 26 | Python | 0.857 | refactor | 1,058 | 51 | 51 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
'availability': 'public',
'categories': list,
'channel_follower_count': int,
'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
'channel_is_verified': bool,
'channel_url': r're:^https://www.youtube.com/',
'comment_count': int,
'descr... | Which can then be applied here to every entry.
```suggestion
entries = []
for item in traverse_obj(post, ('data', ..., {dict})):
item_type = item.get('type')
if item_type == 'video' and url_or_none(item.get('url')):
entries.append(self.url_result(item['url']... | 'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
},
}, {
'info_dict': {
'id': '4a3bba32-78c8-422a-9432-2791aff60b42',
'title': 'то что не пропустил юта6',
'channel': 'Илья Давыдов',
'channel_id': '680... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 26 | Python | 1 | refactor | 1,120 | 51 | 51 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
user, post_id = self._match_valid_url(url).group('user', 'post_id')
post = self._download_json(
f'https://api.boosty.to/v1/blog/{user}/post/{post_id}',
post_id,
note='Downloading post data',
errnote='Unable to download post data')
post_title = self... | And finally, we can then also return that common metadata for the playlist.
```suggestion
if not entries:
raise ExtractorError('No videos found', expected=True)
if len(entries) == 1:
return entries[0]
return self.playlist_result(entries, post_id, post_title, **commo... | 'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
},
}],
}, {
# single external video (youtube)
'url': 'https://boosty.to/denischuzhoy/posts/6094a487-bcec-4cf8-a453-43313b463c38',
'info_dict': {
'id': 'EXelTnve5lY',
'title': ... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 26 | Python | 1 | refactor | 381 | 51 | 51 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
url = None
formats = None
item_id = item.get('id', post_id)
item_type = item.get('type')
if item_type == 'video':
url = item.get('url')
elif item_type == 'ok_video':
formats = self._extract_formats(
... | With title/entries extraction being in `_real_extract` we can remove these two functions:
```suggestion
``` | for player_url in traverse_obj(player_urls, lambda _, v: url_or_none(v['url'])):
url = player_url['url']
format_type = player_url.get('type')
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
formats.extend(self._extract_m3u8_for... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
+ _TESTS = [{
+ # single ok_video
+ 'url': 'htt... | yt_dlp/extractor/boosty.py | 26 | Python | 0.786 | refactor | 109 | 51 | 51 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
from .common import InfoExtractor
from ..utils import ExtractorError, dict_get, qualities, traverse_obj
class BoostyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/posts/(?P<post_id>[^/#?]+)'
_TESTS = [{
# single ok_video
'url': 'https://boosty.to/kuplinov/pos... | ```suggestion
from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
int_or_none,
qualities,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
``` | from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
int_or_none,
qualities,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class BoostyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?boosty\.to/(?P<user>[^/#?]+)/po... | @@ -0,0 +1,212 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, dict_get, qualities, traverse_obj | yt_dlp/extractor/boosty.py | 2 | Python | 1 | refactor | 246 | 27 | 27 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | un-def |
'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
'channel_is_verified': bool,
'channel_url': r're:^https://www\.youtube\.com/',
'comment_count': int,
'description': str,
'heatmap': 'count:100',
'live_status': str,
'playable_in_embe... | `title` doesn't need to be fatal (and shouldn't imo), and I don't think we need two warnings
```suggestion
post_title = self._og_search_title(webpage, default=None) or self._html_extract_title(webpage)
``` | 'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
'channel_is_verified': bool,
'channel_url': r're:^https://www\.youtube\.com/',
'comment_count': int,
'description': str,
'heatmap': 'count:100',
'live_status': str,
'playable_in_embe... | @@ -0,0 +1,209 @@
+from .common import InfoExtractor
+from .youtube import YoutubeIE
+from ..utils import (
+ ExtractorError,
+ int_or_none,
+ qualities,
+ str_or_none,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BoostyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)... | yt_dlp/extractor/boosty.py | 26 | Python | 0.857 | refactor | 220 | 51 | 51 | false | [ie/boosty] Add extractor | 9,144 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | un-def |
}
}''' % (method, param_name, video_id),
}
return self._download_base_gql(
video_id, ops,
'Downloading %s access token GraphQL' % token_kind)['data'][method]
def _get_thumbnails(self, thumbnail):
return [{
'url': re.sub(r'\d+x\d+... | ```suggestion
'platform': 'web',
'player': 'twitchweb',
'supported_codecs': 'av1,h265,h264',
``` | }
}''' % (method, param_name, video_id),
}
return self._download_base_gql(
video_id, ops,
'Downloading %s access token GraphQL' % token_kind)['data'][method]
def _get_thumbnails(self, thumbnail):
return [{
'url': re.sub(r'\d+x\d+... | @@ -198,7 +198,9 @@ def _extract_twitch_m3u8_formats(self, video_id, token, signature):
'allow_audio_only': 'true',
'allow_spectre': 'true',
'p': random.randint(1000000, 10000000),
+ "platform": "web",
'player': 'twitchweb',
+ ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.714 | suggestion | 148 | 51 | 51 | false | [extractor/twitch] Support AV1/HEVC extraction | 9,158 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kasper93 |
signature
}
}''' % (method, param_name, video_id),
}
return self._download_base_gql(
video_id, ops,
'Downloading %s access token GraphQL' % token_kind)['data'][method]
def _get_thumbnails(self, thumbnail):
return [{
... | From some testing, it seems that yt-dlp (ffmpeg) cannot successfully download an av1 twitch livestream. If we add this format, it should be deprioritized | signature
}
}''' % (method, param_name, video_id),
}
return self._download_base_gql(
video_id, ops,
'Downloading %s access token GraphQL' % token_kind)['data'][method]
def _get_thumbnails(self, thumbnail):
return [{
... | @@ -198,7 +198,9 @@ def _extract_twitch_m3u8_formats(self, video_id, token, signature):
'allow_audio_only': 'true',
'allow_spectre': 'true',
'p': random.randint(1000000, 10000000),
+ 'platform': 'web',
'player': 'twitchweb',
+ ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.429 | suggestion | 153 | 51 | 51 | false | [extractor/twitch] Support AV1/HEVC extraction | 9,158 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kasper93 |
def _get_thumbnails(self, thumbnail):
return [{
'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', r'0x0\g<1>', thumbnail),
'preference': 1,
}, {
'url': thumbnail,
}] if thumbnail else None
def _extract_twitch_m3u8_formats(self, path, video_id, token, sign... | ```suggestion
for fmt in formats:
if fmt.get('vcodec') and fmt['vcodec'].startswith('av01'):
# mpegts does not yet have proper support for av1
fmt['downloader_options'] = {'ffmpeg_args_out': ['-f', 'mp4']}
``` |
def _get_thumbnails(self, thumbnail):
return [{
'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', r'0x0\g<1>', thumbnail),
'preference': 1,
}, {
'url': thumbnail,
}] if thumbnail else None
def _extract_twitch_m3u8_formats(self, path, video_id, token, sign... | @@ -191,17 +191,24 @@ def _get_thumbnails(self, thumbnail):
}] if thumbnail else None
def _extract_twitch_m3u8_formats(self, path, video_id, token, signature):
- return self._extract_m3u8_formats(
+ formats = self._extract_m3u8_formats(
f'{self._USHER_BASE}/{path}/{video_id}.m... | yt_dlp/extractor/twitch.py | 26 | Python | 0.786 | suggestion | 266 | 51 | 51 | false | [extractor/twitch] Support AV1/HEVC extraction | 9,158 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kasper93 |
# extract title
temp = get_elements_by_class('title', webpage_html)
series_title = None
title = None
for html in temp:
mobj = re.search(r'<a\s+.*>(.*)</a>', html)
if mobj:
href = extract_attributes(mobj.group(0)).get('href')
... | Unquote only works on bytes in Python >=3.9 ([ref](<https://docs.python.org/3/library/urllib.parse.html#urllib.parse.unquote>))
```suggestion
data_url = urllib.parse.unquote(base64.b64decode(data_url).decode('ascii'))
``` |
# extract title
temp = get_elements_by_class('title', webpage_html)
series_title = None
title = None
for html in temp:
mobj = re.search(r'<a\s+.*>(.*)</a>', html)
if mobj:
href = extract_attributes(mobj.group(0)).get('href')
... | @@ -129,11 +131,14 @@ def _real_extract(self, url):
data_url = player_data.get('url')
if not data_url:
raise ExtractorError('Cannot find url in player_data')
- data_from = player_data.get('from')
+ if player_data.get('encrypt') == 1:
+ data_url = urllib.parse.unqu... | yt_dlp/extractor/duboku.py | 26 | Python | 0.786 | suggestion | 236 | 51 | 51 | false | [Duboku] Decrypt m3u8 url link | 9,161 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | DmitryScaletta |
player_data = self._parse_json(player_data, video_id, js_to_json)
# extract title
temp = get_elements_by_class('title', webpage_html)
series_title = None
title = None
for html in temp:
mobj = re.search(r'<a\s+.*>(.*)</a>', html)
if mobj:
... | ```suggestion
player_encrypt = player_data.get('encrypt')
if player_encrypt == 1:
data_url = urllib.parse.unquote(data_url)
elif player_encrypt == 2:
``` | player_data = self._parse_json(player_data, video_id, js_to_json)
# extract title
temp = get_elements_by_class('title', webpage_html)
series_title = None
title = None
for html in temp:
mobj = re.search(r'<a\s+.*>(.*)</a>', html)
if mobj:
... | @@ -129,11 +131,14 @@ def _real_extract(self, url):
data_url = player_data.get('url')
if not data_url:
raise ExtractorError('Cannot find url in player_data')
- data_from = player_data.get('from')
+ if player_data.get('encrypt') == 1:
+ data_url = urllib.parse.unqu... | yt_dlp/extractor/duboku.py | 26 | Python | 0.714 | suggestion | 194 | 51 | 51 | false | [Duboku] Decrypt m3u8 url link | 9,161 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DmitryScaletta |
'release_timestamp': 1481126700,
'upload_date': '20211101',
}
}, {
# news
'url': 'https://www.nhk.or.jp/radio/player/ondemand.html?p=F261_01_3855109',
'skip': 'Expires on 2023-04-17',
'info_dict': {
'id': 'F261_01_3855109',
'ext... | I think it would be simpler and safer if we pass the whole `episode` dict to this method and deal with it inside
```suggestion
def _extract_extended_description(self, episode_id, episode):
service, area = traverse_obj(episode, ('aa_vinfo2', {str}, {lambda x: (x or '').partition(',')}))
aa_vinfo3... | 'release_timestamp': 1481126700,
'upload_date': '20211101',
},
'expected_warnings': ['Unable to download JSON metadata', 'Failed to get extended description'],
}, {
# news
'url': 'https://www.nhk.or.jp/radio/player/ondemand.html?p=F261_01_3855109',
'sk... | @@ -539,9 +539,31 @@ class NhkRadiruIE(InfoExtractor):
},
}]
+ _api_config = None
+
+ def _extract_extended_description(self, episode_id, aa_vinfo2, aa_vinfo3):
+ service, area = aa_vinfo2.split(",") | yt_dlp/extractor/nhk.py | 26 | Python | 0.857 | refactor | 556 | 51 | 51 | false | [ie/NhkRadiru] Extract extended description | 9,162 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | garret1317 |
}
}, {
# news
'url': 'https://www.nhk.or.jp/radio/player/ondemand.html?p=F261_01_3855109',
'skip': 'Expires on 2023-04-17',
'info_dict': {
'id': 'F261_01_3855109',
'ext': 'm4a',
'channel': 'NHKラジオ第1',
'uploader': 'NHKラジオ第1',
... | checking truthiness of an etree element is no longer supported in py3.12 so we have to do this bit of cringe
```suggestion
if not isinstance(self._api_config, xml.etree.ElementTree.Element):
```
and then above
```py
import xml.etree.ElementTree
``` | },
'expected_warnings': ['Unable to download JSON metadata', 'Failed to get extended description'],
}, {
# news
'url': 'https://www.nhk.or.jp/radio/player/ondemand.html?p=F261_01_3855109',
'skip': 'Expires on 2023-04-17',
'info_dict': {
'id': 'F261_01_3855... | @@ -539,9 +539,31 @@ class NhkRadiruIE(InfoExtractor):
},
}]
+ _api_config = None
+
+ def _extract_extended_description(self, episode_id, aa_vinfo2, aa_vinfo3):
+ service, area = aa_vinfo2.split(",")
+
+ if not self._api_config: | yt_dlp/extractor/nhk.py | 26 | Python | 0.786 | suggestion | 271 | 51 | 51 | false | [ie/NhkRadiru] Extract extended description | 9,162 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | garret1317 |
'id': 'F261_01_3855109',
'ext': 'm4a',
'channel': 'NHKラジオ第1',
'uploader': 'NHKラジオ第1',
'timestamp': 1681635900,
'release_date': '20230416',
'series': 'NHKラジオニュース',
'title': '午後6時のNHKニュース',
'thumbnail': 'https://ww... | make non-fatal. feel free to try and find better formatting for the `detail_url` lines
```suggestion
detail_url = try_call(
lambda: f'https:{self._api_config.find(".//url_program_detail").text}'.format(
service=service, area=area, dateid=aa_vinfo3))
if not detail_url:
... | 'info_dict': {
'id': 'F261_01_3855109',
'ext': 'm4a',
'channel': 'NHKラジオ第1',
'uploader': 'NHKラジオ第1',
'timestamp': 1681635900,
'release_date': '20230416',
'series': 'NHKラジオニュース',
'title': '午後6時のNHKニュース',
'... | @@ -539,9 +539,31 @@ class NhkRadiruIE(InfoExtractor):
},
}]
+ _api_config = None
+
+ def _extract_extended_description(self, episode_id, aa_vinfo2, aa_vinfo3):
+ service, area = aa_vinfo2.split(",")
+
+ if not self._api_config:
+ self._api_config = self._download_xml('htt... | yt_dlp/extractor/nhk.py | 26 | Python | 0.857 | suggestion | 453 | 51 | 51 | false | [ie/NhkRadiru] Extract extended description | 9,162 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | garret1317 |
_api_config = None
def _extract_extended_description(self, episode_id, aa_vinfo2, aa_vinfo3):
service, area = aa_vinfo2.split(",")
if not self._api_config:
self._api_config = self._download_xml('https://www.nhk.or.jp/radio/config/config_web.xml',
... | single quotes and use traversal with `{str}` imo | }]
_API_URL_TMPL = None
def _extract_extended_description(self, episode_id, episode):
service, _, area = traverse_obj(episode, ('aa_vinfo2', {str}, {lambda x: (x or '').partition(',')}))
aa_vinfo3 = traverse_obj(episode, ('aa_vinfo3', {str}))
detail_url = try_call(
lamb... | @@ -539,9 +539,31 @@ class NhkRadiruIE(InfoExtractor):
},
}]
+ _api_config = None
+
+ def _extract_extended_description(self, episode_id, aa_vinfo2, aa_vinfo3):
+ service, area = aa_vinfo2.split(",")
+
+ if not self._api_config:
+ self._api_config = self._download_xml('htt... | yt_dlp/extractor/nhk.py | 26 | Python | 0.286 | suggestion | 48 | 51 | 51 | false | [ie/NhkRadiru] Extract extended description | 9,162 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | garret1317 |
'uploader': 'NHK-FM',
'channel': 'NHK-FM',
'thumbnail': 'https://www.nhk.or.jp/prog/img/449/g449.jpg',
'release_date': '20240217',
'description': 'md5:a456ee8e5e59e6dd2a7d32e62386e811',
'timestamp': 1708185600,
'release_timestamp': 1708... | I've pushed some changes, but just fyi in the future you can use `expected_warnings` to allow the test to pass | 'channel': 'NHK-FM',
'thumbnail': 'https://www.nhk.or.jp/prog/img/449/g449.jpg',
'release_date': '20240217',
'description': 'md5:a456ee8e5e59e6dd2a7d32e62386e811',
'timestamp': 1708185600,
'release_timestamp': 1708178400,
'upload_date':... | @@ -505,6 +507,7 @@ class NhkRadiruIE(InfoExtractor):
}, {
# one with letters in the id
'url': 'https://www.nhk.or.jp/radio/player/ondemand.html?p=F300_06_3738470',
+ 'skip': 'Test fails due to extended description request failing - falls back to normal in real usage', | yt_dlp/extractor/nhk.py | 26 | Python | 0.571 | suggestion | 110 | 51 | 51 | false | [ie/NhkRadiru] Extract extended description | 9,162 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | garret1317 |
}
thumbnails = [{
'url': thumb.get('url'),
'width': thumb.get('width') or None,
'height': thumb.get('height') or None,
} for thumb in traverse_obj(metadata, ('snippet', 'thumbnails', ...))]
self._remove_duplicate_formats(thumbnails)
return {
... | Couple things: We could mutate the original dict, since we control callees.
Also typo fix and static method
```suggestion
@staticmethod
def _sub_to_dict(self, subtitle_list):
subtitles = {}
for sub in subtitle_list:
subtitles.setdefault(sub.pop('tag', None) or 'unknown', []).a... | }] for lang, data in traverse_obj(metadata, 'captions', default={}).items()
}
thumbnails = [{
'url': thumb.get('url'),
'width': thumb.get('width') or None,
'height': thumb.get('height') or None,
} for thumb in traverse_obj(metadata, ('snippet', 't... | @@ -63,3 +71,217 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ def _sub_to_dict(self, subtitile_list):
+ subtitles = {}
+ for sub in subtitile_list:
+ subtitles.setdef... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | question | 524 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
'url': 'https://learn.microsoft.com/en-us/shows/bash-for-beginners/what-is-the-difference-between-a-terminal-and-a-shell-2-of-20-bash-for-beginners/',
'info_dict': {
'id': 'd44e1a03-a0e5-45c2-9496-5c9fa08dc94c',
'ext': 'ismv',
'title': 'What is the Difference Between ... | ```suggestion
playlist_info = self._download_json(url_base, video_id, f'Downloading entries {skip}', query={
'locale': 'en-us',
'$skip': skip,
})
```
This will update the query. I think its better to have the `en-us` here, especially since the url-result cre... | 'id': 'build-2022',
'title': 'Microsoft Build 2022 - Events',
'description': 'md5:c16b43848027df837b22c6fbac7648d3',
},
'playlist_count': 201,
}]
def _entries(self, url_base, video_id):
skip = 0
while True:
playlist_info = self._do... | @@ -63,3 +71,217 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ def _sub_to_dict(self, subtitile_list):
+ subtitles = {}
+ for sub in subtitile_list:
+ subtitles.setdef... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | suggestion | 372 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
},
'playlist_count': 20,
}]
def _entries(self, url_base, video_id):
skip = 0
while True:
playlist_info = self._download_json(f'{url_base}&$skip={skip}', video_id, f'Downloading entries {skip}')
items = traverse_obj(playlist_info, (
'result... | We cuold use early exit here:
```py
if not slug:
url_base = ...
return self._playlist_result(...)
if video_type == 'events':
return self.url_result(...)
entry_id = ...
...
``` | if skip >= playlist_info.get('count', 0) or not url_paths:
break
def _real_extract(self, url):
playlist_id, playlist_type = self._match_valid_url(url).group('id', 'type')
webpage = self._download_webpage(url, playlist_id)
metainfo = {
'title': self._... | @@ -63,3 +71,217 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ def _sub_to_dict(self, subtitile_list):
+ subtitles = {}
+ for sub in subtitile_list:
+ subtitles.setdef... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 1 | suggestion | 200 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
if slug:
if video_type == 'events':
return self.url_result(
self._search_regex(r'<meta\s+name="externalVideoUrl"\s+content="([^"]+)"', webpage, 'videoUrl'), url_transparent=True, **metainfo, **{
'timestamp': parse_iso8601(self._search_regex... | ```suggestion
url_base = f'https://learn.microsoft.com/api/contentbrowser/search/{video_type}/{series}/{"sessions" if video_type == "events" else "episodes"}'
```
refer to the other comment | 'description': 'md5:7bbbfb593d21c2cf2babc3715ade6b88',
'timestamp': 1676339547,
'upload_date': '20230214',
'thumbnail': r're:https://learn\.microsoft\.com/video/media/.*\.png',
'subtitles': 'count:14',
},
}]
def _real_extract(self, url):
... | @@ -63,3 +71,217 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ def _sub_to_dict(self, subtitile_list):
+ subtitles = {}
+ for sub in subtitile_list:
+ subtitles.setdef... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.929 | suggestion | 204 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
'url': 'https://medius.microsoft.com/Embed/video-nc/9640d86c-f513-4889-959e-5dace86e7d2b',
'info_dict': {
'id': '9640d86c-f513-4889-959e-5dace86e7d2b',
'ext': 'ismv',
'title': 'Rapidly code, test and ship from secure cloud developer environments',
'descrip... | `_search_json` appends the `\s*` automatically. I think `default=None` makes more sense.
```suggestion
self._search_json(r'const\s+captionsConfiguration\s*=', webpage, 'captions', video_id, default=None),
``` | 'info_dict': {
'id': '9640d86c-f513-4889-959e-5dace86e7d2b',
'ext': 'ismv',
'title': 'Rapidly code, test and ship from secure cloud developer environments',
'description': 'md5:33c8e4facadc438613476eea24165f71',
'thumbnail': r're:https://mediusimg\.eve... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.786 | suggestion | 223 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'subtitles': 'count:30',
},
'params': {'listsubtitles': True},
}, {
'url': 'https://medius.microsoft.com/Embed/video-nc/81215af5-c813-4dcd-aede-94f4e1a7daa3',
'info_dict': {
'id': '81215af5-c813-4dcd-aede-94f4e1a7daa3',
'ext': 'ismv',
'... | Does it make sense to include both, or can this lead to duplicates?
```suggestion
})) + traverse_obj(
``` | },
}, {
'url': 'https://medius.microsoft.com/Embed/video-nc/81215af5-c813-4dcd-aede-94f4e1a7daa3',
'info_dict': {
'id': '81215af5-c813-4dcd-aede-94f4e1a7daa3',
'ext': 'ismv',
'title': 'Microsoft Build opening',
'description': 'md5:4345509614107... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.714 | refactor | 120 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
}
thumbnails = [{
'url': thumb.get('url'),
'width': thumb.get('width') or None,
'height': thumb.get('height') or None,
} for thumb in traverse_obj(metadata, ('snippet', 'thumbnails', ...))]
self._remove_duplicate_formats(thumbnails)
return {
... | I know the yt-dlp codestyle™ prefers `or` over setting the default value in `get`, but I think here for `pop` it's fine
```suggestion
subtitles.setdefault(sub.pop('tag', 'unknown'), []).append(sub)
``` | }] for lang, data in traverse_obj(metadata, 'captions', default={}).items()
}
thumbnails = [{
'url': thumb.get('url'),
'width': thumb.get('width') or None,
'height': thumb.get('height') or None,
} for thumb in traverse_obj(metadata, ('snippet', 't... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | suggestion | 216 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'formats': formats,
'subtitles': subtitles,
'thumbnails': thumbnails,
}
class MicrosoftMediusBaseIE(InfoExtractor):
@staticmethod
def _sub_to_dict(subtitle_list):
subtitles = {}
for sub in subtitle_list:
subtitles.setdefault(sub.pop('tag'... | I think we should not match so broadly. These are the three URL formats I was able to find:
```
https://medius.microsoft.com/Embed/Video?id=0dc69bda-079b-4070-a7db-a8da1a06a9c7
https://medius.microsoft.com/Embed/video-nc/fe823a91-959c-465b-96d4-8f4db624f72c
https://medius.microsoft.com/Embed/VideoDetails/78493569-9... | 'age_limit': int_or_none(traverse_obj(metadata, ('snippet', 'minimumAge'))) or 0,
'formats': formats,
'subtitles': subtitles,
'thumbnails': thumbnails,
}
class MicrosoftMediusBaseIE(InfoExtractor):
@staticmethod
def _sub_to_dict(subtitle_list):
s... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | style | 518 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
}))
captions = captions or traverse_obj(
re.findall(r'var\s+file\s+=\s+\{[^}]+\'(https://[^\']+\.vtt\?[^\']+)', webpage),
(lambda _, v: url_or_none(v), {lambda x: {'url': x, 'tag': x.split('.vtt?')[0].split('_')[-1]}}))
return self._sub_to_dict(captions)
def _r... | The playlist code seems relatively separate from the individual video code. Could we split this in to two extractors? | 'only_matching': True,
}, {
'url': 'https://medius.microsoft.com/Embed/video-nc/fe823a91-959c-465b-96d4-8f4db624f72c',
'only_matching': True,
}]
def _extract_subtitle(self, webpage, video_id):
captions = traverse_obj(
self._search_json(r'const\s+captionsConfigura... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.429 | refactor | 117 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
_TESTS = [{
'url': 'https://build.microsoft.com/en-US/sessions/b49feb31-afcd-4217-a538-d3ca1d171198?source=sessions',
'info_dict': {
'id': 'aee55fb5-fcf9-4b38-b764-a3527cb57554',
'ext': 'ismv',
'title': 'Microsoft Build opening keynote',
'description'... | I would again say these should probably be split as there is almost no shared code.
They also don't need to be subclassed from `MicrosoftMediusBaseIE`. | 'ext': 'ismv',
'title': 'Rapidly code, test and ship from secure cloud developer environments - Events',
'description': 'md5:f26c1a85d41c1cffd27a0279254a25c3',
'timestamp': 1653408600,
'upload_date': '20220524',
'thumbnail': r're:https://mediusimg\... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.571 | suggestion | 152 | 38 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
]
_TESTS = [{
'url': 'https://build.microsoft.com/en-US/sessions/b49feb31-afcd-4217-a538-d3ca1d171198?source=sessions',
'info_dict': {
'id': 'aee55fb5-fcf9-4b38-b764-a3527cb57554',
'ext': 'ismv',
'title': 'Microsoft Build opening keynote',
'descri... | Is this always a medius URL? If yes, set `ie=MicrosoftMediusIE`. | 'id': '9640d86c-f513-4889-959e-5dace86e7d2b',
'ext': 'ismv',
'title': 'Rapidly code, test and ship from secure cloud developer environments - Events',
'description': 'md5:f26c1a85d41c1cffd27a0279254a25c3',
'timestamp': 1653408600,
'upload_date': '2... | @@ -63,3 +71,221 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.357 | question | 64 | 39 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
return subtitles
def _extract_ism(self, ism_url, video_id):
formats = self._extract_ism_formats(ism_url, video_id)
for fmt in formats:
if fmt.get('language') == 'eng' or 'English' in fmt.get('format_id', ''):
fmt['language_preference'] = -1
else:
... | Not necessary:
```suggestion
``` | subtitles.setdefault(sub.pop('tag', 'und'), []).append(sub)
return subtitles
def _extract_ism(self, ism_url, video_id):
formats = self._extract_ism_formats(ism_url, video_id)
for fmt in formats:
if fmt['language'] != 'eng' and 'English' not in fmt['format_id']:
... | @@ -63,3 +71,258 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.429 | suggestion | 34 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
ism_url = self._search_regex(r'StreamUrl\s*=\s*"([^"]+manifest)"', webpage, 'ism url')
return {
'id': video_id,
'title': self._og_search_title(webpage),
'description': self._og_search_description(webpage),
'formats': self._extract_ism(ism_url, video_id),
... | Oh, I think I didn't explain myself very well. I meant splitting into one playlist and one none playlist extractor like so:
```suggestion
class MicrosoftLearnPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w\-]+/)?(?P<type>shows|events)/(?P<id>[\w\-]+)/?(?:[?#]|$)'
_TESTS = [{
... | 'subtitles': self._extract_subtitle(webpage, video_id),
}
class MicrosoftLearnPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w-]+/)?(?P<type>shows|events)/(?P<id>[\w-]+)/?(?:[?#]|$)'
_TESTS = [{
'url': 'https://learn.microsoft.com/en-us/shows/bash-for... | @@ -63,3 +71,258 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 1 | refactor | 2,153 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
metainfo = {
'title': self._og_search_title(webpage),
'description': self._og_search_description(webpage),
}
if not slug:
url_base = f'https://learn.microsoft.com/api/contentbrowser/search/shows/{series}/episodes'
return self.playlist_result(self... | ```suggestion
class MicrosoftLearnEpisodeIE(MicrosoftMediusBaseIE):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w\-]+/)?shows/[\w\-]+/(?P<id>[^?#/]+)'
_TESTS = [{
'url': 'https://learn.microsoft.com/en-us/shows/bash-for-beginners/what-is-the-difference-between-a-terminal-and-a-shell-2-of-20-b... | 'id': 'd44e1a03-a0e5-45c2-9496-5c9fa08dc94c',
'ext': 'ismv',
'title': 'What is the Difference Between a Terminal and a Shell? (Part 2 of 20)',
'description': 'md5:7bbbfb593d21c2cf2babc3715ade6b88',
'timestamp': 1676339547,
'upload_date': '20230214'... | @@ -63,3 +71,258 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | refactor | 1,989 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'id': 'build-2022',
'title': 'Microsoft Build 2022 - Events',
'description': 'md5:c16b43848027df837b22c6fbac7648d3',
},
'playlist_count': 201,
}]
def _real_extract(self, url):
series, slug = self._match_valid_url(url).groups()
video_id = slug ... | ```suggestion
class MicrosoftLearnSessionIE(InfoExtractor):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w\-]+/)?events/[\w\-]+/(?P<id>[^?#/]+)'
_TESTS = [{
'url': 'https://learn.microsoft.com/en-us/events/build-2022/ts01-rapidly-code-test-ship-from-secure-cloud-developer-environments',
... | 'timestamp': 1653408600,
'upload_date': '20220524',
'thumbnail': r're:https://mediusimg\.event\.microsoft\.com/video-\d+/thumbnail\.jpg.*',
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_... | @@ -63,3 +71,258 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | refactor | 1,461 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'timestamp': 1676339547,
'upload_date': '20230214',
'thumbnail': r're:https://learn\.microsoft\.com/video/media/.*\.png',
'subtitles': 'count:14',
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_... | ```suggestion
'thumbnails': ('publicVideo', 'thumbnailOtherSizes', ..., {url_or_none}, {lambda x: x and {'url': x}}),
``` | 'subtitles': 'count:14',
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
entry_id = self._html_search_meta('entryId', webpage, 'entryId', fatal=True)
video_info = self._download_json(
... | @@ -63,3 +71,254 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.714 | suggestion | 139 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
url_base = f'https://learn.microsoft.com/api/contentbrowser/search/{playlist_type}/{playlist_id}/{sub_type}'
return self.playlist_result(self._entries(url_base, playlist_id), playlist_id, **metainfo)
class MicrosoftLearnEpisodeIE(MicrosoftMediusBaseIE):
_VALID_URL = r'https?://learn\.microsoft\.c... | ```suggestion
entry_id = self._html_search_meta('entryId', webpage, 'entryId', fatal=True)
``` |
class MicrosoftLearnEpisodeIE(MicrosoftMediusBaseIE):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w-]+/)?shows/[\w-]+/(?P<id>[^?#/]+)'
_TESTS = [{
'url': 'https://learn.microsoft.com/en-us/shows/bash-for-beginners/what-is-the-difference-between-a-terminal-and-a-shell-2-of-20-bash-for-beginners/... | @@ -63,3 +71,254 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.714 | suggestion | 104 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
class MicrosoftLearnSessionIE(InfoExtractor):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w\-]+/)?events/[\w\-]+/(?P<id>[^?#/]+)'
_TESTS = [{
'url': 'https://learn.microsoft.com/en-us/events/build-2022/ts01-rapidly-code-test-ship-from-secure-cloud-developer-environments',
'info_dict': {... | ```suggestion
'timestamp': parse_iso8601(self._html_search_meta('startDate', webpage, 'startDate')),
``` | class MicrosoftLearnSessionIE(InfoExtractor):
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w-]+/)?events/[\w-]+/(?P<id>[^?#/]+)'
_TESTS = [{
'url': 'https://learn.microsoft.com/en-us/events/build-2022/ts01-rapidly-code-test-ship-from-secure-cloud-developer-environments',
'info_dict': {
... | @@ -63,3 +71,254 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.714 | suggestion | 118 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
}
thumbnails = [{
'url': thumb.get('url'),
'width': thumb.get('width') or None,
'height': thumb.get('height') or None,
} for thumb in traverse_obj(metadata, ('snippet', 'thumbnails', ...))]
self._remove_duplicate_formats(thumbnails)
return {
... | ```suggestion
subtitles.setdefault(sub.pop('tag', 'und'), []).append(sub)
``` | }] for lang, data in traverse_obj(metadata, 'captions', default={}).items()
}
thumbnails = [{
'url': thumb.get('url'),
'width': thumb.get('width') or None,
'height': thumb.get('height') or None,
} for thumb in traverse_obj(metadata, ('snippet', 't... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.571 | suggestion | 91 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
return {
'id': video_id,
'title': traverse_obj(metadata, ('snippet', 'title')),
'timestamp': unified_timestamp(traverse_obj(metadata, ('snippet', 'activeStartDate'))),
'age_limit': int_or_none(traverse_obj(metadata, ('snippet', 'minimumAge'))) or 0,
'f... | `-1` is the default `language_preference` value, and the format dicts returned by `_extract_ism_formats` will always have `language` and `format_id` string values, so we could just do this:
```suggestion
if fmt['language'] != 'eng' and 'English' not in fmt['format_id']:
fmt['language_pref... |
return {
'id': video_id,
'title': traverse_obj(metadata, ('snippet', 'title')),
'timestamp': unified_timestamp(traverse_obj(metadata, ('snippet', 'activeStartDate'))),
'age_limit': int_or_none(traverse_obj(metadata, ('snippet', 'minimumAge'))) or 0,
'... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | refactor | 339 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'formats': formats,
'subtitles': subtitles,
'thumbnails': thumbnails,
}
class MicrosoftMediusBaseIE(InfoExtractor):
@staticmethod
def _sub_to_dict(subtitle_list):
subtitles = {}
for sub in subtitle_list:
subtitles.setdefault(sub.pop('tag'... | ```suggestion
_VALID_URL = r'https?://medius\.microsoft\.com/Embed/(?:Video\?id=|video-nc/|VideoDetails/)(?P<id>[\da-f-]+)'
``` | 'age_limit': int_or_none(traverse_obj(metadata, ('snippet', 'minimumAge'))) or 0,
'formats': formats,
'subtitles': subtitles,
'thumbnails': thumbnails,
}
class MicrosoftMediusBaseIE(InfoExtractor):
@staticmethod
def _sub_to_dict(subtitle_list):
s... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.714 | suggestion | 133 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'thumbnail': r're:https://mediusimg\.event\.microsoft\.com/video-\d+/thumbnail\.jpg.*',
'subtitles': 'count:31',
},
}, {
'url': 'https://medius.microsoft.com/Embed/VideoDetails/78493569-9b3b-4a85-a409-ee76e789e25c',
'info_dict': {
'id': '78493569-9b3b-4a85... | instead of transforming with `url_or_none`, I would filter with it so that we don't return `'url': None`
```suggestion
('languageList', lambda _, v: url_or_none(v['src']), {
'url': 'src',
``` | 'subtitles': 'count:31',
},
}, {
'url': 'https://medius.microsoft.com/Embed/VideoDetails/78493569-9b3b-4a85-a409-ee76e789e25c',
'info_dict': {
'id': '78493569-9b3b-4a85-a409-ee76e789e25c',
'ext': 'ismv',
'title': ' Anomaly Detection & Root caus... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | suggestion | 223 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'info_dict': {
'id': '78493569-9b3b-4a85-a409-ee76e789e25c',
'ext': 'ismv',
'title': ' Anomaly Detection & Root cause at Edge',
'description': 'md5:f8f1ad93d7918649bfb97fa081b03b83',
'thumbnail': r're:https://mediusdownload.event.microsoft.com/asset.*\... | This is hard to read IMO.
The filtering is unnecessary for two reasons: 1. we could just do `..., {url_or_none}` instead, and 2. we can already be reasonably sure that it will be a valid url because of the pattern used with `re.findall`.
We could get by without traversal even:
```suggestion
})) o... | 'id': '78493569-9b3b-4a85-a409-ee76e789e25c',
'ext': 'ismv',
'title': ' Anomaly Detection & Root cause at Edge',
'description': 'md5:f8f1ad93d7918649bfb97fa081b03b83',
'thumbnail': r're:https://mediusdownload.event.microsoft.com/asset.*\.jpg.*',
's... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | suggestion | 511 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
}]
def _extract_subtitle(self, webpage, video_id):
captions = traverse_obj(
self._search_json(r'const\s+captionsConfiguration\s*=', webpage, 'captions', video_id, default=None),
('languageList', ..., {
'url': ('src', {url_or_none}),
'tag': ('srcla... | ```suggestion
return {
'id': video_id,
'title': self._og_search_title(webpage),
'description': self._og_search_description(webpage),
'formats': self._extract_ism(
self._search_regex(r'StreamUrl\s*=\s*"([^"]+manifest)"', webpage, 'ism url'), v... |
def _extract_subtitle(self, webpage, video_id):
captions = traverse_obj(
self._search_json(r'const\s+captionsConfiguration\s*=', webpage, 'captions', video_id, default=None),
('languageList', lambda _, v: url_or_none(v['src']), {
'url': 'src',
'tag': ... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | refactor | 334 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'tag': ('srclang', {str}),
'name': ('kind', {str}),
})) or traverse_obj(
re.findall(r'var\s+file\s+=\s+\{[^}]+\'(https://[^\']+\.vtt\?[^\']+)', webpage),
(lambda _, v: url_or_none(v), {lambda x: {'url': x, 'tag': x.split('.vtt?')[0].split('_')[-1]}}))
... | ```suggestion
_VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w-]+/)?(?P<type>shows|events)/(?P<id>[\w-]+)/?(?:[?#]|$)'
``` | 'name': ('kind', {str}),
})) or [{'url': url, 'tag': url_basename(url).split('.vtt')[0].split('_')[-1]}
for url in re.findall(r'var\s+file\s+=\s+\{[^}]+\'(https://[^\']+\.vtt\?[^\']+)', webpage)]
return self._sub_to_dict(captions)
def _real_extract(self, url... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | suggestion | 132 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
'title': 'Bash for Beginners',
'description': 'md5:16a91c07222117d1e00912f0dbc02c2c',
},
'playlist_count': 20,
}, {
'url': 'https://learn.microsoft.com/en-us/events/build-2022',
'info_dict': {
'id': 'build-2022',
'title': 'Microsoft Bui... | We can't construct the url results like this. In traversal, the transformation is always called, so the lambda f-string could produce URLs like `'https://learn.microsoft.com/en-usNone'` if one of the dicts in the list doesn't have an `url` field.
```suggestion
url_paths = traverse_obj(playlist_info, ('r... | 'playlist_count': 20,
}, {
'url': 'https://learn.microsoft.com/en-us/events/build-2022',
'info_dict': {
'id': 'build-2022',
'title': 'Microsoft Build 2022 - Events',
'description': 'md5:c16b43848027df837b22c6fbac7648d3',
},
'playlist_count'... | @@ -63,3 +71,253 @@ def _real_extract(self, url):
'subtitles': subtitles,
'thumbnails': thumbnails,
}
+
+
+class MicrosoftMediusBaseIE(InfoExtractor):
+ @staticmethod
+ def _sub_to_dict(subtitle_list):
+ subtitles = {}
+ for sub in subtitle_list:
+ subti... | yt_dlp/extractor/microsoftembed.py | 26 | Python | 0.857 | suggestion | 588 | 51 | 51 | false | [ie/microsoftembed] Add extractors for dev materials | 9,177 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.