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

Code before:
    _TESTS = [{
        'url': 'https://volej.tv/kategorie/chance-cesky-pohar',
        'info_dict': {
            'id': 'chance-cesky-pohar',
            'title': 'Chance Český pohár',
        },
        'playlist_mincount': 30,
    }]
    _PAGE_SIZE = 10

    def _get_page(self, playlist_id, page):
        return self._call_api(f'match/by-category-id-paginated/{playlist_id}', playlist_id,
                              query={'page': page + 1, 'take': self._PAGE_SIZE, 'order': 'DESC'})

    def _get_category(self, playlist_id):
        categories = self._call_api('category', playlist_id)
        for category in categories:
            if category['slug'] == str(playlist_id):
                return category['id'], category['title']

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        category_id, title = self._get_category(playlist_id)
        first_page_data = self._get_page(category_id, 0)
        total_pages = traverse_obj(first_page_data, ('meta', 'pageCount', {int}))
        return self.playlist_result(InAdvancePagedList(
            functools.partial(self._entries, category_id, first_page_data),
            total_pages, self._PAGE_SIZE), playlist_id, title)


Review comment (suggestion):
let's `require` the page count (import `require` from `..utils.traversal`)
```suggestion
        total_pages = traverse_obj(first_page_data, ('meta', 'pageCount', {int}, {require('page count')}))

        return self.playlist_result(InAdvancePagedList(
```

Code after:
        'info_dict': {
            'id': '1173',
            'title': 'VK Jihostroj České Budějovice',
        },
        'playlist_mincount': 30,
    }]
    _API_FILTER = 'by-team-id-paginated'
    _PAGE_SIZE = 6

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        title = self._call_api(f'team/show/{playlist_id}', playlist_id)['title']
        first_page_data = self._get_page(playlist_id, 0)
        total_pages = traverse_obj(first_page_data, ('meta', 'pageCount', {int}, {require('page count')}))
        return self.playlist_result(InAdvancePagedList(
            functools.partial(self._entries, playlist_id, first_page_data),
            total_pages, self._PAGE_SIZE), playlist_id, title)


class VolejTVCategoryPlaylistIE(VolejTVPlaylistBaseIE):
    IE_NAME = 'volejtv:category'
    _VALID_URL = r'https?://volej\.tv/kategorie/(?P<id>[^/$?]+)'
    _TESTS = [{
        'url': 'https://volej.tv/kategorie/chance-cesky-pohar',
        'info_dict': {
            'id': 'chance-cesky-pohar',
            'title': 'Chance Český pohár',
        },
        'playlist_mincount': 30,
    }]
    _API_FILTER = 'by-category-id-paginated'
    _PAGE_SIZE = 10

    def _get_category(self, playlist_id):
        categories = self._call_api('category', playlist_id)
        for category in traverse_obj(categories, (lambda _, v: v['slug'] and v['id'] and v['title'])):
            if category['slug'] == playlist_id:
                return category['id'], category['title']

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        category_id, title = self._get_category(playlist_id)
        first_page_data = self._get_page(category_id, 0)
        total_pages = traverse_obj(first_page_data, ('meta', 'pageCount', {int}, {require('page count')}))
        return self.playlist_result(InAdvancePagedList(
            functools.partial(self._entries, category_id, first_page_data),
            total_pages, self._PAGE_SIZE), playlist_id, title)