summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/bitwave.py
blob: a82cd263a796a883c17bd7e57f331ff27320e853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from .common import InfoExtractor


class BitwaveReplayIE(InfoExtractor):
    IE_NAME = 'bitwave:replay'
    _VALID_URL = r'https?://(?:www\.)?bitwave\.tv/(?P<user>\w+)/replay/(?P<id>\w+)/?$'
    _TEST = {
        'url': 'https://bitwave.tv/RhythmicCarnage/replay/z4P6eq5L7WDrM85UCrVr',
        'only_matching': True
    }

    def _real_extract(self, url):
        replay_id = self._match_id(url)
        replay = self._download_json(
            'https://api.bitwave.tv/v1/replays/' + replay_id,
            replay_id
        )

        return {
            'id': replay_id,
            'title': replay['data']['title'],
            'uploader': replay['data']['name'],
            'uploader_id': replay['data']['name'],
            'url': replay['data']['url'],
            'thumbnails': [
                {'url': x} for x in replay['data']['thumbnails']
            ],
        }


class BitwaveStreamIE(InfoExtractor):
    IE_NAME = 'bitwave:stream'
    _VALID_URL = r'https?://(?:www\.)?bitwave\.tv/(?P<id>\w+)/?$'
    _TEST = {
        'url': 'https://bitwave.tv/doomtube',
        'only_matching': True
    }

    def _real_extract(self, url):
        username = self._match_id(url)
        channel = self._download_json(
            'https://api.bitwave.tv/v1/channels/' + username,
            username)

        formats = self._extract_m3u8_formats(
            channel['data']['url'], username,
            'mp4')

        return {
            'id': username,
            'title': channel['data']['title'],
            'uploader': username,
            'uploader_id': username,
            'formats': formats,
            'thumbnail': channel['data']['thumbnail'],
            'is_live': True,
            'view_count': channel['data']['viewCount']
        }