Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/senategov.py (Python)

Code before:
        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 = []
        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,
            'formats': formats,
            'subtitles': subtitles,
            'thumbnail': thumbnail,
            '_old_archive_ids': [make_archive_id('SenateGov', video_id)],
        }


class SenateGovIE(InfoExtractor):
    _IE_NAME = 'senate.gov'
    _VALID_URL = r'https?:\/\/(?:www\.)?(agriculture|aging|appropriations|armed-services|banking|budget|commerce|energy|epw|finance|foreign|help|intelligence|inaugural|judiciary|rules|sbc|veterans)\.senate\.gov'
    _TESTS = [{
        'url': 'https://www.help.senate.gov/hearings/vaccines-saving-lives-ensuring-confidence-and-protecting-public-health',
        'info_dict': {
            'id': 'help090920',
            'display_id': 'vaccines-saving-lives-ensuring-confidence-and-protecting-public-health',
            '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'},
    }, {
        'url': 'https://www.appropriations.senate.gov/hearings/watch?hearingid=B8A25434-5056-A066-6020-1F68CB75F0CD',
        'info_dict': {
            'id': 'appropsA051518',
            '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'},

Review comment (security):
Maybe `_VALID_URL` should be more restrictive to distinguish between the list of hearings and the hearing page. 

Ex. `https://www.energy.senate.gov/hearings` is a list of hearings whereas `https://www.energy.senate.gov/hearings/2025/1/hearing-to-consider-the-nomination-of-the-honorable-doug-burgum-to-be-secretary-of-the-interior` is a single hearing page.

I plan to open a new issue to process the hearing list page as a playlist / channel. Not sure if these changes are needed on this issue or can be done in the future.

Code after:
            formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, video_id, ext='mp4', fatal=False)
            if formats:
                break

        return {
            'id': video_id,
            'title': self._html_extract_title(webpage),
            'formats': formats,
            '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'
    _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': {
            'id': 'help090920',
            'display_id': 'vaccines-saving-lives-ensuring-confidence-and-protecting-public-health',
            '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'},
    }, {
        'url': 'https://www.appropriations.senate.gov/hearings/watch?hearingid=B8A25434-5056-A066-6020-1F68CB75F0CD',
        'info_dict': {
            'id': 'appropsA051518',
            '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': {