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

Code before:
from .common import InfoExtractor


class BTVPlusIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/predavaniya/(?P<id>\d+)/.*'
    _TESTS = [{
        'url': 'https://btvplus.bg/produkt/predavaniya/60119/sezon-1/ostrovat-na-100-te-grivni-sezon-1-epizod-11-02-10-2024',
        'info_dict': {
            'id': '6011911111',
            'title': 'Островът на 100-те гривни Сезон 1, епизод 11',
            'formats': 'count:1',
        },
    }]

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

        product_url = self._search_regex(
            r"var videoUrl\s*=\s*['\"]([^'\"]+)['\"];",
            webpage, 'product player URL')

        product_url = 'https://btvplus.bg' + product_url

        player_data = self._download_json(product_url, video_id)

        m3u8_url = self._search_regex(
            r'(https?://[^"]+\.m3u8)',
            player_data['config'], 'M3U8 URL')

        formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', m3u8_id='hls')

        title = self._search_regex(
            r'<span class="title">\s*(.*?)\s*</span>',
            webpage, 'video title', default='Unknown Title')

        return {
            'id': video_id,
            'title': title,
            'thumbnail': self._og_search_thumbnail(webpage),
            'description': self._og_search_description(webpage),
            'formats': formats,
        }


Review comment (suggestion):
```suggestion
        player_config = self._download_json(
            urljoin('https://btvplus.bg', player_url), video_id)['config']
```

Code after:
from .common import InfoExtractor
from ..utils import (
    bug_reports_message,
    clean_html,
    get_element_by_class,
    js_to_json,
    mimetype2ext,
    strip_or_none,
    url_or_none,
    urljoin,
)
from ..utils.traversal import traverse_obj


class BTVPlusIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/(?:predavaniya|seriali|novini)/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://btvplus.bg/produkt/predavaniya/67271/btv-reporterite/btv-reporterite-12-07-2025-g',
        'info_dict': {
            'ext': 'mp4',
            'id': '67271',
            'title': 'bTV Репортерите - 12.07.2025 г.',
            'thumbnail': 'https://cdn.btv.bg/media/images/940x529/Jul2025/2113606319.jpg',
        },
    }, {
        'url': 'https://btvplus.bg/produkt/seriali/66942/sezon-2/plen-sezon-2-epizod-55',
        'info_dict': {
            'ext': 'mp4',
            'id': '66942',
            'title': 'Плен - сезон 2, епизод 55',
            'thumbnail': 'https://cdn.btv.bg/media/images/940x529/Jun2025/2113595104.jpg',
        },
    }, {
        'url': 'https://btvplus.bg/produkt/novini/67270/btv-novinite-centralna-emisija-12-07-2025',
        'only_matching': True,
    }]

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

        player_url = self._search_regex(
            r'var\s+videoUrl\s*=\s*[\'"]([^\'"]+)[\'"]',
            webpage, 'player URL')

        player_config = self._download_json(
            urljoin('https://btvplus.bg', player_url), video_id)['config']

        videojs_data = self._search_json(
            r'videojs\(["\'][^"\']+["\'],', player_config, 'videojs data',