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