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 01/11] [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 @@ def _parse_video_info(self, video_info, video_id=None): 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 02/11] [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 @@ parse_iso8601, str_or_none, try_get, + update_url_query, url_or_none, urljoin, ) @@ -171,6 +172,8 @@ def call_playback_api(item, query=None): 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 03/11] [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 @@ def _real_extract(self, url): 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 04/11] [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 @@ 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, }] + _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): - url, smuggled_data = unsmuggle_url(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'