Compare commits

..

3 Commits

Author SHA1 Message Date
Mozi
b2920d0790 [ie/joqrag] Fix string literal 2023-10-22 03:14:42 +08:00
Mozi
dcc0c86eaf [ie/joqrag] Extract code for metadata extraction into a function
Co-authored-by: bashonly <bashonly@bashonly.com>
2023-10-22 03:10:53 +08:00
Mozi
c2c195de32 [ie/joqrag] Do not download if the stream has not started yet
Daily programs list: http://www.joqr.co.jp/qr/agdailyprogram/?date=%Y%m%d
2023-10-22 03:09:53 +08:00

View File

@ -37,25 +37,33 @@ class JoqrAgIE(InfoExtractor):
'only_matching': True, 'only_matching': True,
}] }]
def _extract_metadata(self, variable, html, name):
return clean_html(urllib.parse.unquote_plus(self._search_regex(
rf'var\s+{variable}\s*=\s*["\']([^"\']+)["\']', html, name, default=''))) or None
def _real_extract(self, url): def _real_extract(self, url):
video_id = 'live' video_id = 'live'
metadata = self._download_webpage( metadata = self._download_webpage(
'https://www.uniqueradio.jp/aandg', video_id, 'https://www.uniqueradio.jp/aandg', video_id,
note='Downloading metadata', errnote='Failed to download metadata') note='Downloading metadata', errnote='Failed to download metadata')
title = clean_html(urllib.parse.unquote_plus( title = self._extract_metadata('Program_name', metadata, 'program title')
self._search_regex(r'var\s+Program_name\s*=\s*["\']([^"\']+)["\']', metadata, 'program title'))) desc = self._extract_metadata('Program_text', metadata, 'program description')
desc = clean_html(urllib.parse.unquote_plus(
self._search_regex(r'var\s+Program_text\s*=\s*["\']([^"\']+)["\']', metadata, 'program description')))
m3u8_path = self._search_regex( if title == '放送休止':
r'<source\s[^>]*\bsrc="([^"]+)"', self.raise_no_formats('This stream has not started yet', expected=True)
self._download_webpage( formats = []
'https://www.uniqueradio.jp/agplayer5/inc-player-hls.php', video_id, live_status = 'is_upcoming'
note='Downloading player data', errnote='Failed to download player data'), else:
'm3u8 url') m3u8_path = self._search_regex(
formats = self._extract_m3u8_formats( r'<source\s[^>]*\bsrc="([^"]+)"',
urljoin('https://www.uniqueradio.jp/', m3u8_path), video_id, fatal=False) 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(
urljoin('https://www.uniqueradio.jp/', m3u8_path), video_id, fatal=False)
live_status = 'is_live'
return { return {
'id': video_id, 'id': video_id,
@ -63,5 +71,5 @@ class JoqrAgIE(InfoExtractor):
'channel': '超!A&G+', 'channel': '超!A&G+',
'description': desc, 'description': desc,
'formats': formats, 'formats': formats,
'live_status': 'is_live', 'live_status': live_status,
} }