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

Code before:
                    (https?://(?:www\.)?joqr\.co\.jp/qr/(?:agdailyprogram|agregularprogram)/)
                    '''
    _TESTS = [{
        'url': 'https://www.uniqueradio.jp/agplayer5/player.php',
        'info_dict': {
            'id': 'live',
            'title': str,
            'description': str,
            'live_status': 'is_live',
        },
        'params': {
            'skip_download': True,
            'ignore_no_formats_error': True,
        },
    }]

    def _real_extract(self, url):
        video_id = 'live'

        metadata = self._download_webpage(
            'https://www.uniqueradio.jp/aandg', video_id,
            note='Downloading metadata', errnote='Failed to download metadata')
        title = urllib.parse.unquote_plus(
            self._search_regex(r'var\s+Program_name\s*=\s*["\']([^"\']+)["\']', metadata, 'program title'))
        desc = urllib.parse.unquote_plus(
            self._search_regex(r'var\s+Program_text\s*=\s*["\']([^"\']+)["\']', metadata, 'program description'))

        m3u8_path = self._search_regex(
            r'<source\s[^>]*\bsrc="([^"]+)"',
            self._download_webpage(
                'https://www.uniqueradio.jp/agplayer5/inc-player-hls.php', video_id,
                note='Downloading player data', errnote='Failed to download player data'),
            'm3u8 url')
        formats = self._extract_m3u8_formats(
            f'https://www.uniqueradio.jp/{m3u8_path}', video_id, fatal=False)

        return {
            'id': video_id,
            'title': f'{title} - 超!A&G+',
            'description': desc,
            'formats': formats,
            'live_status': 'is_live',
        }


Review comment (refactor):
as i write this the description that gets extracted is `<div>土曜の黄昏時にお届けするノンストップアニソンライブラリー</div><div>ぜひ何かをしながらお聴きください！</div><br>番組へのメール、リクエストは<a href=\"mailto:sag@joqr.net\">sag@joqr.net</a>まで！<br>`
```suggestion
        desc = clean_html(urllib.parse.unquote_plus(
            self._search_regex(r'var\s+Program_text\s*=\s*["\']([^"\']+)["\']', metadata, 'program description')))
```

also add ```from ..utils import clean_html``` at the top
probably wouldn't hurt to do the same on the title as well, though that doesn't seem to immediately need it

Code after:

class JoqrAgIE(InfoExtractor):
    IE_DESC = '超!A&G+ 文化放送 (f.k.a. AGQR) Nippon Cultural Broadcasting, Inc. (JOQR)'
    _VALID_URL = [r'https?://www\.uniqueradio\.jp/agplayer5/(?:player|inc-player-hls)\.php',
                  r'https?://(?:www\.)?joqr\.co\.jp/ag/',
                  r'https?://(?:www\.)?joqr\.co\.jp/qr/ag(?:daily|regular)program/?(?:$|[#?])']
    _TESTS = [{
        'url': 'https://www.uniqueradio.jp/agplayer5/player.php',
        'info_dict': {
            'id': 'live',
            'title': str,
            'channel': '超!A&G+',
            'description': str,
            'live_status': 'is_live',
            'release_timestamp': int,
        },
        'params': {
            'skip_download': True,
            'ignore_no_formats_error': True,
        },
    }, {
        'url': 'https://www.uniqueradio.jp/agplayer5/inc-player-hls.php',
        'only_matching': True,
    }, {
        'url': 'https://www.joqr.co.jp/ag/article/103760/',
        'only_matching': True,
    }, {
        'url': 'http://www.joqr.co.jp/qr/agdailyprogram/',
        'only_matching': True,
    }, {
        'url': 'http://www.joqr.co.jp/qr/agregularprogram/',
        'only_matching': True,
    }]

    def _extract_metadata(self, variable, html):
        return clean_html(urllib.parse.unquote_plus(self._search_regex(
            rf'var\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
            html, 'metadata', group='value', default=''))) or None

    def _extract_start_timestamp(self, video_id, is_live):
        def extract_start_time_from(date_str):
            dt = datetime_from_str(date_str) + datetime.timedelta(hours=9)
            date = dt.strftime('%Y%m%d')
            start_time = self._search_regex(
                r'<h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(\d{1,2}:\d{1,2})',
                self._download_webpage(
                    f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id,
                    note=f'Downloading program list of {date}', fatal=False,
                    errnote=f'Failed to download program list of {date}') or '',
                'start time', default=None)
            if start_time: