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

Code before:
                ..., {extract_attributes}, 'data-url', {str}, filter))
        ]


class VrSquareChannelIE(VrSquarePlaylistBaseIE):
    IE_NAME = 'vrsquare:channel'

    _VALID_URL = r'https?://livr\.jp/channel/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://livr.jp/channel/H372648599',
        'info_dict': {
            'id': 'H372648599',
            'title': 'AKB48＋チャンネル',
        },
        'playlist_mincount': 502,
    }]

    def _entries(self, playlist_id):
        for page in itertools.count(1):
            ajax = self._download_json(
                f'{self._BASE_URL}/ajax/channel/{playlist_id}',
                playlist_id, query={'p': page},
            )
            yield from self._fetch_vids(ajax, ('contents_render_list', ...))
            if not ajax['hasNext']:
                break

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        webpage = self._download_webpage(url, playlist_id)

        return self.playlist_result(
            self._entries(playlist_id), playlist_id, self._html_search_meta('og:title', webpage))


class VrSquareSearchIE(VrSquarePlaylistBaseIE):
    IE_NAME = 'vrsquare:search'

    _VALID_URL = r'https?://livr\.jp/web-search'
    _TESTS = [{
        'url': 'https://livr.jp/web-search?w=%23%E5%B0%8F%E6%A0%97%E6%9C%89%E4%BB%A5',
        'info_dict': {
            'id': '#小栗有以',
            'title': '#小栗有以',
        },
        'playlist_mincount': 70,
    }]

    def _entries(self, query):
        for page in itertools.count(1):
            ajax = self._download_json(

Review comment (suggestion):
I think `_entries` can be generalized and moved into the baseclass. I have an impl written locally, will push

Code after:
        ):
            yield self.url_result(
                f'{self._BASE_URL}/contents/{url_path.removeprefix("/contents/")}', VrSquareIE)

    def _entries(self, path, display_id, query=None):
        for page in itertools.count(1):
            ajax = self._download_json(
                f'{self._BASE_URL}{path}', display_id,
                f'Downloading playlist JSON page {page}',
                query={'p': page, **(query or {})})
            yield from self._fetch_vids(ajax, ('contents_render_list', ...))
            if not traverse_obj(ajax, (('has_next', 'hasNext'), {bool}, any)):
                break


class VrSquareChannelIE(VrSquarePlaylistBaseIE):
    IE_NAME = 'vrsquare:channel'

    _VALID_URL = r'https?://livr\.jp/channel/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://livr.jp/channel/H372648599',
        'info_dict': {
            'id': 'H372648599',
            'title': 'AKB48＋チャンネル',
        },
        'playlist_mincount': 502,
    }]

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        webpage = self._download_webpage(url, playlist_id)

        return self.playlist_result(
            self._entries(f'/ajax/channel/{playlist_id}', playlist_id),
            playlist_id, self._html_search_meta('og:title', webpage))


class VrSquareSearchIE(VrSquarePlaylistBaseIE):
    IE_NAME = 'vrsquare:search'

    _VALID_URL = r'https?://livr\.jp/web-search/?\?(?:[^#]+&)?w=[^#]+'
    _TESTS = [{
        'url': 'https://livr.jp/web-search?w=%23%E5%B0%8F%E6%A0%97%E6%9C%89%E4%BB%A5',
        'info_dict': {
            'id': '#小栗有以',
        },
        'playlist_mincount': 60,
    }]

    def _real_extract(self, url):
        search_query = parse_qs(url)['w'][0]