]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/cam4.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / cam4.py
1 from .common import InfoExtractor
2
3
4 class CAM4IE(InfoExtractor):
5 _VALID_URL = r'https?://(?:[^/]+\.)?cam4\.com/(?P<id>[a-z0-9_]+)'
6 _TEST = {
7 'url': 'https://www.cam4.com/foxynesss',
8 'info_dict': {
9 'id': 'foxynesss',
10 'ext': 'mp4',
11 'title': 're:^foxynesss [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
12 'age_limit': 18,
13 'live_status': 'is_live',
14 'thumbnail': 'https://snapshots.xcdnpro.com/thumbnails/foxynesss',
15 }
16 }
17
18 def _real_extract(self, url):
19 channel_id = self._match_id(url)
20 m3u8_playlist = self._download_json('https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(channel_id), channel_id).get('cdnURL')
21
22 formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True)
23
24 return {
25 'id': channel_id,
26 'title': channel_id,
27 'is_live': True,
28 'age_limit': 18,
29 'formats': formats,
30 'thumbnail': f'https://snapshots.xcdnpro.com/thumbnails/{channel_id}',
31 }