]>
Commit | Line | Data |
---|---|---|
29f7c58a | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
6 | from ..compat import compat_str | |
7 | from ..utils import ( | |
8 | int_or_none, | |
9 | try_get, | |
10 | urlencode_postdata, | |
11 | ) | |
12 | ||
13 | ||
14 | class BongaCamsIE(InfoExtractor): | |
15 | _VALID_URL = r'https?://(?P<host>(?:[^/]+\.)?bongacams\d*\.com)/(?P<id>[^/?&#]+)' | |
16 | _TESTS = [{ | |
17 | 'url': 'https://de.bongacams.com/azumi-8', | |
18 | 'only_matching': True, | |
19 | }, { | |
20 | 'url': 'https://cn.bongacams.com/azumi-8', | |
21 | 'only_matching': True, | |
22 | }] | |
23 | ||
24 | def _real_extract(self, url): | |
25 | mobj = re.match(self._VALID_URL, url) | |
26 | host = mobj.group('host') | |
27 | channel_id = mobj.group('id') | |
28 | ||
29 | amf = self._download_json( | |
30 | 'https://%s/tools/amf.php' % host, channel_id, | |
31 | data=urlencode_postdata(( | |
32 | ('method', 'getRoomData'), | |
33 | ('args[]', channel_id), | |
34 | ('args[]', 'false'), | |
35 | )), headers={'X-Requested-With': 'XMLHttpRequest'}) | |
36 | ||
37 | server_url = amf['localData']['videoServerUrl'] | |
38 | ||
39 | uploader_id = try_get( | |
40 | amf, lambda x: x['performerData']['username'], compat_str) or channel_id | |
41 | uploader = try_get( | |
42 | amf, lambda x: x['performerData']['displayName'], compat_str) | |
43 | like_count = int_or_none(try_get( | |
44 | amf, lambda x: x['performerData']['loversCount'])) | |
45 | ||
46 | formats = self._extract_m3u8_formats( | |
47 | '%s/hls/stream_%s/playlist.m3u8' % (server_url, uploader_id), | |
48 | channel_id, 'mp4', m3u8_id='hls', live=True) | |
49 | self._sort_formats(formats) | |
50 | ||
51 | return { | |
52 | 'id': channel_id, | |
53 | 'title': self._live_title(uploader or uploader_id), | |
54 | 'uploader': uploader, | |
55 | 'uploader_id': uploader_id, | |
56 | 'like_count': like_count, | |
57 | 'age_limit': 18, | |
58 | 'is_live': True, | |
59 | 'formats': formats, | |
60 | } |