]>
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':
67 self
._sort
_formats
(formats
)
69 mature
= metadata
.get('adult')
73 age_limit
= 18 if mature
is True else 0
77 'title': title
.strip(),
79 'channel': channel_id
,
80 'channel_id': metadata
.get('id'),
81 'channel_url': 'https://picarto.tv/%s' % channel_id
,
82 'age_limit': age_limit
,
87 class PicartoVodIE(InfoExtractor
):
88 _VALID_URL
= r
'https?://(?:www.)?picarto\.tv/videopopout/(?P<id>[^/?#&]+)'
90 'url': 'https://picarto.tv/videopopout/ArtofZod_2017.12.12.00.13.23.flv',
91 'md5': '3ab45ba4352c52ee841a28fb73f2d9ca',
93 'id': 'ArtofZod_2017.12.12.00.13.23.flv',
95 'title': 'ArtofZod_2017.12.12.00.13.23.flv',
96 'thumbnail': r
're:^https?://.*\.jpg'
99 'url': 'https://picarto.tv/videopopout/Plague',
100 'only_matching': True,
103 def _real_extract(self
, url
):
104 video_id
= self
._match
_id
(url
)
106 webpage
= self
._download
_webpage
(url
, video_id
)
108 vod_info
= self
._parse
_json
(
110 r
'(?s)#vod-player["\']\s
*,\s
*(\{.+?\}
)\s
*\
)', webpage,
112 video_id, transform_source=js_to_json)
114 formats = self._extract_m3u8_formats(
115 vod_info['vod
'], video_id, 'mp4
', entry_protocol='m3u8_native
',
117 self._sort_formats(formats)
122 'thumbnail
': vod_info.get('vodThumb
'),