mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 07:28:19 +01:00
Compare commits
4 Commits
42b6003f59
...
24bf287b7c
Author | SHA1 | Date | |
---|---|---|---|
|
24bf287b7c | ||
|
4b5eec0aaa | ||
|
1a68959dc4 | ||
|
1597bcf660 |
|
@ -59,16 +59,15 @@ def _extract_from_api(self, video_id, tld):
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
}, fatal=False, impersonate=True) or {}
|
}, fatal=False, impersonate=True) or {}
|
||||||
|
|
||||||
status = response.get('room_status')
|
|
||||||
if status != 'public':
|
|
||||||
if error := self._ERROR_MAP.get(status):
|
|
||||||
raise ExtractorError(error, expected=True)
|
|
||||||
self.report_warning('Falling back to webpage extraction')
|
|
||||||
return None
|
|
||||||
|
|
||||||
m3u8_url = response.get('url')
|
m3u8_url = response.get('url')
|
||||||
if not m3u8_url:
|
if not m3u8_url:
|
||||||
|
status = response.get('room_status')
|
||||||
|
if error := self._ERROR_MAP.get(status):
|
||||||
|
raise ExtractorError(error, expected=True)
|
||||||
|
if status == 'public':
|
||||||
self.raise_geo_restricted()
|
self.raise_geo_restricted()
|
||||||
|
self.report_warning(f'Got status "{status}" from API; falling back to webpage extraction')
|
||||||
|
return None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
|
|
@ -458,7 +458,10 @@ class PolskieRadioPlayerIE(InfoExtractor):
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '3',
|
'id': '3',
|
||||||
'ext': 'm4a',
|
'ext': 'm4a',
|
||||||
'title': 'Trójka',
|
'title': r're:Trójka \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
|
||||||
|
'thumbnail': 'https://player.polskieradio.pl/images/trojka-color-logo.png',
|
||||||
|
'live_status': 'is_live',
|
||||||
|
'display_id': 'trojka',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'format': 'bestaudio',
|
'format': 'bestaudio',
|
||||||
|
@ -467,12 +470,20 @@ class PolskieRadioPlayerIE(InfoExtractor):
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _get_channel_list(self, channel_url='no_channel'):
|
def _get_channel_list(self, channel_url='no_channel'):
|
||||||
|
webpage = self._download_webpage(self._BASE_URL, channel_url)
|
||||||
|
player_hash = self._search_regex(r'/main\.bundle\.js\?([a-f0-9]+)', webpage, 'player hash')
|
||||||
|
channel_list = self.cache.load('polskieradio-player-channel-list', player_hash)
|
||||||
|
if channel_list:
|
||||||
|
return channel_list
|
||||||
player_code = self._download_webpage(
|
player_code = self._download_webpage(
|
||||||
self._PLAYER_URL, channel_url,
|
self._PLAYER_URL, channel_url,
|
||||||
note='Downloading js player')
|
note='Downloading js player')
|
||||||
channel_list = js_to_json(self._search_regex(
|
channel_list = self._search_json(
|
||||||
r';var r="anteny",a=(\[.+?\])},', player_code, 'channel list'))
|
r''';\s*var\s[a-zA-Z_]+\s*=\s*["']anteny["']\s*,\s*[a-zA-Z_]+\s*=\s*''',
|
||||||
return self._parse_json(channel_list, channel_url)
|
player_code, 'channel list', channel_url, transform_source=js_to_json,
|
||||||
|
contains_pattern=r'\[{(?s:.+)}\]')
|
||||||
|
self.cache.store('polskieradio-player-channel-list', player_hash, channel_list)
|
||||||
|
return channel_list
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
channel_url = self._match_id(url)
|
channel_url = self._match_id(url)
|
||||||
|
@ -495,19 +506,11 @@ def _real_extract(self, url):
|
||||||
if not station:
|
if not station:
|
||||||
raise ExtractorError('Station not found even though we extracted channel')
|
raise ExtractorError('Station not found even though we extracted channel')
|
||||||
|
|
||||||
formats = []
|
formats = self._extract_m3u8_formats(
|
||||||
for stream_url in station['Streams']:
|
next((
|
||||||
stream_url = self._proto_relative_url(stream_url)
|
stream_url.replace('http:', 'https:') for stream_url in station['Streams'] if stream_url.endswith('.m3u8')
|
||||||
if stream_url.endswith('/playlist.m3u8'):
|
)),
|
||||||
formats.extend(self._extract_m3u8_formats(stream_url, channel_url, live=True))
|
channel_url, live=True)
|
||||||
elif stream_url.endswith('/manifest.f4m'):
|
|
||||||
formats.extend(self._extract_mpd_formats(stream_url, channel_url))
|
|
||||||
elif stream_url.endswith('/Manifest'):
|
|
||||||
formats.extend(self._extract_ism_formats(stream_url, channel_url))
|
|
||||||
else:
|
|
||||||
formats.append({
|
|
||||||
'url': stream_url,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': str(channel['id']),
|
'id': str(channel['id']),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user