]>
Commit | Line | Data |
---|---|---|
d9c2b0a6 | 1 | from __future__ import unicode_literals |
2 | ||
2b547dd7 | 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+)/?$' | |
ae7c0143 | 9 | _TEST = { |
10 | 'url': 'https://bitwave.tv/RhythmicCarnage/replay/z4P6eq5L7WDrM85UCrVr', | |
11 | 'only_matching': True | |
12 | } | |
2b547dd7 | 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+)/?$' | |
ae7c0143 | 36 | _TEST = { |
37 | 'url': 'https://bitwave.tv/doomtube', | |
38 | 'only_matching': True | |
39 | } | |
2b547dd7 | 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, | |
39ca3b5c | 54 | 'title': channel['data']['title'], |
2b547dd7 | 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 | } |