]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/picarto.py
1 from .common
import InfoExtractor
8 class PicartoIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www.)?picarto\.tv/(?P<id>[a-zA-Z0-9]+)'
11 'url': 'https://picarto.tv/Setz',
15 'title': 're:^Setz [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
19 'skip': 'Stream is offline',
23 def suitable(cls
, url
):
24 return False if PicartoVodIE
.suitable(url
) else super(PicartoIE
, cls
).suitable(url
)
26 def _real_extract(self
, url
):
27 channel_id
= self
._match
_id
(url
)
29 data
= self
._download
_json
(
30 'https://ptvintern.picarto.tv/ptvapi', channel_id
, query
={
39 getLoadBalancerUrl(channel_name: "%s") {
42 }''' % (channel_id
, channel_id
),
44 metadata
= data
['channel']
46 if metadata
.get('online') == 0:
47 raise ExtractorError('Stream is offline', expected
=True)
48 title
= metadata
['title']
50 cdn_data
= self
._download
_json
(
51 data
['getLoadBalancerUrl']['url'] + '/stream/json_' + metadata
['stream_name'] + '.js',
52 channel_id
, 'Downloading load balancing info')
55 for source
in (cdn_data
.get('source') or []):
56 source_url
= source
.get('url')
59 source_type
= source
.get('type')
60 if source_type
== 'html5/application/vnd.apple.mpegurl':
61 formats
.extend(self
._extract
_m
3u8_formats
(
62 source_url
, channel_id
, 'mp4', m3u8_id
='hls', fatal
=False))
63 elif source_type
== 'html5/video/mp4':
68 mature
= metadata
.get('adult')
72 age_limit
= 18 if mature
is True else 0
76 'title': title
.strip(),
78 'channel': channel_id
,
79 'channel_id': metadata
.get('id'),
80 'channel_url': 'https://picarto.tv/%s' % channel_id
,
81 'age_limit': age_limit
,
86 class PicartoVodIE(InfoExtractor
):
87 _VALID_URL
= r
'https?://(?:www.)?picarto\.tv/videopopout/(?P<id>[^/?#&]+)'
89 'url': 'https://picarto.tv/videopopout/ArtofZod_2017.12.12.00.13.23.flv',
90 'md5': '3ab45ba4352c52ee841a28fb73f2d9ca',
92 'id': 'ArtofZod_2017.12.12.00.13.23.flv',
94 'title': 'ArtofZod_2017.12.12.00.13.23.flv',
95 'thumbnail': r
're:^https?://.*\.jpg'
98 'url': 'https://picarto.tv/videopopout/Plague',
99 'only_matching': True,
102 def _real_extract(self
, url
):
103 video_id
= self
._match
_id
(url
)
105 webpage
= self
._download
_webpage
(url
, video_id
)
107 vod_info
= self
._parse
_json
(
109 r
'(?s)#vod-player["\']\s
*,\s
*(\{.+?\}
)\s
*\
)', webpage,
111 video_id, transform_source=js_to_json)
113 formats = self._extract_m3u8_formats(
114 vod_info['vod
'], video_id, 'mp4
', entry_protocol='m3u8_native
',
120 'thumbnail
': vod_info.get('vodThumb
'),