From 3c14e9191f3035b9a729d1d87bc0381f42de57cf Mon Sep 17 00:00:00 2001 From: voidptr_t Date: Sat, 11 Jan 2025 17:39:31 +0300 Subject: [PATCH 001/121] [ie/PlVideo] Add extractor (#10657) Closes #10311 Authored by: Sanceilaks, seproDev Co-authored-by: sepro --- yt_dlp/extractor/_extractors.py | 1 + yt_dlp/extractor/plvideo.py | 130 ++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 yt_dlp/extractor/plvideo.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index 967010826e..bbd6d21bd7 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -1551,6 +1551,7 @@ from .pluralsight import ( PluralsightIE, ) from .plutotv import PlutoTVIE +from .plvideo import PlVideoIE from .podbayfm import ( PodbayFMChannelIE, PodbayFMIE, diff --git a/yt_dlp/extractor/plvideo.py b/yt_dlp/extractor/plvideo.py new file mode 100644 index 0000000000..9351af10ae --- /dev/null +++ b/yt_dlp/extractor/plvideo.py @@ -0,0 +1,130 @@ +from .common import InfoExtractor +from ..utils import ( + float_or_none, + int_or_none, + parse_iso8601, + parse_resolution, + url_or_none, +) +from ..utils.traversal import traverse_obj + + +class PlVideoIE(InfoExtractor): + IE_DESC = 'Платформа' + _VALID_URL = r'https?://(?:www\.)?plvideo\.ru/(?:watch\?(?:[^#]+&)?v=|shorts/)(?P[\w-]+)' + _TESTS = [{ + 'url': 'https://plvideo.ru/watch?v=Y5JzUzkcQTMK', + 'md5': 'fe8e18aca892b3b31f3bf492169f8a26', + 'info_dict': { + 'id': 'Y5JzUzkcQTMK', + 'ext': 'mp4', + 'thumbnail': 'https://img.plvideo.ru/images/fp-2024-images/v/cover/37/dd/37dd00a4c96c77436ab737e85947abd7/original663a4a3bb713e5.33151959.jpg', + 'title': 'Presidente de Cuba llega a Moscú en una visita de trabajo', + 'channel': 'RT en Español', + 'channel_id': 'ZH4EKqunVDvo', + 'media_type': 'video', + 'comment_count': int, + 'tags': ['rusia', 'cuba', 'russia', 'miguel díaz-canel'], + 'description': 'md5:a1a395d900d77a86542a91ee0826c115', + 'released_timestamp': 1715096124, + 'channel_is_verified': True, + 'like_count': int, + 'timestamp': 1715095911, + 'duration': 44320, + 'view_count': int, + 'dislike_count': int, + 'upload_date': '20240507', + 'modified_date': '20240701', + 'channel_follower_count': int, + 'modified_timestamp': 1719824073, + }, + }, { + 'url': 'https://plvideo.ru/shorts/S3Uo9c-VLwFX', + 'md5': '7d8fa2279406c69d2fd2a6fc548a9805', + 'info_dict': { + 'id': 'S3Uo9c-VLwFX', + 'ext': 'mp4', + 'channel': 'Romaatom', + 'tags': 'count:22', + 'dislike_count': int, + 'upload_date': '20241130', + 'description': 'md5:452e6de219bf2f32bb95806c51c3b364', + 'duration': 58433, + 'modified_date': '20241130', + 'thumbnail': 'https://img.plvideo.ru/images/fp-2024-11-cover/S3Uo9c-VLwFX/f9318999-a941-482b-b700-2102a7049366.jpg', + 'media_type': 'shorts', + 'like_count': int, + 'modified_timestamp': 1732961458, + 'channel_is_verified': True, + 'channel_id': 'erJyyTIbmUd1', + 'timestamp': 1732961355, + 'comment_count': int, + 'title': 'Белоусов отменил приказы о кадровом резерве на гражданской службе', + 'channel_follower_count': int, + 'view_count': int, + 'released_timestamp': 1732961458, + }, + }] + + def _real_extract(self, url): + video_id = self._match_id(url) + + video_data = self._download_json( + f'https://api.g1.plvideo.ru/v1/videos/{video_id}?Aud=18', video_id) + + is_live = False + formats = [] + subtitles = {} + automatic_captions = {} + for quality, data in traverse_obj(video_data, ('item', 'profiles', {dict.items}, lambda _, v: url_or_none(v[1]['hls']))): + formats.append({ + 'format_id': quality, + 'ext': 'mp4', + 'protocol': 'm3u8_native', + **traverse_obj(data, { + 'url': 'hls', + 'fps': ('fps', {float_or_none}), + 'aspect_ratio': ('aspectRatio', {float_or_none}), + }), + **parse_resolution(quality), + }) + if livestream_url := traverse_obj(video_data, ('item', 'livestream', 'url', {url_or_none})): + is_live = True + formats.extend(self._extract_m3u8_formats(livestream_url, video_id, 'mp4', live=True)) + for lang, url in traverse_obj(video_data, ('item', 'subtitles', {dict.items}, lambda _, v: url_or_none(v[1]))): + if lang.endswith('-auto'): + automatic_captions.setdefault(lang[:-5], []).append({ + 'url': url, + }) + else: + subtitles.setdefault(lang, []).append({ + 'url': url, + }) + + return { + 'id': video_id, + 'formats': formats, + 'subtitles': subtitles, + 'automatic_captions': automatic_captions, + 'is_live': is_live, + **traverse_obj(video_data, ('item', { + 'id': ('id', {str}), + 'title': ('title', {str}), + 'description': ('description', {str}), + 'thumbnail': ('cover', 'paths', 'original', 'src', {url_or_none}), + 'duration': ('uploadFile', 'videoDuration', {int_or_none}), + 'channel': ('channel', 'name', {str}), + 'channel_id': ('channel', 'id', {str}), + 'channel_follower_count': ('channel', 'stats', 'subscribers', {int_or_none}), + 'channel_is_verified': ('channel', 'verified', {bool}), + 'tags': ('tags', ..., {str}), + 'timestamp': ('createdAt', {parse_iso8601}), + 'released_timestamp': ('publishedAt', {parse_iso8601}), + 'modified_timestamp': ('updatedAt', {parse_iso8601}), + 'view_count': ('stats', 'viewTotalCount', {int_or_none}), + 'like_count': ('stats', 'likeCount', {int_or_none}), + 'dislike_count': ('stats', 'dislikeCount', {int_or_none}), + 'comment_count': ('stats', 'commentCount', {int_or_none}), + 'media_type': ('type', {str}), + })), + } From 763ed06ee69f13949397897bd42ff2ec3dc3d384 Mon Sep 17 00:00:00 2001 From: HobbyistDev <105957301+HobbyistDev@users.noreply.github.com> Date: Sun, 12 Jan 2025 01:25:18 +0800 Subject: [PATCH 002/121] [ie/XiaoHongShu] Extend `_VALID_URL` (#11806) Closes #11797 Authored by: HobbyistDev --- yt_dlp/extractor/xiaohongshu.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/xiaohongshu.py b/yt_dlp/extractor/xiaohongshu.py index 1280ca6a9c..46543b823e 100644 --- a/yt_dlp/extractor/xiaohongshu.py +++ b/yt_dlp/extractor/xiaohongshu.py @@ -10,7 +10,7 @@ from ..utils.traversal import traverse_obj class XiaoHongShuIE(InfoExtractor): - _VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P[\da-f]+)' + _VALID_URL = r'https?://www\.xiaohongshu\.com/(?:explore|discovery/item)/(?P[\da-f]+)' IE_DESC = '小红书' _TESTS = [{ 'url': 'https://www.xiaohongshu.com/explore/6411cf99000000001300b6d9', @@ -25,6 +25,18 @@ class XiaoHongShuIE(InfoExtractor): 'duration': 101.726, 'thumbnail': r're:https?://sns-webpic-qc\.xhscdn\.com/\d+/[a-z0-9]+/[\w]+', }, + }, { + 'url': 'https://www.xiaohongshu.com/discovery/item/674051740000000007027a15?xsec_token=CBgeL8Dxd1ZWBhwqRd568gAZ_iwG-9JIf9tnApNmteU2E=', + 'info_dict': { + 'id': '674051740000000007027a15', + 'ext': 'mp4', + 'title': '相互喜欢就可以了', + 'uploader_id': '63439913000000001901f49a', + 'duration': 28.073, + 'description': '#广州[话题]# #深圳[话题]# #香港[话题]# #街头采访[话题]# #是你喜欢的类型[话题]#', + 'thumbnail': r're:https?://sns-webpic-qc\.xhscdn\.com/\d+/[\da-f]+/[^/]+', + 'tags': ['广州', '深圳', '香港', '街头采访', '是你喜欢的类型'], + }, }] def _real_extract(self, url): From 1f4e1e85a27c5b43e34d7706cfd88ffce1b56a4a Mon Sep 17 00:00:00 2001 From: Paul Storkman <111140294+Strkmn@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:51:16 +0100 Subject: [PATCH 003/121] [core] Validate retries values are non-negative (#11927) Closes #11926 Authored by: Strkmn --- yt_dlp/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 20111175b1..c76fe27483 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -261,9 +261,11 @@ def validate_options(opts): elif value in ('inf', 'infinite'): return float('inf') try: - return int(value) + int_value = int(value) except (TypeError, ValueError): validate(False, f'{name} retry count', value) + validate_positive(f'{name} retry count', int_value) + return int_value opts.retries = parse_retries('download', opts.retries) opts.fragment_retries = parse_retries('fragment', opts.fragment_retries) From 8346b549150003df988538e54c9d8bc4de568979 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Sat, 11 Jan 2025 13:05:23 -0600 Subject: [PATCH 004/121] Fix filename sanitization with `--no-windows-filenames` (#11988) Fix bug in 6fc85f617a5850307fd5b258477070e6ee177796 Closes #11987 Authored by: bashonly --- yt_dlp/YoutubeDL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 764baf3a00..178c5b9515 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1323,7 +1323,7 @@ class YoutubeDL: elif (sys.platform != 'win32' and not self.params.get('restrictfilenames') and self.params.get('windowsfilenames') is False): def sanitize(key, value): - return value.replace('/', '\u29F8').replace('\0', '') + return str(value).replace('/', '\u29F8').replace('\0', '') else: def sanitize(key, value): return filename_sanitizer(key, value, restricted=self.params.get('restrictfilenames')) From 712d2abb32f59b2d246be2901255f84f1a4c30b3 Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Sun, 12 Jan 2025 15:01:13 +1300 Subject: [PATCH 005/121] [ie/youtube] Use `tv` instead of `mweb` client by default (#12059) Authored by: coletdjnz --- yt_dlp/extractor/youtube.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 1e83e41b8f..f414d9d030 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -256,11 +256,12 @@ INNERTUBE_CLIENTS = { 'client': { 'clientName': 'MWEB', 'clientVersion': '2.20241202.07.00', - # mweb does not require PO Token with this UA + # mweb previously did not require PO Token with this UA 'userAgent': 'Mozilla/5.0 (iPad; CPU OS 16_7_10 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1,gzip(gfe)', }, }, 'INNERTUBE_CONTEXT_CLIENT_NAME': 2, + 'REQUIRE_PO_TOKEN': True, 'SUPPORTS_COOKIES': True, }, 'tv': { @@ -1356,8 +1357,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor): '401': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'av01.0.12M.08'}, } _SUBTITLE_FORMATS = ('json3', 'srv1', 'srv2', 'srv3', 'ttml', 'vtt') - _DEFAULT_CLIENTS = ('ios', 'mweb') - _DEFAULT_AUTHED_CLIENTS = ('web_creator', 'mweb') + _DEFAULT_CLIENTS = ('ios', 'tv') + _DEFAULT_AUTHED_CLIENTS = ('web_creator', 'tv') _GEO_BYPASS = False From 75079f4e3f7dce49b61ef01da7adcd9876a0ca3b Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Sun, 12 Jan 2025 15:02:57 +1300 Subject: [PATCH 006/121] [ie/youtube] Refactor cookie auth (#11989) Authored by: coletdjnz --- yt_dlp/extractor/youtube.py | 176 +++++++++++++++++++++++++----------- 1 file changed, 123 insertions(+), 53 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index f414d9d030..e16ec43edd 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -32,7 +32,6 @@ from ..utils import ( classproperty, clean_html, datetime_from_str, - dict_get, filesize_from_tbr, filter_dict, float_or_none, @@ -568,9 +567,15 @@ class YoutubeBaseInfoExtractor(InfoExtractor): pref.update({'hl': self._preferred_lang or 'en', 'tz': 'UTC'}) self._set_cookie('.youtube.com', name='PREF', value=urllib.parse.urlencode(pref)) + def _initialize_cookie_auth(self): + yt_sapisid, yt_1psapisid, yt_3psapisid = self._get_sid_cookies() + if yt_sapisid or yt_1psapisid or yt_3psapisid: + self.write_debug('Found YouTube account cookies') + def _real_initialize(self): self._initialize_pref() self._initialize_consent() + self._initialize_cookie_auth() self._check_login_required() def _perform_login(self, username, password): @@ -628,32 +633,63 @@ class YoutubeBaseInfoExtractor(InfoExtractor): client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0}) return context - _SAPISID = None - - def _generate_sapisidhash_header(self, origin='https://www.youtube.com'): - time_now = round(time.time()) - if self._SAPISID is None: - yt_cookies = self._get_cookies('https://www.youtube.com') - # Sometimes SAPISID cookie isn't present but __Secure-3PAPISID is. - # See: https://github.com/yt-dlp/yt-dlp/issues/393 - sapisid_cookie = dict_get( - yt_cookies, ('__Secure-3PAPISID', 'SAPISID')) - if sapisid_cookie and sapisid_cookie.value: - self._SAPISID = sapisid_cookie.value - self.write_debug('Extracted SAPISID cookie') - # SAPISID cookie is required if not already present - if not yt_cookies.get('SAPISID'): - self.write_debug('Copying __Secure-3PAPISID cookie to SAPISID cookie') - self._set_cookie( - '.youtube.com', 'SAPISID', self._SAPISID, secure=True, expire_time=time_now + 3600) - else: - self._SAPISID = False - if not self._SAPISID: + @staticmethod + def _make_sid_authorization(scheme, sid, origin, additional_parts): + timestamp = str(round(time.time())) + + hash_parts = [] + if additional_parts: + hash_parts.append(':'.join(additional_parts.values())) + hash_parts.extend([timestamp, sid, origin]) + sidhash = hashlib.sha1(' '.join(hash_parts).encode()).hexdigest() + + parts = [timestamp, sidhash] + if additional_parts: + parts.append(''.join(additional_parts)) + + return f'{scheme} {"_".join(parts)}' + + def _get_sid_cookies(self): + """ + Get SAPISID, 1PSAPISID, 3PSAPISID cookie values + @returns sapisid, 1psapisid, 3psapisid + """ + yt_cookies = self._get_cookies('https://www.youtube.com') + yt_sapisid = try_call(lambda: yt_cookies['SAPISID'].value) + yt_3papisid = try_call(lambda: yt_cookies['__Secure-3PAPISID'].value) + yt_1papisid = try_call(lambda: yt_cookies['__Secure-1PAPISID'].value) + + # Sometimes SAPISID cookie isn't present but __Secure-3PAPISID is. + # YouTube also falls back to __Secure-3PAPISID if SAPISID is missing. + # See: https://github.com/yt-dlp/yt-dlp/issues/393 + + return yt_sapisid or yt_3papisid, yt_1papisid, yt_3papisid + + def _get_sid_authorization_header(self, origin='https://www.youtube.com', user_session_id=None): + """ + Generate API Session ID Authorization for Innertube requests. Assumes all requests are secure (https). + @param origin: Origin URL + @param user_session_id: Optional User Session ID + @return: Authorization header value + """ + + authorizations = [] + additional_parts = {} + if user_session_id: + additional_parts['u'] = user_session_id + + yt_sapisid, yt_1psapisid, yt_3psapisid = self._get_sid_cookies() + + for scheme, sid in (('SAPISIDHASH', yt_sapisid), + ('SAPISID1PHASH', yt_1psapisid), + ('SAPISID3PHASH', yt_3psapisid)): + if sid: + authorizations.append(self._make_sid_authorization(scheme, sid, origin, additional_parts)) + + if not authorizations: return None - # SAPISIDHASH algorithm from https://stackoverflow.com/a/32065323 - sapisidhash = hashlib.sha1( - f'{time_now} {self._SAPISID} {origin}'.encode()).hexdigest() - return f'SAPISIDHASH {time_now}_{sapisidhash}' + + return ' '.join(authorizations) def _call_api(self, ep, query, video_id, fatal=True, headers=None, note='Downloading API JSON', errnote='Unable to download API page', @@ -689,26 +725,48 @@ class YoutubeBaseInfoExtractor(InfoExtractor): if session_index is not None: return session_index - def _data_sync_id_to_delegated_session_id(self, data_sync_id): + @staticmethod + def _parse_data_sync_id(data_sync_id): + """ + Parse data_sync_id into delegated_session_id and user_session_id. + + data_sync_id is of the form "delegated_session_id||user_session_id" for secondary channel + and just "user_session_id||" for primary channel. + + @param data_sync_id: data_sync_id string + @return: Tuple of (delegated_session_id, user_session_id) + """ if not data_sync_id: - return - # datasyncid is of the form "channel_syncid||user_syncid" for secondary channel - # and just "user_syncid||" for primary channel. We only want the channel_syncid - channel_syncid, _, user_syncid = data_sync_id.partition('||') - if user_syncid: - return channel_syncid + return None, None + first, _, second = data_sync_id.partition('||') + if second: + return first, second + return None, first - def _extract_account_syncid(self, *args): + def _extract_delegated_session_id(self, *args): """ - Extract current session ID required to download private playlists of secondary channels + Extract current delegated session ID required to download private playlists of secondary channels @params response and/or ytcfg + @return: delegated session ID """ # ytcfg includes channel_syncid if on secondary channel if delegated_sid := traverse_obj(args, (..., 'DELEGATED_SESSION_ID', {str}, any)): return delegated_sid data_sync_id = self._extract_data_sync_id(*args) - return self._data_sync_id_to_delegated_session_id(data_sync_id) + return self._parse_data_sync_id(data_sync_id)[0] + + def _extract_user_session_id(self, *args): + """ + Extract current user session ID + @params response and/or ytcfg + @return: user session ID + """ + if user_sid := traverse_obj(args, (..., 'USER_SESSION_ID', {str}, any)): + return user_sid + + data_sync_id = self._extract_data_sync_id(*args) + return self._parse_data_sync_id(data_sync_id)[1] def _extract_data_sync_id(self, *args): """ @@ -735,7 +793,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor): @functools.cached_property def is_authenticated(self): - return bool(self._generate_sapisidhash_header()) + return bool(self._get_sid_authorization_header()) def extract_ytcfg(self, video_id, webpage): if not webpage: @@ -745,25 +803,28 @@ class YoutubeBaseInfoExtractor(InfoExtractor): r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;', webpage, 'ytcfg', default='{}'), video_id, fatal=False) or {} - def _generate_cookie_auth_headers(self, *, ytcfg=None, account_syncid=None, session_index=None, origin=None, **kwargs): + def _generate_cookie_auth_headers(self, *, ytcfg=None, delegated_session_id=None, user_session_id=None, session_index=None, origin=None, **kwargs): headers = {} - account_syncid = account_syncid or self._extract_account_syncid(ytcfg) - if account_syncid: - headers['X-Goog-PageId'] = account_syncid + delegated_session_id = delegated_session_id or self._extract_delegated_session_id(ytcfg) + if delegated_session_id: + headers['X-Goog-PageId'] = delegated_session_id if session_index is None: session_index = self._extract_session_index(ytcfg) - if account_syncid or session_index is not None: + if delegated_session_id or session_index is not None: headers['X-Goog-AuthUser'] = session_index if session_index is not None else 0 - auth = self._generate_sapisidhash_header(origin) + auth = self._get_sid_authorization_header(origin, user_session_id=user_session_id or self._extract_user_session_id(ytcfg)) if auth is not None: headers['Authorization'] = auth headers['X-Origin'] = origin + if traverse_obj(ytcfg, 'LOGGED_IN', expected_type=bool): + headers['X-Youtube-Bootstrap-Logged-In'] = 'true' + return headers def generate_api_headers( - self, *, ytcfg=None, account_syncid=None, session_index=None, + self, *, ytcfg=None, delegated_session_id=None, user_session_id=None, session_index=None, visitor_data=None, api_hostname=None, default_client='web', **kwargs): origin = 'https://' + (self._select_api_hostname(api_hostname, default_client)) @@ -774,7 +835,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor): 'Origin': origin, 'X-Goog-Visitor-Id': visitor_data or self._extract_visitor_data(ytcfg), 'User-Agent': self._ytcfg_get_safe(ytcfg, lambda x: x['INNERTUBE_CONTEXT']['client']['userAgent'], default_client=default_client), - **self._generate_cookie_auth_headers(ytcfg=ytcfg, account_syncid=account_syncid, session_index=session_index, origin=origin), + **self._generate_cookie_auth_headers( + ytcfg=ytcfg, + delegated_session_id=delegated_session_id, + user_session_id=user_session_id, + session_index=session_index, + origin=origin), } return filter_dict(headers) @@ -3837,9 +3903,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor): default_client=client, visitor_data=visitor_data, session_index=self._extract_session_index(master_ytcfg, player_ytcfg), - account_syncid=( - self._data_sync_id_to_delegated_session_id(data_sync_id) - or self._extract_account_syncid(master_ytcfg, initial_pr, player_ytcfg) + delegated_session_id=( + self._parse_data_sync_id(data_sync_id)[0] + or self._extract_delegated_session_id(master_ytcfg, initial_pr, player_ytcfg) + ), + user_session_id=( + self._parse_data_sync_id(data_sync_id)[1] + or self._extract_user_session_id(master_ytcfg, initial_pr, player_ytcfg) ), ) @@ -5351,7 +5421,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor): if not continuation_list[0]: continuation_list[0] = self._extract_continuation(parent_renderer) - def _entries(self, tab, item_id, ytcfg, account_syncid, visitor_data): + def _entries(self, tab, item_id, ytcfg, delegated_session_id, visitor_data): continuation_list = [None] extract_entries = lambda x: self._extract_entries(x, continuation_list) tab_content = try_get(tab, lambda x: x['content'], dict) @@ -5372,7 +5442,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor): break seen_continuations.add(continuation_token) headers = self.generate_api_headers( - ytcfg=ytcfg, account_syncid=account_syncid, visitor_data=visitor_data) + ytcfg=ytcfg, delegated_session_id=delegated_session_id, visitor_data=visitor_data) response = self._extract_response( item_id=f'{item_id} page {page_num}', query=continuation, headers=headers, ytcfg=ytcfg, @@ -5442,7 +5512,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor): return self.playlist_result( self._entries( selected_tab, metadata['id'], ytcfg, - self._extract_account_syncid(ytcfg, data), + self._extract_delegated_session_id(ytcfg, data), self._extract_visitor_data(data, ytcfg)), **metadata) @@ -5594,7 +5664,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor): watch_endpoint = try_get( playlist, lambda x: x['contents'][-1]['playlistPanelVideoRenderer']['navigationEndpoint']['watchEndpoint']) headers = self.generate_api_headers( - ytcfg=ytcfg, account_syncid=self._extract_account_syncid(ytcfg, data), + ytcfg=ytcfg, delegated_session_id=self._extract_delegated_session_id(ytcfg, data), visitor_data=self._extract_visitor_data(response, data, ytcfg)) query = { 'playlistId': playlist_id, @@ -5692,7 +5762,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor): if not is_playlist: return headers = self.generate_api_headers( - ytcfg=ytcfg, account_syncid=self._extract_account_syncid(ytcfg, data), + ytcfg=ytcfg, delegated_session_id=self._extract_delegated_session_id(ytcfg, data), visitor_data=self._extract_visitor_data(data, ytcfg)) query = { 'params': 'wgYCCAA=', From 1f489f4a45691cac3f9e787d22a3a8a086229ba6 Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Sun, 12 Jan 2025 18:42:02 +0000 Subject: [PATCH 007/121] [ie/DrTalks] Add extractor (#10831) Closes #6390 Authored by: pzhlkj6612, seproDev Co-authored-by: sepro --- yt_dlp/extractor/_extractors.py | 1 + yt_dlp/extractor/drtalks.py | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 yt_dlp/extractor/drtalks.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index bbd6d21bd7..e3947dfb5c 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -555,6 +555,7 @@ from .dropout import ( DropoutIE, DropoutSeasonIE, ) +from .drtalks import DrTalksIE from .drtuber import DrTuberIE from .drtv import ( DRTVIE, diff --git a/yt_dlp/extractor/drtalks.py b/yt_dlp/extractor/drtalks.py new file mode 100644 index 0000000000..5ea7f75807 --- /dev/null +++ b/yt_dlp/extractor/drtalks.py @@ -0,0 +1,51 @@ +from .brightcove import BrightcoveNewIE +from .common import InfoExtractor +from ..utils import url_or_none +from ..utils.traversal import traverse_obj + + +class DrTalksIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?drtalks\.com/videos/(?P[\w-]+)' + _TESTS = [{ + 'url': 'https://drtalks.com/videos/six-pillars-of-resilience-tools-for-managing-stress-and-flourishing/', + 'info_dict': { + 'id': '6366193757112', + 'ext': 'mp4', + 'uploader_id': '6314452011001', + 'tags': ['resilience'], + 'description': 'md5:9c6805aee237ee6de8052461855b9dda', + 'timestamp': 1734546659, + 'thumbnail': 'https://drtalks.com/wp-content/uploads/2024/12/Episode-82-Eva-Selhub-DrTalks-Thumbs.jpg', + 'title': 'Six Pillars of Resilience: Tools for Managing Stress and Flourishing', + 'duration': 2800.682, + 'upload_date': '20241218', + }, + }, { + 'url': 'https://drtalks.com/videos/the-pcos-puzzle-mastering-metabolic-health-with-marcelle-pick/', + 'info_dict': { + 'id': '6364699891112', + 'ext': 'mp4', + 'title': 'The PCOS Puzzle: Mastering Metabolic Health with Marcelle Pick', + 'description': 'md5:e87cbe00ca50135d5702787fc4043aaa', + 'thumbnail': 'https://drtalks.com/wp-content/uploads/2024/11/Episode-34-Marcelle-Pick-OBGYN-NP-DrTalks.jpg', + 'duration': 3515.2, + 'tags': ['pcos'], + 'upload_date': '20241114', + 'timestamp': 1731592119, + 'uploader_id': '6314452011001', + }, + }] + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + next_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['data']['video'] + + return self.url_result( + next_data['videos']['brightcoveVideoLink'], BrightcoveNewIE, video_id, + url_transparent=True, + **traverse_obj(next_data, { + 'title': ('title', {str}), + 'description': ('videos', 'summury', {str}), + 'thumbnail': ('featuredImage', 'node', 'sourceUrl', {url_or_none}), + })) From e2ef4fece6c9742d1733e3bae408c4787765f78c Mon Sep 17 00:00:00 2001 From: Allen <64094914+allendema@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:43:16 +0100 Subject: [PATCH 008/121] [ie/vine] Remove extractors (#11700) Authored by: allendema --- yt_dlp/extractor/_extractors.py | 4 - yt_dlp/extractor/tumblr.py | 21 ----- yt_dlp/extractor/twitter.py | 39 --------- yt_dlp/extractor/vine.py | 150 -------------------------------- 4 files changed, 214 deletions(-) delete mode 100644 yt_dlp/extractor/vine.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index e3947dfb5c..d42bce21b2 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -2356,10 +2356,6 @@ from .vimm import ( VimmIE, VimmRecordingIE, ) -from .vine import ( - VineIE, - VineUserIE, -) from .viously import ViouslyIE from .viqeo import ViqeoIE from .viu import ( diff --git a/yt_dlp/extractor/tumblr.py b/yt_dlp/extractor/tumblr.py index d6d4368839..1f2c9b19ca 100644 --- a/yt_dlp/extractor/tumblr.py +++ b/yt_dlp/extractor/tumblr.py @@ -189,26 +189,6 @@ class TumblrIE(InfoExtractor): 'release_date': '20140227', }, 'add_ie': ['Vimeo'], - }, { - 'url': 'http://sutiblr.tumblr.com/post/139638707273', - 'md5': '2dd184b3669e049ba40563a7d423f95c', - 'info_dict': { - 'id': 'ir7qBEIKqvq', - 'ext': 'mp4', - 'title': 'Vine by sutiblr', - 'alt_title': 'Vine by sutiblr', - 'uploader': 'sutiblr', - 'uploader_id': '1198993975374495744', - 'upload_date': '20160220', - 'like_count': int, - 'comment_count': int, - 'repost_count': int, - 'thumbnail': r're:^https?://.*\.jpg', - 'timestamp': 1455940159, - 'view_count': int, - }, - 'add_ie': ['Vine'], - 'skip': 'Vine is unavailable', }, { 'url': 'https://silami.tumblr.com/post/84250043974/my-bad-river-flows-in-you-impression-on-maschine', 'md5': '3c92d7c3d867f14ccbeefa2119022277', @@ -366,7 +346,6 @@ class TumblrIE(InfoExtractor): _providers = { 'instagram': 'Instagram', 'vimeo': 'Vimeo', - 'vine': 'Vine', 'youtube': 'Youtube', 'dailymotion': 'Dailymotion', 'tiktok': 'TikTok', diff --git a/yt_dlp/extractor/twitter.py b/yt_dlp/extractor/twitter.py index 8196ce6c32..c05b5bf9cb 100644 --- a/yt_dlp/extractor/twitter.py +++ b/yt_dlp/extractor/twitter.py @@ -409,26 +409,6 @@ class TwitterCardIE(InfoExtractor): }, 'add_ie': ['Youtube'], }, - { - 'url': 'https://twitter.com/i/cards/tfw/v1/665289828897005568', - 'info_dict': { - 'id': 'iBb2x00UVlv', - 'ext': 'mp4', - 'upload_date': '20151113', - 'uploader_id': '1189339351084113920', - 'uploader': 'ArsenalTerje', - 'title': 'Vine by ArsenalTerje', - 'timestamp': 1447451307, - 'alt_title': 'Vine by ArsenalTerje', - 'comment_count': int, - 'like_count': int, - 'thumbnail': r're:^https?://[^?#]+\.jpg', - 'view_count': int, - 'repost_count': int, - }, - 'add_ie': ['Vine'], - 'params': {'skip_download': 'm3u8'}, - }, { 'url': 'https://twitter.com/i/videos/tweet/705235433198714880', 'md5': '884812a2adc8aaf6fe52b15ccbfa3b88', @@ -567,25 +547,6 @@ class TwitterIE(TwitterBaseIE): 'age_limit': 0, '_old_archive_ids': ['twitter 700207533655363584'], }, - }, { - 'url': 'https://twitter.com/Filmdrunk/status/713801302971588609', - 'md5': '89a15ed345d13b86e9a5a5e051fa308a', - 'info_dict': { - 'id': 'MIOxnrUteUd', - 'ext': 'mp4', - 'title': 'Dr.Pepperの飲み方 #japanese #バカ #ドクペ #電動ガン', - 'uploader': 'TAKUMA', - 'uploader_id': '1004126642786242560', - 'timestamp': 1402826626, - 'upload_date': '20140615', - 'thumbnail': r're:^https?://.*\.jpg', - 'alt_title': 'Vine by TAKUMA', - 'comment_count': int, - 'repost_count': int, - 'like_count': int, - 'view_count': int, - }, - 'add_ie': ['Vine'], }, { 'url': 'https://twitter.com/captainamerica/status/719944021058060289', 'info_dict': { diff --git a/yt_dlp/extractor/vine.py b/yt_dlp/extractor/vine.py deleted file mode 100644 index eed4bfeeb9..0000000000 --- a/yt_dlp/extractor/vine.py +++ /dev/null @@ -1,150 +0,0 @@ -from .common import InfoExtractor -from ..utils import ( - determine_ext, - format_field, - int_or_none, - unified_timestamp, -) - - -class VineIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?vine\.co/(?:v|oembed)/(?P\w+)' - _EMBED_REGEX = [r']+src=[\'"](?P(?:https?:)?//(?:www\.)?vine\.co/v/[^/]+/embed/(?:simple|postcard))'] - _TESTS = [{ - 'url': 'https://vine.co/v/b9KOOWX7HUx', - 'md5': '2f36fed6235b16da96ce9b4dc890940d', - 'info_dict': { - 'id': 'b9KOOWX7HUx', - 'ext': 'mp4', - 'title': 'Chicken.', - 'alt_title': 'Vine by Jack', - 'timestamp': 1368997951, - 'upload_date': '20130519', - 'uploader': 'Jack', - 'uploader_id': '76', - 'view_count': int, - 'like_count': int, - 'comment_count': int, - 'repost_count': int, - }, - }, { - 'url': 'https://vine.co/v/e192BnZnZ9V', - 'info_dict': { - 'id': 'e192BnZnZ9V', - 'ext': 'mp4', - 'title': 'ยิ้ม~ เขิน~ อาย~ น่าร้ากอ้ะ >//< @n_whitewo @orlameena #lovesicktheseries #lovesickseason2', - 'alt_title': 'Vine by Pimry_zaa', - 'timestamp': 1436057405, - 'upload_date': '20150705', - 'uploader': 'Pimry_zaa', - 'uploader_id': '1135760698325307392', - 'view_count': int, - 'like_count': int, - 'comment_count': int, - 'repost_count': int, - }, - 'params': { - 'skip_download': True, - }, - }, { - 'url': 'https://vine.co/v/MYxVapFvz2z', - 'only_matching': True, - }, { - 'url': 'https://vine.co/v/bxVjBbZlPUH', - 'only_matching': True, - }, { - 'url': 'https://vine.co/oembed/MYxVapFvz2z.json', - 'only_matching': True, - }] - - def _real_extract(self, url): - video_id = self._match_id(url) - - data = self._download_json( - f'https://archive.vine.co/posts/{video_id}.json', video_id) - - def video_url(kind): - for url_suffix in ('Url', 'URL'): - format_url = data.get(f'video{kind}{url_suffix}') - if format_url: - return format_url - - formats = [] - for quality, format_id in enumerate(('low', '', 'dash')): - format_url = video_url(format_id.capitalize()) - if not format_url: - continue - # DASH link returns plain mp4 - if format_id == 'dash' and determine_ext(format_url) == 'mpd': - formats.extend(self._extract_mpd_formats( - format_url, video_id, mpd_id='dash', fatal=False)) - else: - formats.append({ - 'url': format_url, - 'format_id': format_id or 'standard', - 'quality': quality, - }) - self._check_formats(formats, video_id) - - username = data.get('username') - - alt_title = format_field(username, None, 'Vine by %s') - - return { - 'id': video_id, - 'title': data.get('description') or alt_title or 'Vine video', - 'alt_title': alt_title, - 'thumbnail': data.get('thumbnailUrl'), - 'timestamp': unified_timestamp(data.get('created')), - 'uploader': username, - 'uploader_id': data.get('userIdStr'), - 'view_count': int_or_none(data.get('loops')), - 'like_count': int_or_none(data.get('likes')), - 'comment_count': int_or_none(data.get('comments')), - 'repost_count': int_or_none(data.get('reposts')), - 'formats': formats, - } - - -class VineUserIE(InfoExtractor): - IE_NAME = 'vine:user' - _VALID_URL = r'https?://vine\.co/(?Pu/)?(?P[^/]+)' - _VINE_BASE_URL = 'https://vine.co/' - _TESTS = [{ - 'url': 'https://vine.co/itsruthb', - 'info_dict': { - 'id': 'itsruthb', - 'title': 'Ruth B', - 'description': '| Instagram/Twitter: itsruthb | still a lost boy from neverland', - }, - 'playlist_mincount': 611, - }, { - 'url': 'https://vine.co/u/942914934646415360', - 'only_matching': True, - }] - - @classmethod - def suitable(cls, url): - return False if VineIE.suitable(url) else super().suitable(url) - - def _real_extract(self, url): - mobj = self._match_valid_url(url) - user = mobj.group('user') - u = mobj.group('u') - - profile_url = '{}api/users/profiles/{}{}'.format( - self._VINE_BASE_URL, 'vanity/' if not u else '', user) - profile_data = self._download_json( - profile_url, user, note='Downloading user profile data') - - data = profile_data['data'] - user_id = data.get('userId') or data['userIdStr'] - profile = self._download_json( - f'https://archive.vine.co/profiles/{user_id}.json', user_id) - entries = [ - self.url_result( - f'https://vine.co/v/{post_id}', ie='Vine', video_id=post_id) - for post_id in profile['posts'] - if post_id and isinstance(post_id, str)] - return self.playlist_result( - entries, user, profile.get('username'), profile.get('description')) From dade5e35c89adaad04408bfef766820dbca06ebe Mon Sep 17 00:00:00 2001 From: Simon Sawicki Date: Mon, 13 Jan 2025 00:24:22 +0100 Subject: [PATCH 009/121] [cleanup] Misc (#11915) Authored by: grqz, Grub4K, seproDev Co-authored-by: sepro Co-authored-by: N/Ame <173015200+grqz@users.noreply.github.com> --- README.md | 2 +- pyproject.toml | 3 ++- yt_dlp/YoutubeDL.py | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1c628d0257..2f848bd132 100644 --- a/README.md +++ b/README.md @@ -1769,7 +1769,7 @@ The following extractors use this feature: #### youtube * `lang`: Prefer translated metadata (`title`, `description` etc) of this language code (case-sensitive). By default, the video primary language metadata is preferred, with a fallback to `en` translated. See [youtube.py](https://github.com/yt-dlp/yt-dlp/blob/c26f9b991a0681fd3ea548d535919cec1fbbd430/yt_dlp/extractor/youtube.py#L381-L390) for list of supported content language codes * `skip`: One or more of `hls`, `dash` or `translated_subs` to skip extraction of the m3u8 manifests, dash manifests and [auto-translated subtitles](https://github.com/yt-dlp/yt-dlp/issues/4090#issuecomment-1158102032) respectively -* `player_client`: Clients to extract video data from. The main clients are `web`, `ios` and `android`, with variants `_music` and `_creator` (e.g. `ios_creator`); and `mweb`, `android_vr`, `web_safari`, `web_embedded`, `tv` and `tv_embedded` with no variants. By default, `ios,mweb` is used, or `web_creator,mweb` is used when authenticating with cookies. The `_music` variants are added for `music.youtube.com` URLs. Some clients, such as `web` and `android`, require a `po_token` for their formats to be downloadable. Some clients, such as the `_creator` variants, will only work with authentication. Not all clients support authentication via cookies. You can use `all` to use all the clients, and `default` for the default clients. You can prefix a client with `-` to exclude it, e.g. `youtube:player_client=all,-web` +* `player_client`: Clients to extract video data from. The main clients are `web`, `ios` and `android`, with variants `_music` and `_creator` (e.g. `ios_creator`); and `mweb`, `android_vr`, `web_safari`, `web_embedded`, `tv` and `tv_embedded` with no variants. By default, `ios,tv` is used, or `web_creator,tv` is used when authenticating with cookies. The `_music` variants are added for `music.youtube.com` URLs. Some clients, such as `web` and `android`, require a `po_token` for their formats to be downloadable. Some clients, such as the `_creator` variants, will only work with authentication. Not all clients support authentication via cookies. You can use `all` to use all the clients, and `default` for the default clients. You can prefix a client with `-` to exclude it, e.g. `youtube:player_client=all,-web` * `player_skip`: Skip some network requests that are generally needed for robust extraction. One or more of `configs` (skip client configs), `webpage` (skip initial webpage), `js` (skip js player). While these options can help reduce the number of requests needed or avoid some rate-limiting, they could cause some issues. See [#860](https://github.com/yt-dlp/yt-dlp/pull/860) for more details * `player_params`: YouTube player parameters to use for player requests. Will overwrite any default ones set by yt-dlp. * `comment_sort`: `top` or `new` (default) - choose comment sorting mode (on YouTube's side) diff --git a/pyproject.toml b/pyproject.toml index 96e2d669a4..5eb9a96447 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ dev = [ ] static-analysis = [ "autopep8~=2.0", - "ruff~=0.8.0", + "ruff~=0.9.0", ] test = [ "pytest~=8.1", @@ -195,6 +195,7 @@ ignore = [ "B023", # function-uses-loop-variable (false positives) "B028", # no-explicit-stacklevel "B904", # raise-without-from-inside-except + "A005", # stdlib-module-shadowing "C401", # unnecessary-generator-set "C402", # unnecessary-generator-dict "PIE790", # unnecessary-placeholder diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 178c5b9515..f6155dd2e9 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -283,7 +283,10 @@ class YoutubeDL: lazy_playlist: Process playlist entries as they are received. matchtitle: Download only matching titles. rejecttitle: Reject downloads for matching titles. - logger: Log messages to a logging.Logger instance. + logger: A class having a `debug`, `warning` and `error` function where + each has a single string parameter, the message to be logged. + For compatibility reasons, both debug and info messages are passed to `debug`. + A debug message will have a prefix of `[debug] ` to discern it from info messages. logtostderr: Print everything to stderr instead of stdout. consoletitle: Display progress in the console window's titlebar. writedescription: Write the video description to a .description file From a3c0321825110d7eb447a6e6f393cec2bade34f9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:35:35 +0000 Subject: [PATCH 010/121] Release 2025.01.12 Created by: bashonly :ci skip all --- CONTRIBUTORS | 2 ++ Changelog.md | 19 +++++++++++++++++++ supportedsites.md | 4 ++-- yt_dlp/version.py | 6 +++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4b69642603..0102264180 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -713,3 +713,5 @@ xiaomac wesson09 Crypto90 MutantPiggieGolem1 +Sanceilaks +Strkmn diff --git a/Changelog.md b/Changelog.md index 22a9a6e4bb..cf9806ea11 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,25 @@ # To create a release, dispatch the https://github.com/yt-dlp/yt-dlp/actions/workflows/release.yml workflow on master --> +### 2025.01.12 + +#### Core changes +- [Fix filename sanitization with `--no-windows-filenames`](https://github.com/yt-dlp/yt-dlp/commit/8346b549150003df988538e54c9d8bc4de568979) ([#11988](https://github.com/yt-dlp/yt-dlp/issues/11988)) by [bashonly](https://github.com/bashonly) +- [Validate retries values are non-negative](https://github.com/yt-dlp/yt-dlp/commit/1f4e1e85a27c5b43e34d7706cfd88ffce1b56a4a) ([#11927](https://github.com/yt-dlp/yt-dlp/issues/11927)) by [Strkmn](https://github.com/Strkmn) + +#### Extractor changes +- **drtalks**: [Add extractor](https://github.com/yt-dlp/yt-dlp/commit/1f489f4a45691cac3f9e787d22a3a8a086229ba6) ([#10831](https://github.com/yt-dlp/yt-dlp/issues/10831)) by [pzhlkj6612](https://github.com/pzhlkj6612), [seproDev](https://github.com/seproDev) +- **plvideo**: [Add extractor](https://github.com/yt-dlp/yt-dlp/commit/3c14e9191f3035b9a729d1d87bc0381f42de57cf) ([#10657](https://github.com/yt-dlp/yt-dlp/issues/10657)) by [Sanceilaks](https://github.com/Sanceilaks), [seproDev](https://github.com/seproDev) +- **vine**: [Remove extractors](https://github.com/yt-dlp/yt-dlp/commit/e2ef4fece6c9742d1733e3bae408c4787765f78c) ([#11700](https://github.com/yt-dlp/yt-dlp/issues/11700)) by [allendema](https://github.com/allendema) +- **xiaohongshu**: [Extend `_VALID_URL`](https://github.com/yt-dlp/yt-dlp/commit/763ed06ee69f13949397897bd42ff2ec3dc3d384) ([#11806](https://github.com/yt-dlp/yt-dlp/issues/11806)) by [HobbyistDev](https://github.com/HobbyistDev) +- **youtube** + - [Fix DASH formats incorrectly skipped in some situations](https://github.com/yt-dlp/yt-dlp/commit/0b6b7742c2e7f2a1fcb0b54ef3dd484bab404b3f) ([#11910](https://github.com/yt-dlp/yt-dlp/issues/11910)) by [coletdjnz](https://github.com/coletdjnz) + - [Refactor cookie auth](https://github.com/yt-dlp/yt-dlp/commit/75079f4e3f7dce49b61ef01da7adcd9876a0ca3b) ([#11989](https://github.com/yt-dlp/yt-dlp/issues/11989)) by [coletdjnz](https://github.com/coletdjnz) + - [Use `tv` instead of `mweb` client by default](https://github.com/yt-dlp/yt-dlp/commit/712d2abb32f59b2d246be2901255f84f1a4c30b3) ([#12059](https://github.com/yt-dlp/yt-dlp/issues/12059)) by [coletdjnz](https://github.com/coletdjnz) + +#### Misc. changes +- **cleanup**: Miscellaneous: [dade5e3](https://github.com/yt-dlp/yt-dlp/commit/dade5e35c89adaad04408bfef766820dbca06ebe) by [grqz](https://github.com/grqz), [Grub4K](https://github.com/Grub4K), [seproDev](https://github.com/seproDev) + ### 2024.12.23 #### Core changes diff --git a/supportedsites.md b/supportedsites.md index 916735e08b..1420742d17 100644 --- a/supportedsites.md +++ b/supportedsites.md @@ -374,6 +374,7 @@ - **Dropbox** - **Dropout**: [*dropout*](## "netrc machine") - **DropoutSeason** + - **DrTalks** - **DrTuber** - **drtv** - **drtv:live** @@ -1086,6 +1087,7 @@ - **pluralsight**: [*pluralsight*](## "netrc machine") - **pluralsight:course** - **PlutoTV**: (**Currently broken**) + - **PlVideo**: Платформа - **PodbayFM** - **PodbayFMChannel** - **Podchaser** @@ -1641,8 +1643,6 @@ - **Vimm:stream** - **ViMP** - **ViMP:Playlist** - - **Vine** - - **vine:user** - **Viously** - **Viqeo**: (**Currently broken**) - **Viu** diff --git a/yt_dlp/version.py b/yt_dlp/version.py index 1ff43c611f..97a3b1b26a 100644 --- a/yt_dlp/version.py +++ b/yt_dlp/version.py @@ -1,8 +1,8 @@ # Autogenerated by devscripts/update-version.py -__version__ = '2024.12.23' +__version__ = '2025.01.12' -RELEASE_GIT_HEAD = '65cf46cddd873fd229dbb0fc0689bca4c201c6b6' +RELEASE_GIT_HEAD = 'dade5e35c89adaad04408bfef766820dbca06ebe' VARIANT = None @@ -12,4 +12,4 @@ CHANNEL = 'stable' ORIGIN = 'yt-dlp/yt-dlp' -_pkg_version = '2024.12.23' +_pkg_version = '2025.01.12' From c8541f8b13e743fcfa06667530d13fee8686e22a Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:21:56 -0600 Subject: [PATCH 011/121] [ie/youtube] Do not use `web_creator` as a default client (#12087) Closes #12085 Authored by: bashonly --- README.md | 2 +- yt_dlp/extractor/youtube.py | 41 +++++++------------------------------ 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 2f848bd132..56e4458dc1 100644 --- a/README.md +++ b/README.md @@ -1769,7 +1769,7 @@ The following extractors use this feature: #### youtube * `lang`: Prefer translated metadata (`title`, `description` etc) of this language code (case-sensitive). By default, the video primary language metadata is preferred, with a fallback to `en` translated. See [youtube.py](https://github.com/yt-dlp/yt-dlp/blob/c26f9b991a0681fd3ea548d535919cec1fbbd430/yt_dlp/extractor/youtube.py#L381-L390) for list of supported content language codes * `skip`: One or more of `hls`, `dash` or `translated_subs` to skip extraction of the m3u8 manifests, dash manifests and [auto-translated subtitles](https://github.com/yt-dlp/yt-dlp/issues/4090#issuecomment-1158102032) respectively -* `player_client`: Clients to extract video data from. The main clients are `web`, `ios` and `android`, with variants `_music` and `_creator` (e.g. `ios_creator`); and `mweb`, `android_vr`, `web_safari`, `web_embedded`, `tv` and `tv_embedded` with no variants. By default, `ios,tv` is used, or `web_creator,tv` is used when authenticating with cookies. The `_music` variants are added for `music.youtube.com` URLs. Some clients, such as `web` and `android`, require a `po_token` for their formats to be downloadable. Some clients, such as the `_creator` variants, will only work with authentication. Not all clients support authentication via cookies. You can use `all` to use all the clients, and `default` for the default clients. You can prefix a client with `-` to exclude it, e.g. `youtube:player_client=all,-web` +* `player_client`: Clients to extract video data from. The main clients are `web`, `ios` and `android`, with variants `_music` and `_creator` (e.g. `ios_creator`); and `mweb`, `android_vr`, `web_safari`, `web_embedded`, `tv` and `tv_embedded` with no variants. By default, `tv,ios,web` is used, or `tv,web` is used when authenticating with cookies. The `_music` variants may be added for `music.youtube.com` URLs. Some clients, such as `web` and `android`, require a `po_token` for their formats to be downloadable. Some clients, such as the `_creator` variants, will only work with authentication. Not all clients support authentication via cookies. You can use `default` for the default clients, or you can use `all` for all clients (not recommended). You can prefix a client with `-` to exclude it, e.g. `youtube:player_client=default,-ios` * `player_skip`: Skip some network requests that are generally needed for robust extraction. One or more of `configs` (skip client configs), `webpage` (skip initial webpage), `js` (skip js player). While these options can help reduce the number of requests needed or avoid some rate-limiting, they could cause some issues. See [#860](https://github.com/yt-dlp/yt-dlp/pull/860) for more details * `player_params`: YouTube player parameters to use for player requests. Will overwrite any default ones set by yt-dlp. * `comment_sort`: `top` or `new` (default) - choose comment sorting mode (on YouTube's side) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index e16ec43edd..c23e65cc51 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -116,6 +116,7 @@ INNERTUBE_CLIENTS = { }, }, 'INNERTUBE_CONTEXT_CLIENT_NAME': 67, + 'REQUIRE_PO_TOKEN': True, 'SUPPORTS_COOKIES': True, }, # This client now requires sign-in for every video @@ -127,6 +128,7 @@ INNERTUBE_CLIENTS = { }, }, 'INNERTUBE_CONTEXT_CLIENT_NAME': 62, + 'REQUIRE_PO_TOKEN': True, 'REQUIRE_AUTH': True, 'SUPPORTS_COOKIES': True, }, @@ -211,8 +213,8 @@ INNERTUBE_CLIENTS = { }, }, 'INNERTUBE_CONTEXT_CLIENT_NAME': 5, - 'REQUIRE_PO_TOKEN': True, 'REQUIRE_JS_PLAYER': False, + 'REQUIRE_PO_TOKEN': True, }, # This client now requires sign-in for every video 'ios_music': { @@ -229,6 +231,7 @@ INNERTUBE_CLIENTS = { }, 'INNERTUBE_CONTEXT_CLIENT_NAME': 26, 'REQUIRE_JS_PLAYER': False, + 'REQUIRE_PO_TOKEN': True, 'REQUIRE_AUTH': True, }, # This client now requires sign-in for every video @@ -246,6 +249,7 @@ INNERTUBE_CLIENTS = { }, 'INNERTUBE_CONTEXT_CLIENT_NAME': 15, 'REQUIRE_JS_PLAYER': False, + 'REQUIRE_PO_TOKEN': True, 'REQUIRE_AUTH': True, }, # mweb has 'ultralow' formats @@ -1423,8 +1427,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor): '401': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'av01.0.12M.08'}, } _SUBTITLE_FORMATS = ('json3', 'srv1', 'srv2', 'srv3', 'ttml', 'vtt') - _DEFAULT_CLIENTS = ('ios', 'tv') - _DEFAULT_AUTHED_CLIENTS = ('web_creator', 'tv') + _DEFAULT_CLIENTS = ('tv', 'ios', 'web') + _DEFAULT_AUTHED_CLIENTS = ('tv', 'web') _GEO_BYPASS = False @@ -3960,15 +3964,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor): if not requested_clients: raise ExtractorError('No player clients have been requested', expected=True) - if smuggled_data.get('is_music_url') or self.is_music_url(url): - for requested_client in requested_clients: - _, base_client, variant = _split_innertube_client(requested_client) - music_client = f'{base_client}_music' if base_client != 'mweb' else 'web_music' - if variant != 'music' and music_client in INNERTUBE_CLIENTS: - client_info = INNERTUBE_CLIENTS[music_client] - if not client_info['REQUIRE_AUTH'] or (self.is_authenticated and client_info['SUPPORTS_COOKIES']): - requested_clients.append(music_client) - if self.is_authenticated: unsupported_clients = [ client for client in requested_clients if not INNERTUBE_CLIENTS[client]['SUPPORTS_COOKIES'] @@ -4079,28 +4074,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor): else: prs.append(pr) - # web_embedded can work around age-gate and age-verification for some embeddable videos - if self._is_agegated(pr) and variant != 'web_embedded': - append_client(f'web_embedded.{base_client}') - # Unauthenticated users will only get web_embedded client formats if age-gated - if self._is_agegated(pr) and not self.is_authenticated: - self.to_screen( - f'{video_id}: This video is age-restricted; some formats may be missing ' - f'without authentication. {self._login_hint()}', only_once=True) - - ''' This code is pointless while web_creator is in _DEFAULT_AUTHED_CLIENTS - # EU countries require age-verification for accounts to access age-restricted videos - # If account is not age-verified, _is_agegated() will be truthy for non-embedded clients - embedding_is_disabled = variant == 'web_embedded' and self._is_unplayable(pr) - if self.is_authenticated and (self._is_agegated(pr) or embedding_is_disabled): - self.to_screen( - f'{video_id}: This video is age-restricted and YouTube is requiring ' - 'account age-verification; some formats may be missing', only_once=True) - # web_creator can work around the age-verification requirement - # tv_embedded may(?) still work around age-verification if the video is embeddable - append_client('web_creator') - ''' - prs.extend(deprioritized_prs) if skipped_clients: From bbc7591d3bb650f96cd1f1584055888cc919f14a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:50:41 +0000 Subject: [PATCH 012/121] Release 2025.01.15 Created by: bashonly :ci skip all --- Changelog.md | 5 +++++ yt_dlp/version.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index cf9806ea11..b996d35f7a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,11 @@ # To create a release, dispatch the https://github.com/yt-dlp/yt-dlp/actions/workflows/release.yml workflow on master --> +### 2025.01.15 + +#### Extractor changes +- **youtube**: [Do not use `web_creator` as a default client](https://github.com/yt-dlp/yt-dlp/commit/c8541f8b13e743fcfa06667530d13fee8686e22a) ([#12087](https://github.com/yt-dlp/yt-dlp/issues/12087)) by [bashonly](https://github.com/bashonly) + ### 2025.01.12 #### Core changes diff --git a/yt_dlp/version.py b/yt_dlp/version.py index 97a3b1b26a..e7588aebbc 100644 --- a/yt_dlp/version.py +++ b/yt_dlp/version.py @@ -1,8 +1,8 @@ # Autogenerated by devscripts/update-version.py -__version__ = '2025.01.12' +__version__ = '2025.01.15' -RELEASE_GIT_HEAD = 'dade5e35c89adaad04408bfef766820dbca06ebe' +RELEASE_GIT_HEAD = 'c8541f8b13e743fcfa06667530d13fee8686e22a' VARIANT = None @@ -12,4 +12,4 @@ CHANNEL = 'stable' ORIGIN = 'yt-dlp/yt-dlp' -_pkg_version = '2025.01.12' +_pkg_version = '2025.01.15' From 164368610456e2d96b279f8b120dea08f7b1d74f Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:40:13 -0600 Subject: [PATCH 013/121] [ie/dropout] Fix extraction (#12102) Closes #12103 Authored by: bashonly --- yt_dlp/extractor/dropout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/extractor/dropout.py b/yt_dlp/extractor/dropout.py index 7e97c4d40c..a0d8aacdbe 100644 --- a/yt_dlp/extractor/dropout.py +++ b/yt_dlp/extractor/dropout.py @@ -135,7 +135,7 @@ class DropoutIE(InfoExtractor): self.raise_login_required(method='any') raise ExtractorError(login_err, expected=True) - embed_url = self._search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url') + embed_url = self._html_search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url') thumbnail = self._og_search_thumbnail(webpage) watch_info = get_element_by_id('watch-info', webpage) or '' From a567f97b62ae9f6d6f5a9376c361512ab8dceda2 Mon Sep 17 00:00:00 2001 From: 4ft35t <4ft35t@users.noreply.github.com> Date: Sun, 19 Jan 2025 21:10:36 +0800 Subject: [PATCH 014/121] [ie/Weibo] Extend `_VALID_URL` (#12088) Closes #12086 Authored by: 4ft35t --- yt_dlp/extractor/weibo.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/weibo.py b/yt_dlp/extractor/weibo.py index e632858e56..6e57446e94 100644 --- a/yt_dlp/extractor/weibo.py +++ b/yt_dlp/extractor/weibo.py @@ -124,7 +124,7 @@ class WeiboBaseIE(InfoExtractor): class WeiboIE(WeiboBaseIE): - _VALID_URL = r'https?://(?:m\.weibo\.cn/status|(?:www\.)?weibo\.com/\d+)/(?P[a-zA-Z0-9]+)' + _VALID_URL = r'https?://(?:m\.weibo\.cn/(?:status|detail)|(?:www\.)?weibo\.com/\d+)/(?P[a-zA-Z0-9]+)' _TESTS = [{ 'url': 'https://weibo.com/7827771738/N4xlMvjhI', 'info_dict': { @@ -164,6 +164,25 @@ class WeiboIE(WeiboBaseIE): 'like_count': int, 'repost_count': int, }, + }, { + 'url': 'https://m.weibo.cn/detail/4189191225395228', + 'info_dict': { + 'id': '4189191225395228', + 'ext': 'mp4', + 'display_id': 'FBqgOmDxO', + 'title': '柴犬柴犬的秒拍视频', + 'description': '午睡当然是要甜甜蜜蜜的啦![坏笑] Instagram:shibainu.gaku http://t.cn/RHbmjzW ', + 'duration': 53, + 'timestamp': 1514264429, + 'upload_date': '20171226', + 'thumbnail': r're:https://.*\.jpg', + 'uploader': '柴犬柴犬', + 'uploader_id': '5926682210', + 'uploader_url': 'https://weibo.com/u/5926682210', + 'view_count': int, + 'like_count': int, + 'repost_count': int, + }, }, { 'url': 'https://weibo.com/0/4224132150961381', 'note': 'no playback_list example', From 89198bb23b4d03e0473ac408bfb50d67c2f71165 Mon Sep 17 00:00:00 2001 From: Boof <97455552+hexahigh@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:13:40 +0100 Subject: [PATCH 015/121] [ie/nrk] Extract more formats (#12069) Closes #12053 Authored by: hexahigh --- yt_dlp/extractor/nrk.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yt_dlp/extractor/nrk.py b/yt_dlp/extractor/nrk.py index 658ae5f916..efc4a17346 100644 --- a/yt_dlp/extractor/nrk.py +++ b/yt_dlp/extractor/nrk.py @@ -12,6 +12,7 @@ from ..utils import ( parse_iso8601, str_or_none, try_get, + update_url_query, url_or_none, urljoin, ) @@ -171,6 +172,8 @@ class NRKIE(NRKBaseIE): format_url = url_or_none(asset.get('url')) if not format_url: continue + # Remove the 'adap' query parameter + format_url = update_url_query(format_url, {'adap': []}) asset_format = (asset.get('format') or '').lower() if asset_format == 'hls' or determine_ext(format_url) == 'm3u8': formats.extend(self._extract_nrk_formats(format_url, video_id)) From de30f652ffb7623500215f5906844f2ae0d92c7b Mon Sep 17 00:00:00 2001 From: sepro Date: Sun, 19 Jan 2025 17:52:31 +0100 Subject: [PATCH 016/121] [ie/LBRY] Support signed URLs (#12138) Authored by: seproDev --- yt_dlp/extractor/lbry.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/lbry.py b/yt_dlp/extractor/lbry.py index 0445b7cbfc..7b22f90e9b 100644 --- a/yt_dlp/extractor/lbry.py +++ b/yt_dlp/extractor/lbry.py @@ -310,7 +310,13 @@ class LBRYIE(LBRYBaseIE): if stream_type in self._SUPPORTED_STREAM_TYPES: claim_id, is_live = result['claim_id'], False streaming_url = self._call_api_proxy( - 'get', claim_id, {'uri': uri}, 'streaming url')['streaming_url'] + 'get', claim_id, { + 'uri': uri, + **traverse_obj(parse_qs(url), { + 'signature': ('signature', 0), + 'signature_ts': ('signature_ts', 0), + }), + }, 'streaming url')['streaming_url'] # GET request to v3 API returns original video/audio file if available direct_url = re.sub(r'/api/v\d+/', '/api/v3/', streaming_url) From 68221ecc87c6a3f3515757bac2a0f9674a38e3f2 Mon Sep 17 00:00:00 2001 From: Grabien <60237587+Grabien@users.noreply.github.com> Date: Mon, 20 Jan 2025 01:01:22 +0200 Subject: [PATCH 017/121] [ie/senategov] Fix extractors (#9361) Authored by: Grabien, seproDev Co-authored-by: sepro --- yt_dlp/extractor/senategov.py | 219 ++++++++++++++++++++-------------- 1 file changed, 132 insertions(+), 87 deletions(-) diff --git a/yt_dlp/extractor/senategov.py b/yt_dlp/extractor/senategov.py index cddca09d0c..efcdb79d0c 100644 --- a/yt_dlp/extractor/senategov.py +++ b/yt_dlp/extractor/senategov.py @@ -4,43 +4,12 @@ import urllib.parse from .common import InfoExtractor from ..utils import ( ExtractorError, - parse_qs, - unsmuggle_url, + UnsupportedError, + make_archive_id, + remove_end, + url_or_none, ) - -_COMMITTEES = { - 'ag': ('76440', 'http://ag-f.akamaihd.net'), - 'aging': ('76442', 'http://aging-f.akamaihd.net'), - 'approps': ('76441', 'http://approps-f.akamaihd.net'), - 'arch': ('', 'http://ussenate-f.akamaihd.net'), - 'armed': ('76445', 'http://armed-f.akamaihd.net'), - 'banking': ('76446', 'http://banking-f.akamaihd.net'), - 'budget': ('76447', 'http://budget-f.akamaihd.net'), - 'cecc': ('76486', 'http://srs-f.akamaihd.net'), - 'commerce': ('80177', 'http://commerce1-f.akamaihd.net'), - 'csce': ('75229', 'http://srs-f.akamaihd.net'), - 'dpc': ('76590', 'http://dpc-f.akamaihd.net'), - 'energy': ('76448', 'http://energy-f.akamaihd.net'), - 'epw': ('76478', 'http://epw-f.akamaihd.net'), - 'ethics': ('76449', 'http://ethics-f.akamaihd.net'), - 'finance': ('76450', 'http://finance-f.akamaihd.net'), - 'foreign': ('76451', 'http://foreign-f.akamaihd.net'), - 'govtaff': ('76453', 'http://govtaff-f.akamaihd.net'), - 'help': ('76452', 'http://help-f.akamaihd.net'), - 'indian': ('76455', 'http://indian-f.akamaihd.net'), - 'intel': ('76456', 'http://intel-f.akamaihd.net'), - 'intlnarc': ('76457', 'http://intlnarc-f.akamaihd.net'), - 'jccic': ('85180', 'http://jccic-f.akamaihd.net'), - 'jec': ('76458', 'http://jec-f.akamaihd.net'), - 'judiciary': ('76459', 'http://judiciary-f.akamaihd.net'), - 'rpc': ('76591', 'http://rpc-f.akamaihd.net'), - 'rules': ('76460', 'http://rules-f.akamaihd.net'), - 'saa': ('76489', 'http://srs-f.akamaihd.net'), - 'smbiz': ('76461', 'http://smbiz-f.akamaihd.net'), - 'srs': ('75229', 'http://srs-f.akamaihd.net'), - 'uscc': ('76487', 'http://srs-f.akamaihd.net'), - 'vetaff': ('76462', 'http://vetaff-f.akamaihd.net'), -} +from ..utils.traversal import traverse_obj class SenateISVPIE(InfoExtractor): @@ -53,31 +22,46 @@ class SenateISVPIE(InfoExtractor): 'info_dict': { 'id': 'judiciary031715', 'ext': 'mp4', - 'title': 'Integrated Senate Video Player', + 'title': 'ISVP', 'thumbnail': r're:^https?://.*\.(?:jpg|png)$', + '_old_archive_ids': ['senategov judiciary031715'], }, 'params': { # m3u8 download 'skip_download': True, }, + 'expected_warnings': ['Failed to download m3u8 information'], }, { 'url': 'http://www.senate.gov/isvp/?type=live&comm=commerce&filename=commerce011514.mp4&auto_play=false', 'info_dict': { 'id': 'commerce011514', 'ext': 'mp4', 'title': 'Integrated Senate Video Player', + '_old_archive_ids': ['senategov commerce011514'], }, 'params': { # m3u8 download 'skip_download': True, }, + 'skip': 'This video is not available.', }, { 'url': 'http://www.senate.gov/isvp/?type=arch&comm=intel&filename=intel090613&hc_location=ufi', # checksum differs each time 'info_dict': { 'id': 'intel090613', 'ext': 'mp4', - 'title': 'Integrated Senate Video Player', + 'title': 'ISVP', + '_old_archive_ids': ['senategov intel090613'], + }, + 'expected_warnings': ['Failed to download m3u8 information'], + }, { + 'url': 'https://www.senate.gov/isvp/?auto_play=false&comm=help&filename=help090920&poster=https://www.help.senate.gov/assets/images/video-poster.png&stt=950', + 'info_dict': { + 'id': 'help090920', + 'ext': 'mp4', + 'title': 'ISVP', + 'thumbnail': 'https://www.help.senate.gov/assets/images/video-poster.png', + '_old_archive_ids': ['senategov help090920'], }, }, { # From http://www.c-span.org/video/?96791-1 @@ -85,60 +69,81 @@ class SenateISVPIE(InfoExtractor): 'only_matching': True, }] - def _real_extract(self, url): - url, smuggled_data = unsmuggle_url(url, {}) + _COMMITTEES = { + 'ag': ('76440', 'https://ag-f.akamaihd.net', '2036803', 'agriculture'), + 'aging': ('76442', 'https://aging-f.akamaihd.net', '2036801', 'aging'), + 'approps': ('76441', 'https://approps-f.akamaihd.net', '2036802', 'appropriations'), + 'arch': ('', 'https://ussenate-f.akamaihd.net', '', 'arch'), + 'armed': ('76445', 'https://armed-f.akamaihd.net', '2036800', 'armedservices'), + 'banking': ('76446', 'https://banking-f.akamaihd.net', '2036799', 'banking'), + 'budget': ('76447', 'https://budget-f.akamaihd.net', '2036798', 'budget'), + 'cecc': ('76486', 'https://srs-f.akamaihd.net', '2036782', 'srs_cecc'), + 'commerce': ('80177', 'https://commerce1-f.akamaihd.net', '2036779', 'commerce'), + 'csce': ('75229', 'https://srs-f.akamaihd.net', '2036777', 'srs_srs'), + 'dpc': ('76590', 'https://dpc-f.akamaihd.net', '', 'dpc'), + 'energy': ('76448', 'https://energy-f.akamaihd.net', '2036797', 'energy'), + 'epw': ('76478', 'https://epw-f.akamaihd.net', '2036783', 'environment'), + 'ethics': ('76449', 'https://ethics-f.akamaihd.net', '2036796', 'ethics'), + 'finance': ('76450', 'https://finance-f.akamaihd.net', '2036795', 'finance_finance'), + 'foreign': ('76451', 'https://foreign-f.akamaihd.net', '2036794', 'foreignrelations'), + 'govtaff': ('76453', 'https://govtaff-f.akamaihd.net', '2036792', 'hsgac'), + 'help': ('76452', 'https://help-f.akamaihd.net', '2036793', 'help'), + 'indian': ('76455', 'https://indian-f.akamaihd.net', '2036791', 'indianaffairs'), + 'intel': ('76456', 'https://intel-f.akamaihd.net', '2036790', 'intelligence'), + 'intlnarc': ('76457', 'https://intlnarc-f.akamaihd.net', '', 'internationalnarcoticscaucus'), + 'jccic': ('85180', 'https://jccic-f.akamaihd.net', '2036778', 'jccic'), + 'jec': ('76458', 'https://jec-f.akamaihd.net', '2036789', 'jointeconomic'), + 'judiciary': ('76459', 'https://judiciary-f.akamaihd.net', '2036788', 'judiciary'), + 'rpc': ('76591', 'https://rpc-f.akamaihd.net', '', 'rpc'), + 'rules': ('76460', 'https://rules-f.akamaihd.net', '2036787', 'rules'), + 'saa': ('76489', 'https://srs-f.akamaihd.net', '2036780', 'srs_saa'), + 'smbiz': ('76461', 'https://smbiz-f.akamaihd.net', '2036786', 'smallbusiness'), + 'srs': ('75229', 'https://srs-f.akamaihd.net', '2031966', 'srs_srs'), + 'uscc': ('76487', 'https://srs-f.akamaihd.net', '2036781', 'srs_uscc'), + 'vetaff': ('76462', 'https://vetaff-f.akamaihd.net', '2036785', 'veteransaffairs'), + } + def _real_extract(self, url): qs = urllib.parse.parse_qs(self._match_valid_url(url).group('qs')) - if not qs.get('filename') or not qs.get('type') or not qs.get('comm'): + if not qs.get('filename') or not qs.get('comm'): raise ExtractorError('Invalid URL', expected=True) - - video_id = re.sub(r'.mp4$', '', qs['filename'][0]) + filename = qs['filename'][0] + video_id = remove_end(filename, '.mp4') webpage = self._download_webpage(url, video_id) + committee = qs['comm'][0] - if smuggled_data.get('force_title'): - title = smuggled_data['force_title'] - else: - title = self._html_extract_title(webpage) - poster = qs.get('poster') - thumbnail = poster[0] if poster else None - - video_type = qs['type'][0] - committee = video_type if video_type == 'arch' else qs['comm'][0] - - stream_num, domain = _COMMITTEES[committee] + stream_num, stream_domain, stream_id, msl3 = self._COMMITTEES[committee] + urls_alternatives = [f'https://www-senate-gov-media-srs.akamaized.net/hls/live/{stream_id}/{committee}/{filename}/master.m3u8', + f'https://www-senate-gov-msl3archive.akamaized.net/{msl3}/{filename}_1/master.m3u8', + f'{stream_domain}/i/{filename}_1@{stream_num}/master.m3u8', + f'{stream_domain}/i/{filename}.mp4/master.m3u8'] formats = [] - if video_type == 'arch': - filename = video_id if '.' in video_id else video_id + '.mp4' - m3u8_url = urllib.parse.urljoin(domain, 'i/' + filename + '/master.m3u8') - formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4', m3u8_id='m3u8') - else: - hdcore_sign = 'hdcore=3.1.0' - url_params = (domain, video_id, stream_num) - f4m_url = f'%s/z/%s_1@%s/manifest.f4m?{hdcore_sign}' % url_params - m3u8_url = '{}/i/{}_1@{}/master.m3u8'.format(*url_params) - for entry in self._extract_f4m_formats(f4m_url, video_id, f4m_id='f4m'): - # URLs without the extra param induce an 404 error - entry.update({'extra_param_to_segment_url': hdcore_sign}) - formats.append(entry) - for entry in self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4', m3u8_id='m3u8'): - mobj = re.search(r'(?P(?:-p|-b)).m3u8', entry['url']) - if mobj: - entry['format_id'] += mobj.group('tag') - formats.append(entry) + subtitles = {} + for video_url in urls_alternatives: + formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, video_id, ext='mp4', fatal=False) + if formats: + break return { 'id': video_id, - 'title': title, + 'title': self._html_extract_title(webpage), 'formats': formats, - 'thumbnail': thumbnail, + 'subtitles': subtitles, + 'thumbnail': traverse_obj(qs, ('poster', 0, {url_or_none})), + '_old_archive_ids': [make_archive_id(SenateGovIE, video_id)], } class SenateGovIE(InfoExtractor): _IE_NAME = 'senate.gov' - _VALID_URL = r'https?:\/\/(?:www\.)?(help|appropriations|judiciary|banking|armed-services|finance)\.senate\.gov' + _SUBDOMAIN_RE = '|'.join(map(re.escape, ( + 'agriculture', 'aging', 'appropriations', 'armed-services', 'banking', + 'budget', 'commerce', 'energy', 'epw', 'finance', 'foreign', 'help', + 'intelligence', 'inaugural', 'judiciary', 'rules', 'sbc', 'veterans', + ))) + _VALID_URL = rf'https?://(?:www\.)?(?:{_SUBDOMAIN_RE})\.senate\.gov' _TESTS = [{ 'url': 'https://www.help.senate.gov/hearings/vaccines-saving-lives-ensuring-confidence-and-protecting-public-health', 'info_dict': { @@ -147,6 +152,9 @@ class SenateGovIE(InfoExtractor): 'title': 'Vaccines: Saving Lives, Ensuring Confidence, and Protecting Public Health', 'description': 'The U.S. Senate Committee on Health, Education, Labor & Pensions', 'ext': 'mp4', + 'age_limit': 0, + 'thumbnail': 'https://www.help.senate.gov/assets/images/sharelogo.jpg', + '_old_archive_ids': ['senategov help090920'], }, 'params': {'skip_download': 'm3u8'}, }, { @@ -156,8 +164,12 @@ class SenateGovIE(InfoExtractor): 'display_id': 'watch?hearingid=B8A25434-5056-A066-6020-1F68CB75F0CD', 'title': 'Review of the FY2019 Budget Request for the U.S. Army', 'ext': 'mp4', + 'age_limit': 0, + 'thumbnail': 'https://www.appropriations.senate.gov/themes/appropriations/images/video-poster-flash-fit.png', + '_old_archive_ids': ['senategov appropsA051518'], }, 'params': {'skip_download': 'm3u8'}, + 'expected_warnings': ['Failed to download m3u8 information'], }, { 'url': 'https://www.banking.senate.gov/hearings/21st-century-communities-public-transportation-infrastructure-investment-and-fast-act-reauthorization', 'info_dict': { @@ -166,32 +178,65 @@ class SenateGovIE(InfoExtractor): 'title': '21st Century Communities: Public Transportation Infrastructure Investment and FAST Act Reauthorization', 'description': 'The Official website of The United States Committee on Banking, Housing, and Urban Affairs', 'ext': 'mp4', + 'thumbnail': 'https://www.banking.senate.gov/themes/banking/images/sharelogo.jpg', + 'age_limit': 0, + '_old_archive_ids': ['senategov banking041521'], }, 'params': {'skip_download': 'm3u8'}, + }, { + 'url': 'https://www.agriculture.senate.gov/hearings/hemp-production-and-the-2018-farm-bill', + 'only_matching': True, + }, { + 'url': 'https://www.aging.senate.gov/hearings/the-older-americans-act-the-local-impact-of-the-law-and-the-upcoming-reauthorization', + 'only_matching': True, + }, { + 'url': 'https://www.budget.senate.gov/hearings/improving-care-lowering-costs-achieving-health-care-efficiency', + 'only_matching': True, + }, { + 'url': 'https://www.commerce.senate.gov/2024/12/communications-networks-safety-and-security', + 'only_matching': True, + }, { + 'url': 'https://www.energy.senate.gov/hearings/2024/2/full-committee-hearing-to-examine', + 'only_matching': True, + }, { + 'url': 'https://www.epw.senate.gov/public/index.cfm/hearings?ID=F63083EA-2C13-498C-B548-341BED68C209', + 'only_matching': True, + }, { + 'url': 'https://www.foreign.senate.gov/hearings/american-diplomacy-and-global-leadership-review-of-the-fy25-state-department-budget-request', + 'only_matching': True, + }, { + 'url': 'https://www.intelligence.senate.gov/hearings/foreign-threats-elections-2024-%E2%80%93-roles-and-responsibilities-us-tech-providers', + 'only_matching': True, + }, { + 'url': 'https://www.inaugural.senate.gov/52nd-inaugural-ceremonies/', + 'only_matching': True, + }, { + 'url': 'https://www.rules.senate.gov/hearings/02/07/2023/business-meeting', + 'only_matching': True, + }, { + 'url': 'https://www.sbc.senate.gov/public/index.cfm/hearings?ID=5B13AA6B-8279-45AF-B54B-94156DC7A2AB', + 'only_matching': True, + }, { + 'url': 'https://www.veterans.senate.gov/2024/5/frontier-health-care-ensuring-veterans-access-no-matter-where-they-live', + 'only_matching': True, }] def _real_extract(self, url): display_id = self._generic_id(url) webpage = self._download_webpage(url, display_id) - parse_info = parse_qs(self._search_regex( - r'