mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-23 09:31:29 +02:00
Compare commits
2 Commits
b2920d0790
...
2113492fa3
Author | SHA1 | Date | |
---|---|---|---|
|
2113492fa3 | ||
|
0d5d5756a4 |
|
@ -1,7 +1,13 @@
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
import datetime
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import clean_html, urljoin
|
from ..utils import (
|
||||||
|
clean_html,
|
||||||
|
datetime_from_str,
|
||||||
|
unified_timestamp,
|
||||||
|
urljoin,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class JoqrAgIE(InfoExtractor):
|
class JoqrAgIE(InfoExtractor):
|
||||||
|
@ -18,6 +24,7 @@ class JoqrAgIE(InfoExtractor):
|
||||||
'channel': '超!A&G+',
|
'channel': '超!A&G+',
|
||||||
'description': str,
|
'description': str,
|
||||||
'live_status': 'is_live',
|
'live_status': 'is_live',
|
||||||
|
'release_timestamp': int,
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
|
@ -41,6 +48,30 @@ class JoqrAgIE(InfoExtractor):
|
||||||
return clean_html(urllib.parse.unquote_plus(self._search_regex(
|
return clean_html(urllib.parse.unquote_plus(self._search_regex(
|
||||||
rf'var\s+{variable}\s*=\s*["\']([^"\']+)["\']', html, name, default=''))) or None
|
rf'var\s+{variable}\s*=\s*["\']([^"\']+)["\']', html, name, default=''))) or None
|
||||||
|
|
||||||
|
def _extract_start_timestamp(self, video_id, is_live):
|
||||||
|
def __extract_start_timestamp_of_day(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\s+class="dailyProgram-itemHeaderTime"\s*>\s*\d{1,2}:\d{1,2}\s*–\s*(?P<time>\d{1,2}:\d{1,2})\s*<\/h3>',
|
||||||
|
self._download_webpage(
|
||||||
|
f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id,
|
||||||
|
fatal=False, note=f'Downloading program list of {date}',
|
||||||
|
errnote=f'Failed to download program list of {date}'),
|
||||||
|
'start time of the first program', default=None, group='time')
|
||||||
|
if start_time:
|
||||||
|
return unified_timestamp(f'{dt.strftime("%Y/%m/%d")} {start_time} +09:00')
|
||||||
|
return None
|
||||||
|
|
||||||
|
start_timestamp = __extract_start_timestamp_of_day('today')
|
||||||
|
if not start_timestamp:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not is_live or start_timestamp < datetime_from_str('now').timestamp():
|
||||||
|
return start_timestamp
|
||||||
|
else:
|
||||||
|
return __extract_start_timestamp_of_day('yesterday')
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = 'live'
|
video_id = 'live'
|
||||||
|
|
||||||
|
@ -51,9 +82,14 @@ class JoqrAgIE(InfoExtractor):
|
||||||
desc = self._extract_metadata('Program_text', metadata, 'program description')
|
desc = self._extract_metadata('Program_text', metadata, 'program description')
|
||||||
|
|
||||||
if title == '放送休止':
|
if title == '放送休止':
|
||||||
self.raise_no_formats('This stream has not started yet', expected=True)
|
|
||||||
formats = []
|
formats = []
|
||||||
live_status = 'is_upcoming'
|
live_status = 'is_upcoming'
|
||||||
|
release_timestamp = self._extract_start_timestamp(video_id, False)
|
||||||
|
if release_timestamp:
|
||||||
|
msg = f'This stream will start at {datetime.datetime.fromtimestamp(release_timestamp).strftime("%Y-%m-%d %H:%M:%S")}'
|
||||||
|
else:
|
||||||
|
msg = 'This stream has not started yet'
|
||||||
|
self.raise_no_formats(msg, expected=True)
|
||||||
else:
|
else:
|
||||||
m3u8_path = self._search_regex(
|
m3u8_path = self._search_regex(
|
||||||
r'<source\s[^>]*\bsrc="([^"]+)"',
|
r'<source\s[^>]*\bsrc="([^"]+)"',
|
||||||
|
@ -64,6 +100,7 @@ class JoqrAgIE(InfoExtractor):
|
||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
urljoin('https://www.uniqueradio.jp/', m3u8_path), video_id, fatal=False)
|
urljoin('https://www.uniqueradio.jp/', m3u8_path), video_id, fatal=False)
|
||||||
live_status = 'is_live'
|
live_status = 'is_live'
|
||||||
|
release_timestamp = self._extract_start_timestamp(video_id, True)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
@ -72,4 +109,5 @@ class JoqrAgIE(InfoExtractor):
|
||||||
'description': desc,
|
'description': desc,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'live_status': live_status,
|
'live_status': live_status,
|
||||||
|
'release_timestamp': release_timestamp,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user