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

Code before:
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    extract_attributes,
    get_element_by_class,
    str_or_none,
)


class SteamIE(InfoExtractor):
    _VALID_URL = r'''(?x)
        https?://(?:store\.steampowered|steamcommunity)\.com/
            (?:agecheck/)?
            (?P<urltype>video|app)/ #If the page is only for videos or for a game
            (?P<gameID>\d+)/?
            (?P<videoID>\d*)(?P<extra>\??) # For urltype == video we sometimes get the videoID
        |
        https?://(?:www\.)?steamcommunity\.com/sharedfiles/filedetails/\?id=(?P<fileID>[0-9]+)
    '''
    _VIDEO_PAGE_TEMPLATE = 'http://store.steampowered.com/video/%s/'
    _AGECHECK_TEMPLATE = 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
    _TESTS = [{
        'url': 'http://store.steampowered.com/video/105600/',
        'playlist': [
            {
                '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,
        },
    }, {

Review comment (refactor):
`_TESTS` can be more concise
```diff
@@ -23,40 +31,18 @@ class SteamIE(InfoExtractor):
     _AGECHECK_TEMPLATE = 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
     _TESTS = [{
         'url': 'http://store.steampowered.com/video/105600/',
-        'playlist': [
-            {
-                '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,
-        },
+        'playlist_mincount': 3,
     }, {
         'url': 'https://store.steampowered.com/app/271590/Grand_Theft_Auto_V/',
         'info_dict': {
             'id': '271590',
-            'title': 'Grand Theft Auto V',
+            'title': 'Grand Theft Auto V Legacy',
         },
-        'playlist_count': 23,
+        'playlist_mincount': 26,
     }]

     def _real_extract(self, url):
```

Code after:

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    clean_html,
    extract_attributes,
    str_or_none,
    url_or_none,
)
from ..utils.traversal import (
    find_element,
    find_elements,
    traverse_obj,
    trim_str,
)


class SteamIE(InfoExtractor):
    _VALID_URL = r'''(?x)
        https?://(?:store\.steampowered|steamcommunity)\.com/
            (?:agecheck/)?
            (?P<urltype>video|app)/ #If the page is only for videos or for a game
            (?P<gameID>\d+)/?
            (?P<videoID>\d*)(?P<extra>\??) # For urltype == video we sometimes get the videoID
        |
        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