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

Code before:
    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(
                f'{self._BASE_URL}/ajax/web-search',
                query, query={'p': page, 'w': query},
            )
            yield from self._fetch_vids(ajax, ('contents_render_list', ...))
            if not ajax['has_next']:
                break

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

        return self.playlist_result(self._entries(query), query, query)


class VrSquareSectionIE(VrSquarePlaylistBaseIE):
    IE_NAME = 'vrsquare:section'

    _VALID_URL = r'https?://livr\.jp/(?:category|headline)/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://livr.jp/category/C133936275',
        'info_dict': {
            'id': 'C133936275',
            'title': 'そこ曲がったら、櫻坂？VR',
        },
        'playlist_mincount': 308,
    }, {
        'url': 'https://livr.jp/headline/A296449604',
        'info_dict': {
            'id': 'A296449604',
            'title': 'AKB48 アフターVR',
        },
        'playlist_mincount': 22,
    }]

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

Review comment (refactor):
don't duplicate the playlist id for playlist title
```suggestion
        return self.playlist_result(self._entries(query), query)
```

Code after:

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]

        return self.playlist_result(
            self._entries('/ajax/web-search', search_query, {'w': search_query}), search_query)


class VrSquareSectionIE(VrSquarePlaylistBaseIE):
    IE_NAME = 'vrsquare:section'

    _VALID_URL = r'https?://livr\.jp/(?:category|headline)/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://livr.jp/category/C133936275',
        'info_dict': {
            'id': 'C133936275',
            'title': 'そこ曲がったら、櫻坂？VR',
        },
        'playlist_mincount': 308,
    }, {
        'url': 'https://livr.jp/headline/A296449604',
        'info_dict': {
            'id': 'A296449604',
            'title': 'AKB48 アフターVR',
        },
        'playlist_mincount': 22,
    }]

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

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