]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/theta.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..utils
import try_get
8 class ThetaStreamIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?theta\.tv/(?!video/)(?P<id>[a-z0-9-]+)'
11 'url': 'https://www.theta.tv/davirus',
12 'skip': 'The live may have ended',
16 'title': 'I choose you - My Community is King -👀 - YO HABLO ESPANOL - CODE DAVIRUS',
17 'thumbnail': r
're:https://live-thumbnails-prod-theta-tv\.imgix\.net/thumbnail/.+\.jpg',
20 'url': 'https://www.theta.tv/mst3k',
21 'note': 'This channel is live 24/7',
25 'title': 'Mystery Science Theatre 3000 24/7 Powered by the THETA Network.',
26 'thumbnail': r
're:https://user-prod-theta-tv\.imgix\.net/.+\.jpg',
29 'url': 'https://www.theta.tv/contv-anime',
33 'title': 'CONTV ANIME 24/7. Powered by THETA Network.',
34 'thumbnail': r
're:https://user-prod-theta-tv\.imgix\.net/.+\.jpg',
38 def _real_extract(self
, url
):
39 channel_id
= self
._match
_id
(url
)
40 info
= self
._download
_json
(f
'https://api.theta.tv/v1/channel?alias={channel_id}', channel_id
)['body']
43 data
['url'] for data
in info
['live_stream']['video_urls']
44 if data
.get('type') != 'embed' and data
.get('resolution') in ('master', 'source'))
46 formats
= self
._extract
_m
3u8_formats
(m3u8_playlist
, channel_id
, 'mp4', m3u8_id
='hls', live
=True)
47 self
._sort
_formats
(formats
)
49 channel
= try_get(info
, lambda x
: x
['user']['username']) # using this field instead of channel_id due to capitalization
53 'title': try_get(info
, lambda x
: x
['live_stream']['title']),
55 'view_count': try_get(info
, lambda x
: x
['live_stream']['view_count']),
58 'thumbnail': try_get(info
, lambda x
: x
['live_stream']['thumbnail_url']),
62 class ThetaVideoIE(InfoExtractor
):
63 _VALID_URL
= r
'https?://(?:www\.)?theta\.tv/video/(?P<id>vid[a-z0-9]+)'
65 'url': 'https://www.theta.tv/video/vidiq6aaet3kzf799p0',
66 'md5': '633d8c29eb276bb38a111dbd591c677f',
68 'id': 'vidiq6aaet3kzf799p0',
70 'title': 'Theta EdgeCast Tutorial',
71 'uploader': 'Pixiekittie',
72 'description': 'md5:e316253f5bdced8b5a46bb50ae60a09f',
73 'thumbnail': r
're:https://user-prod-theta-tv\.imgix\.net/.+/vod_thumb/.+.jpg',
77 def _real_extract(self
, url
):
78 video_id
= self
._match
_id
(url
)
79 info
= self
._download
_json
(f
'https://api.theta.tv/v1/video/{video_id}/raw', video_id
)['body']
81 m3u8_playlist
= try_get(info
, lambda x
: x
['video_urls'][0]['url'])
83 formats
= self
._extract
_m
3u8_formats
(m3u8_playlist
, video_id
, 'mp4', m3u8_id
='hls')
84 self
._sort
_formats
(formats
)
88 'title': info
.get('title'),
89 'uploader': try_get(info
, lambda x
: x
['user']['username']),
90 'description': info
.get('description'),
91 'view_count': info
.get('view_count'),
92 'like_count': info
.get('like_count'),
94 'thumbnail': info
.get('thumbnail_url'),