mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-23 09:31:29 +02:00
Compare commits
No commits in common. "2113492fa35ccfe7f5e2464703f636b6e628635a" and "b2920d0790c9ffa35ae0acc85fba65be2fed62a6" have entirely different histories.
2113492fa3
...
b2920d0790
|
@ -1,13 +1,7 @@
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import datetime
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import clean_html, urljoin
|
||||||
clean_html,
|
|
||||||
datetime_from_str,
|
|
||||||
unified_timestamp,
|
|
||||||
urljoin,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class JoqrAgIE(InfoExtractor):
|
class JoqrAgIE(InfoExtractor):
|
||||||
|
@ -24,7 +18,6 @@ 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,
|
||||||
|
@ -48,30 +41,6 @@ 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'
|
||||||
|
|
||||||
|
@ -82,14 +51,9 @@ 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="([^"]+)"',
|
||||||
|
@ -100,7 +64,6 @@ 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,
|
||||||
|
@ -109,5 +72,4 @@ 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