]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/picarto.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class PicartoIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www.)?picarto\.tv/(?P<id>[a-zA-Z0-9]+)'
14 'url': 'https://picarto.tv/Setz',
18 'title': 're:^Setz [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
22 'skip': 'Stream is offline',
26 def suitable(cls
, url
):
27 return False if PicartoVodIE
.suitable(url
) else super(PicartoIE
, cls
).suitable(url
)
29 def _real_extract(self
, url
):
30 channel_id
= self
._match
_id
(url
)
32 data
= self
._download
_json
(
33 'https://ptvintern.picarto.tv/ptvapi', channel_id
, query
={
42 getLoadBalancerUrl(channel_name: "%s") {
45 }''' % (channel_id
, channel_id
),
47 metadata
= data
['channel']
49 if metadata
.get('online') == 0:
50 raise ExtractorError('Stream is offline', expected
=True)
51 title
= metadata
['title']
53 cdn_data
= self
._download
_json
(
54 data
['getLoadBalancerUrl']['url'] + '/stream/json_' + metadata
['stream_name'] + '.js',
55 channel_id
, 'Downloading load balancing info')
58 for source
in (cdn_data
.get('source') or []):
59 source_url
= source
.get('url')
62 source_type
= source
.get('type')
63 if source_type
== 'html5/application/vnd.apple.mpegurl':
64 formats
.extend(self
._extract
_m
3u8_formats
(
65 source_url
, channel_id
, 'mp4', m3u8_id
='hls', fatal
=False))
66 elif source_type
== 'html5/video/mp4':
70 self
._sort
_formats
(formats
)
72 mature
= metadata
.get('adult')
76 age_limit
= 18 if mature
is True else 0
80 'title': self
._live
_title
(title
.strip()),
82 'channel': channel_id
,
83 'channel_id': metadata
.get('id'),
84 'channel_url': 'https://picarto.tv/%s' % channel_id
,
85 'age_limit': age_limit
,
90 class PicartoVodIE(InfoExtractor
):
91 _VALID_URL
= r
'https?://(?:www.)?picarto\.tv/videopopout/(?P<id>[^/?#&]+)'
93 'url': 'https://picarto.tv/videopopout/ArtofZod_2017.12.12.00.13.23.flv',
94 'md5': '3ab45ba4352c52ee841a28fb73f2d9ca',
96 'id': 'ArtofZod_2017.12.12.00.13.23.flv',
98 'title': 'ArtofZod_2017.12.12.00.13.23.flv',
99 'thumbnail': r
're:^https?://.*\.jpg'
102 'url': 'https://picarto.tv/videopopout/Plague',
103 'only_matching': True,
106 def _real_extract(self
, url
):
107 video_id
= self
._match
_id
(url
)
109 webpage
= self
._download
_webpage
(url
, video_id
)
111 vod_info
= self
._parse
_json
(
113 r
'(?s)#vod-player["\']\s
*,\s
*(\{.+?\}
)\s
*\
)', webpage,
115 video_id, transform_source=js_to_json)
117 formats = self._extract_m3u8_formats(
118 vod_info['vod
'], video_id, 'mp4
', entry_protocol='m3u8_native
',
120 self._sort_formats(formats)
125 'thumbnail
': vod_info.get('vodThumb
'),