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

Code before:
            'channel': 'hololive ホロライブ - VTuber Group',
            'categories': ['Music'],
            'uploader': 'hololive ホロライブ - VTuber Group',
            'channel_follower_count': int,
            'uploader_id': 'UCJFZiqLMntJufDCHc6bQixg',
            'availability': 'public',
            'thumbnail': 'https://i.ytimg.com/vi_webp/9kQ2GtvDV3s/maxresdefault.webp',
            'duration': 263,
            'like_count': int,
        },
    }, ]

    def _real_extract(self, url):
        return self.url_result(f'https://www.youtube.com/watch?v={self._match_id(url)}', YoutubeIE)


class HolodexPlaylistIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.|staging\.)?holodex\.net/(?:watch/[^\?]\?playlist=|api/v2/playlist/)(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://holodex.net/api/v2/playlist/239',
        'info_dict': {
            'id': '239',
            'title': 'Songs/Videos that made fall into the rabbit hole (from my google activity history)',
        },
        'playlist_count': 14,
    }]

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        data = self._download_json(f'https://holodex.net/api/v2/playlist/{playlist_id}', playlist_id)
        return self.playlist_from_matches(
            traverse_obj(data, ('videos', ..., 'id')), playlist_id, data.get('name'), ie=YoutubeIE)


Review comment (suggestion):
Add a test for the other URL pattern. Also add one test (either video/playlist) for `staging.`

only_matching tests are fine for these

Code after:
            'upload_date': '20200406',
            'uploader_url': 'http://www.youtube.com/channel/UCJFZiqLMntJufDCHc6bQixg',
            'view_count': int,
            'channel': 'hololive ホロライブ - VTuber Group',
            'categories': ['Music'],
            'uploader': 'hololive ホロライブ - VTuber Group',
            'channel_follower_count': int,
            'uploader_id': 'UCJFZiqLMntJufDCHc6bQixg',
            'availability': 'public',
            'thumbnail': 'https://i.ytimg.com/vi_webp/9kQ2GtvDV3s/maxresdefault.webp',
            'duration': 263,
            'like_count': int,
        },
    }, {
        'url': 'https://holodex.net/api/v2/playlist/239',
        'info_dict': {
            'id': '239',
            'title': 'Songs/Videos that made fall into the rabbit hole (from my google activity history)',
        },
        'playlist_count': 14,
    }, {
        'url': 'https://holodex.net/watch/_m2mQyaofjI?foo=bar&playlist=69',
        'info_dict': {
            'id': '69',
            'title': '拿著金斧頭的藍髮大姊姊'
        },
        'playlist_count': 3,
    }, {
        'url': 'https://holodex.net/watch/_m2mQyaofjI?playlist=69',
        'info_dict': {
            'id': '_m2mQyaofjI',
            'ext': 'mp4',
            'playable_in_embed': True,
            'like_count': int,
            'uploader': 'Ernst / エンスト',
            'duration': 11,
            'uploader_url': 'http://www.youtube.com/channel/UCqSX4PPZY0cyetqKVY_wRVA',
            'categories': ['Entertainment'],
            'title': '【星街すいせい】星街向你獻上晚安',
            'upload_date': '20210705',
            'description': 'md5:8b8ffb157bae77f2d109021a0b577d4a',
            'channel': 'Ernst / エンスト',
            'channel_id': 'UCqSX4PPZY0cyetqKVY_wRVA',
            'channel_follower_count': int,
            'view_count': int,
            'tags': [],
            'live_status': 'not_live',
            'channel_url': 'https://www.youtube.com/channel/UCqSX4PPZY0cyetqKVY_wRVA',
            'availability': 'public',
            'thumbnail': 'https://i.ytimg.com/vi_webp/_m2mQyaofjI/maxresdefault.webp',
            'age_limit': 0,