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

Code before:
            'ext': 'mp4',
            'upload_date': '20250809',
            'thumbnail': 'https://cdn.cms.mtv.hu/wp-content/uploads/sites/4/2025/08/Idojaras-jelentes-35-1.jpg',
        },
    }, {
        # hirado - subcategory
        'url': 'https://hirado.hu/belfold/video/2025/08/09/nyitott-porta-napok-2025/',
        'info_dict': {
            'id': '8590581',
            'title': 'Nyitott Porta Napok 2025',
            'display_id': 'nyitott-porta-napok-2025',
            'ext': 'mp4',
            'upload_date': '20250809',
            'thumbnail': 'https://cdn.cms.mtv.hu/wp-content/uploads/sites/4/2025/08/vlcsnap-2025-08-09-10h35m01s887.jpg',
        },
    }]

    def _real_extract(self, url):
        mobj = self._match_valid_url(url)
        display_id = mobj.group('id')
        webpage = self._download_webpage(url, display_id)

        player_data_str = self._html_search_regex(
            r'loadPlayer\(\s*(?:["\'][^"\']+["\']\s*,\s*)?(\{.*?\})\s*\)', webpage, 'player data')
        player_data = self._parse_json(player_data_str, display_id, urllib.parse.unquote)
        video_id = str(player_data['contentId'])
        title = player_data.get('title') or self._og_search_title(webpage, fatal=False) or \
            self._html_search_regex(r'<h\d+\b[^>]+\bclass="article_title">([^<]+)<', webpage, 'title')

        upload_date = unified_strdate(
            '{}-{}-{}'.format(mobj.group('year'), mobj.group('month'), mobj.group('day')))
        if not upload_date:
            upload_date = unified_strdate(self._html_search_regex(
                r'<p+\b[^>]+\bclass="article_date">([^<]+)<', webpage, 'upload date', default=None))

        player_data['video'] = player_data.pop('token')
        player_page = self._download_webpage(
            'https://player.mediaklikk.hu/playernew/player.php', video_id,
            query=player_data, headers={'Referer': url})
        player_json = self._search_json(
            r'\bpl\.setup\s*\(', player_page, 'player json', video_id, end_pattern=r'\);')
        playlist_url = traverse_obj(
            player_json, ('playlist', lambda _, v: v['type'] == 'hls', 'file', {url_or_none}), get_all=False)
        if not playlist_url:
            raise ExtractorError('Unable to extract playlist url')

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(playlist_url, video_id)

        return {
            'id': video_id,
            'title': title,

Review comment (refactor):
can we do this instead:
```py
        webpage = self._download_webpage(url, display_id)

        player_data = self._search_json(
            r'loadPlayer\((?:\s*["\'][^"\']+["\']\s*,)?', webpage, 'player data', mobj)
        video_id = str(player_data['contentId'])
```

&nbsp;

and then below:

```diff
@@ -89,7 +88,7 @@ def _real_extract(self, url):
             upload_date = unified_strdate(self._html_search_regex(
                 r'<p+\b[^>]+\bclass="article_date">([^<]+)<', webpage, 'upload date', default=None))
 
-        player_data['video'] = player_data.pop('token')
+        player_data['video'] = urllib.parse.unquote(player_data.pop('token'))
         player_page = self._download_webpage(
             'https://player.mediaklikk.hu/playernew/player.php', video_id,
             query=player_data, headers={'Referer': url})
```

Code after:
            'display_id': 'idojaras-jelentes-2025-augusztus-9-2230',
            'ext': 'mp4',
            'upload_date': '20250809',
            'thumbnail': 'https://cdn.cms.mtv.hu/wp-content/uploads/sites/4/2025/08/Idojaras-jelentes-35-1.jpg',
        },
    }, {
        # hirado - subcategory
        'url': 'https://hirado.hu/belfold/video/2025/08/09/nyitott-porta-napok-2025/',
        'info_dict': {
            'id': '8590581',
            'title': 'Nyitott Porta Napok 2025',
            'display_id': 'nyitott-porta-napok-2025',
            'ext': 'mp4',
            'upload_date': '20250809',
            'thumbnail': 'https://cdn.cms.mtv.hu/wp-content/uploads/sites/4/2025/08/vlcsnap-2025-08-09-10h35m01s887.jpg',
        },
    }]

    def _real_extract(self, url):
        mobj = self._match_valid_url(url)
        display_id = mobj.group('id')
        webpage = self._download_webpage(url, display_id)

        player_data = self._search_json(
            r'loadPlayer\((?:\s*["\'][^"\']+["\']\s*,)?', webpage, 'player data', mobj)
        video_id = str(player_data['contentId'])
        title = player_data.get('title') or self._og_search_title(webpage, fatal=False) or \
            self._html_search_regex(r'<h\d+\b[^>]+\bclass="article_title">([^<]+)<', webpage, 'title')

        upload_date = unified_strdate(
            '{}-{}-{}'.format(mobj.group('year'), mobj.group('month'), mobj.group('day')))
        if not upload_date:
            upload_date = unified_strdate(self._html_search_regex(
                r'<p+\b[^>]+\bclass="article_date">([^<]+)<', webpage, 'upload date', default=None))

        player_data['video'] = urllib.parse.unquote(player_data.pop('token'))
        player_page = self._download_webpage(
            'https://player.mediaklikk.hu/playernew/player.php', video_id,
            query=player_data, headers={'Referer': url})
        player_json = self._search_json(
            r'\bpl\.setup\s*\(', player_page, 'player json', video_id, end_pattern=r'\);')
        playlist_url = traverse_obj(
            player_json, ('playlist', lambda _, v: v['type'] == 'hls', 'file', {url_or_none}), get_all=False)
        if not playlist_url:
            raise ExtractorError('Unable to extract playlist url')

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(playlist_url, video_id)

        return {
            'id': video_id,
            'title': title,