]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/cam4.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / cam4.py
CommitLineData
d1b39ad8
AK
1from .common import InfoExtractor
2
3
4class 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,
e600a5c9
AK
13 'live_status': 'is_live',
14 'thumbnail': 'https://snapshots.xcdnpro.com/thumbnails/foxynesss',
add96eb9 15 },
d1b39ad8
AK
16 }
17
18 def _real_extract(self, url):
19 channel_id = self._match_id(url)
add96eb9 20 m3u8_playlist = self._download_json(f'https://www.cam4.com/rest/v1.0/profile/{channel_id}/streamInfo', channel_id).get('cdnURL')
d1b39ad8
AK
21
22 formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True)
d1b39ad8
AK
23
24 return {
25 'id': channel_id,
39ca3b5c 26 'title': channel_id,
d1b39ad8
AK
27 'is_live': True,
28 'age_limit': 18,
29 'formats': formats,
e600a5c9 30 'thumbnail': f'https://snapshots.xcdnpro.com/thumbnails/{channel_id}',
d1b39ad8 31 }