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

Code before:
                'md5': 'e800bd0baf47286d8b434d07b357247e',
                'info_dict': {
                    'id': '256785003',
                    'ext': 'mp4',
                    'title': 'Terraria video 256785003',
                    'thumbnail': r're:^https?://[^/]*steamstatic\.com',
                },
            },
            {
                'md5': '9612ee058ebd645371c5ddd69adb310f',
                'info_dict': {
                    'id': '2040428',
                    'ext': 'mp4',
                    'title': 'Terraria video 2040428',
                    'thumbnail': r're:^https?://[^/]*steamstatic\.com',
                },
            },
        ],
        'info_dict': {
            'id': '105600',
            'title': 'Terraria',
        },
        'params': {
            'playlistend': 2,
        },
        'expected_warnings': ['Unknown MIME type image/avif in DASH manifest'],
    }, {
        'url': 'https://store.steampowered.com/app/271590/Grand_Theft_Auto_V/',
        'info_dict': {
            'id': '271590',
            'title': 'Grand Theft Auto V',
        },
        'playlist_count': 23,
    }]

    def _real_extract(self, url):
        m = self._match_valid_url(url)
        file_id = m.group('fileID')
        if file_id:
            video_url = url
            playlist_id = file_id
        else:
            game_id = m.group('gameID')
            playlist_id = game_id
            video_url = self._VIDEO_PAGE_TEMPLATE % playlist_id

        self._set_cookie('steampowered.com', 'wants_mature_content', '1')
        self._set_cookie('steampowered.com', 'birthtime', '944006401')
        self._set_cookie('steampowered.com', 'lastagecheckage', '1-0-2000')

        webpage = self._download_webpage(video_url, playlist_id)

Review comment (refactor):
already resolved by [#14016](https://github.com/yt-dlp/yt-dlp/pull/14016)
please merge master and remove this line
```suggestion
```

Code after:
        https?://(?:www\.)?steamcommunity\.com/sharedfiles/filedetails/\?id=(?P<fileID>[0-9]+)
    '''
    _VIDEO_PAGE_TEMPLATE = 'https://store.steampowered.com/video/%s/'
    _AGECHECK_TEMPLATE = 'https://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
    _TESTS = [{
        'url': 'https://store.steampowered.com/video/105600/',
        'info_dict': {
            'id': '105600',
            'title': 'Terraria',
        },
        'playlist_mincount': 3,
    }, {
        'url': 'https://store.steampowered.com/app/271590/Grand_Theft_Auto_V/',
        'info_dict': {
            'id': '271590',
            'title': 'Grand Theft Auto V Legacy',
        },
        'playlist_mincount': 26,
    }]

    def _real_extract(self, url):
        m = self._match_valid_url(url)
        file_id = m.group('fileID')
        if file_id:
            video_url = url
            playlist_id = file_id
        else:
            game_id = m.group('gameID')
            playlist_id = game_id
            video_url = self._VIDEO_PAGE_TEMPLATE % playlist_id

        self._set_cookie('steampowered.com', 'wants_mature_content', '1')
        self._set_cookie('steampowered.com', 'birthtime', '944006401')
        self._set_cookie('steampowered.com', 'lastagecheckage', '1-0-2000')

        webpage = self._download_webpage(video_url, playlist_id)

        if re.search('<div[^>]+>Please enter your birth date to continue:</div>', webpage) is not None:
            video_url = self._AGECHECK_TEMPLATE % playlist_id
            self.report_age_confirmation()
            webpage = self._download_webpage(video_url, playlist_id)

        app_name = traverse_obj(webpage, ({find_element(cls='apphub_AppName')}, {clean_html}))
        entries = []
        for data_prop in traverse_obj(webpage, (
            {find_elements(cls='highlight_player_item highlight_movie', html=True)},
            ..., {extract_attributes}, 'data-props', {json.loads}, {dict},
        )):
            formats = []
            if hls_manifest := traverse_obj(data_prop, ('hlsManifest', {url_or_none})):
                formats.extend(self._extract_m3u8_formats(