]>
Commit | Line | Data |
---|---|---|
d1b39ad8 AK |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | ||
6 | ||
7 | class CAM4IE(InfoExtractor): | |
8 | _VALID_URL = r'https?://(?:[^/]+\.)?cam4\.com/(?P<id>[a-z0-9_]+)' | |
9 | _TEST = { | |
10 | 'url': 'https://www.cam4.com/foxynesss', | |
11 | 'info_dict': { | |
12 | 'id': 'foxynesss', | |
13 | 'ext': 'mp4', | |
14 | 'title': 're:^foxynesss [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', | |
15 | 'age_limit': 18, | |
e600a5c9 AK |
16 | 'live_status': 'is_live', |
17 | 'thumbnail': 'https://snapshots.xcdnpro.com/thumbnails/foxynesss', | |
d1b39ad8 AK |
18 | } |
19 | } | |
20 | ||
21 | def _real_extract(self, url): | |
22 | channel_id = self._match_id(url) | |
23 | m3u8_playlist = self._download_json('https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(channel_id), channel_id).get('cdnURL') | |
24 | ||
25 | formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True) | |
26 | self._sort_formats(formats) | |
27 | ||
28 | return { | |
29 | 'id': channel_id, | |
39ca3b5c | 30 | 'title': channel_id, |
d1b39ad8 AK |
31 | 'is_live': True, |
32 | 'age_limit': 18, | |
33 | 'formats': formats, | |
e600a5c9 | 34 | 'thumbnail': f'https://snapshots.xcdnpro.com/thumbnails/{channel_id}', |
d1b39ad8 | 35 | } |