mirror of
https://github.com/l1ving/youtube-dl
synced 2020-11-18 19:53:54 -08:00
[picarto] Stop relying on info from web page
This is just unreliable and some streams like private ones do not work via this method.
This commit is contained in:
parent
963623ceb6
commit
246ac56a93
@ -8,7 +8,6 @@ from ..compat import compat_str
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
try_get,
|
|
||||||
update_url_query,
|
update_url_query,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
@ -34,21 +33,10 @@ class PicartoIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
channel_id = self._match_id(url)
|
channel_id = self._match_id(url)
|
||||||
stream_page = self._download_webpage(url, channel_id)
|
|
||||||
metadata = self._download_json(
|
metadata = self._download_json(
|
||||||
'https://api.picarto.tv/v1/channel/name/' + channel_id,
|
'https://api.picarto.tv/v1/channel/name/' + channel_id,
|
||||||
channel_id)
|
channel_id)
|
||||||
|
|
||||||
if '>This channel does not exist' in stream_page:
|
|
||||||
raise ExtractorError(
|
|
||||||
'Channel %s does not exist' % channel_id, expected=True)
|
|
||||||
|
|
||||||
player = self._parse_json(
|
|
||||||
self._search_regex(
|
|
||||||
r'(?s)playerSettings\[\d+\]\s*=\s*(\{.+?\}\s*\n)', stream_page,
|
|
||||||
'player settings'),
|
|
||||||
channel_id, transform_source=js_to_json)
|
|
||||||
|
|
||||||
if metadata.get('online') is False:
|
if metadata.get('online') is False:
|
||||||
raise ExtractorError('Stream is offline', expected=True)
|
raise ExtractorError('Stream is offline', expected=True)
|
||||||
|
|
||||||
@ -57,21 +45,13 @@ class PicartoIE(InfoExtractor):
|
|||||||
data=urlencode_postdata({'loadbalancinginfo': channel_id}),
|
data=urlencode_postdata({'loadbalancinginfo': channel_id}),
|
||||||
note='Downloading load balancing info')
|
note='Downloading load balancing info')
|
||||||
|
|
||||||
def get_event(key):
|
|
||||||
return try_get(player, lambda x: x['event'][key], compat_str) or ''
|
|
||||||
|
|
||||||
token = self._VALID_URL_RE.match(url).group('token') or 'public'
|
token = self._VALID_URL_RE.match(url).group('token') or 'public'
|
||||||
params = {
|
params = {
|
||||||
'ticket': get_event('ticket'),
|
|
||||||
'con': int(time.time() * 1000),
|
'con': int(time.time() * 1000),
|
||||||
'type': get_event('ticket'),
|
|
||||||
'scope': get_event('scope'),
|
|
||||||
'token': token,
|
'token': token,
|
||||||
}
|
}
|
||||||
|
|
||||||
prefered_edge = cdn_data.get('preferedEdge')
|
prefered_edge = cdn_data.get('preferedEdge')
|
||||||
default_tech = player.get('defaultTech')
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
for edge in cdn_data['edges']:
|
for edge in cdn_data['edges']:
|
||||||
@ -85,8 +65,6 @@ class PicartoIE(InfoExtractor):
|
|||||||
preference = 0
|
preference = 0
|
||||||
if edge_id == prefered_edge:
|
if edge_id == prefered_edge:
|
||||||
preference += 1
|
preference += 1
|
||||||
if tech_type == default_tech:
|
|
||||||
preference += 1
|
|
||||||
format_id = []
|
format_id = []
|
||||||
if edge_id:
|
if edge_id:
|
||||||
format_id.append(edge_id)
|
format_id.append(edge_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user