]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/cam4.py
30daf2be9aa0038ab1d2e5e24f2f39a8fb295b00
[yt-dlp.git] / yt_dlp / extractor / cam4.py
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,
16 }
17 }
18
19 def _real_extract(self, url):
20 channel_id = self._match_id(url)
21 m3u8_playlist = self._download_json('https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(channel_id), channel_id).get('cdnURL')
22
23 formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True)
24 self._sort_formats(formats)
25
26 return {
27 'id': channel_id,
28 'title': self._live_title(channel_id),
29 'is_live': True,
30 'age_limit': 18,
31 'formats': formats,
32 }