]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/bitwave.py
a82cd263a796a883c17bd7e57f331ff27320e853
[yt-dlp.git] / yt_dlp / extractor / bitwave.py
1 from .common import InfoExtractor
2
3
4 class BitwaveReplayIE(InfoExtractor):
5 IE_NAME = 'bitwave:replay'
6 _VALID_URL = r'https?://(?:www\.)?bitwave\.tv/(?P<user>\w+)/replay/(?P<id>\w+)/?$'
7 _TEST = {
8 'url': 'https://bitwave.tv/RhythmicCarnage/replay/z4P6eq5L7WDrM85UCrVr',
9 'only_matching': True
10 }
11
12 def _real_extract(self, url):
13 replay_id = self._match_id(url)
14 replay = self._download_json(
15 'https://api.bitwave.tv/v1/replays/' + replay_id,
16 replay_id
17 )
18
19 return {
20 'id': replay_id,
21 'title': replay['data']['title'],
22 'uploader': replay['data']['name'],
23 'uploader_id': replay['data']['name'],
24 'url': replay['data']['url'],
25 'thumbnails': [
26 {'url': x} for x in replay['data']['thumbnails']
27 ],
28 }
29
30
31 class BitwaveStreamIE(InfoExtractor):
32 IE_NAME = 'bitwave:stream'
33 _VALID_URL = r'https?://(?:www\.)?bitwave\.tv/(?P<id>\w+)/?$'
34 _TEST = {
35 'url': 'https://bitwave.tv/doomtube',
36 'only_matching': True
37 }
38
39 def _real_extract(self, url):
40 username = self._match_id(url)
41 channel = self._download_json(
42 'https://api.bitwave.tv/v1/channels/' + username,
43 username)
44
45 formats = self._extract_m3u8_formats(
46 channel['data']['url'], username,
47 'mp4')
48
49 return {
50 'id': username,
51 'title': channel['data']['title'],
52 'uploader': username,
53 'uploader_id': username,
54 'formats': formats,
55 'thumbnail': channel['data']['thumbnail'],
56 'is_live': True,
57 'view_count': channel['data']['viewCount']
58 }