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

Code before:
            if is_billennium_tabs:
                mobj = re.search(
                    r'<div[^>]+class=["\']next["\'][^>]*>\s*<a[^>]+onclick=(["\'])TB_LoadTab\((?P<params>(?:(?!\1).)+)\);\1',
                    pagination)
                if not mobj:
                    break
                params = self._parse_json('[' + js_to_json(unescapeHTML(mobj.group('params'))) + ']', category_id)
                tab_content = self._download_json(
                    'https://www.polskieradio.pl/CMS/TemplateBoxesManagement/TemplateBoxTabContent.aspx/GetTabContent',
                    category_id, 'Downloading page %s' % page_num, data=json.dumps({
                        'tabId': params[1],
                        'boxInstanceId': params[0],
                        'sectionId': params[3],
                        'categoryId': params[4],
                        'categoryType': params[2],
                        'subjectIds': params[6],
                        'tagIndexId': params[7],
                        'queryString': params[8],
                        'name': params[9],
                        'pageNumber': page_num,
                        'pagerMode': params[5],
                        'openArticlesInParentTemplate': params[10],
                        'idSectionFromUrl': params[11],
                        'maxDocumentAge': params[12],
                        'showCategoryForArticle': params[13],
                    }).encode('utf-8'), headers={'content-type': 'application/json'})
                content = tab_content['d']['Content']
                pagination = tab_content['d']['PagerContent']
            elif is_post_back:
                mobj = re.search(
                    r'onclick=(["\'])__doPostBack\((["\'])(?P<target>[\w$]+)\2\s*,\s*(["\'])Next\4',
                    content)
                if not mobj:
                    break
                aspnetform = self._hidden_inputs(content)
                content = self._download_webpage(
                    url, category_id, 'Downloading page %s' % page_num,
                    data=urlencode({
                        **aspnetform,
                        '__EVENTTARGET': mobj.group('target'),
                        '__EVENTARGUMENT': 'Next',
                    }).encode('utf-8'))
            else:
                mobj = re.search(
                    r'<div[^>]+class=["\']next["\'][^>]*>\s*<a[^>]+href=(["\'])(?P<url>(?:(?!\1).)+)\1',
                    content)
                if not mobj:
                    break
                next_url = compat_urlparse.urljoin(url, mobj.group('url'))
                content = self._download_webpage(
                    next_url, category_id, 'Downloading page %s' % page_num)

Review comment (suggestion):
```suggestion
                tab_content = self._download_json(
                    'https://www.polskieradio.pl/CMS/TemplateBoxesManagement/TemplateBoxTabContent.aspx/GetTabContent',
                    category_id, f'Downloading page {page_num}',
                    headers={'content-type': 'application/json'}, data=json.dumps({
                        'pageNumber': page_num,
                        **dict(zip((
                            'boxInstanceId', 'tabId', 'categoryType', 'sectionId', 'categoryId', 'pagerMode',
                            'subjectIds', 'tagIndexId', 'queryString', 'name', 'openArticlesInParentTemplate',
                            'idSectionFromUrl', 'maxDocumentAge', 'showCategoryForArticle',
                        ), params),
                    }).encode())
```
would be way cleaner imo

Code after:
            'id': '175458',
            'title': 'Krzysztof Dziuba',
        },
        'playlist_mincount': 420,
    }, {
        'url': 'http://www.polskieradio.pl/8,Dwojka/196,Publicystyka',
        'only_matching': True,
    }]

    @classmethod
    def suitable(cls, url):
        return False if PolskieRadioLegacyIE.suitable(url) else super().suitable(url)

    def _entries(self, url, page, category_id):
        content = page
        is_billennium_tabs = 'onclick="TB_LoadTab(' in page
        is_post_back = 'onclick="__doPostBack(' in page
        pagination = page if is_billennium_tabs else None
        for page_num in itertools.count(2):
            for a_entry, entry_id in re.findall(
                    r'(?s)<article[^>]+>.*?(<a[^>]+href=["\'](?:(?:https?)?://[^/]+)?/\d+/\d+/Artykul/(\d+)[^>]+>).*?</article>',
                    content):
                entry = extract_attributes(a_entry)
                if entry.get('href'):
                    yield self.url_result(
                        urljoin(url, entry['href']), PolskieRadioLegacyIE, entry_id, entry.get('title'))
            for a_entry in re.findall(r'<span data-media=({[^ ]+})', content):
                yield traverse_obj(self._parse_json(a_entry, category_id), {
                    'url': 'file',
                    'id': 'uid',
                    'duration': 'length',
                    'title': ('title', {urllib.parse.unquote}),
                    'description': ('desc', {urllib.parse.unquote}),
                })
            if is_billennium_tabs:
                params = self._search_json(
                    r'<div[^>]+class=["\']next["\'][^>]*>\s*<a[^>]+onclick=["\']TB_LoadTab\(',
                    pagination, 'next page params', category_id, default=None, close_objects=1,
                    contains_pattern='.+', transform_source=lambda x: '[%s' % js_to_json(unescapeHTML(x)))
                if not params:
                    break
                tab_content = self._download_json(
                    'https://www.polskieradio.pl/CMS/TemplateBoxesManagement/TemplateBoxTabContent.aspx/GetTabContent',
                    category_id, f'Downloading page {page_num}', headers={'content-type': 'application/json'},
                    data=json.dumps(dict(zip((
                        'boxInstanceId', 'tabId', 'categoryType', 'sectionId', 'categoryId', 'pagerMode',
                        'subjectIds', 'tagIndexId', 'queryString', 'name', 'openArticlesInParentTemplate',
                        'idSectionFromUrl', 'maxDocumentAge', 'showCategoryForArticle', 'pageNumber'
                    ), params))).encode())['d']
                content, pagination = tab_content['Content'], tab_content.get('PagerContent')
            elif is_post_back: