]>
Commit | Line | Data |
---|---|---|
2a49d019 | 1 | from .common import InfoExtractor |
45b2ee6f | 2 | from ..utils import int_or_none, url_or_none |
2a49d019 | 3 | |
4 | ||
5 | class CamModelsIE(InfoExtractor): | |
8b1da46e S |
6 | _VALID_URL = r'https?://(?:www\.)?cammodels\.com/cam/(?P<id>[^/?#&]+)' |
7 | _TESTS = [{ | |
8 | 'url': 'https://www.cammodels.com/cam/AutumnKnight/', | |
9 | 'only_matching': True, | |
add96eb9 | 10 | 'age_limit': 18, |
8b1da46e | 11 | }] |
2a49d019 | 12 | |
13 | def _real_extract(self, url): | |
8b1da46e S |
14 | user_id = self._match_id(url) |
15 | ||
2a49d019 | 16 | manifest = self._download_json( |
add96eb9 | 17 | f'https://manifest-server.naiadsystems.com/live/s:{user_id}.json', user_id) |
8b1da46e S |
18 | |
19 | formats = [] | |
45b2ee6f | 20 | thumbnails = [] |
8b1da46e S |
21 | for format_id, format_dict in manifest['formats'].items(): |
22 | if not isinstance(format_dict, dict): | |
23 | continue | |
24 | encodings = format_dict.get('encodings') | |
25 | if not isinstance(encodings, list): | |
26 | continue | |
27 | vcodec = format_dict.get('videoCodec') | |
28 | acodec = format_dict.get('audioCodec') | |
29 | for media in encodings: | |
30 | if not isinstance(media, dict): | |
31 | continue | |
3052a30d S |
32 | media_url = url_or_none(media.get('location')) |
33 | if not media_url: | |
8b1da46e S |
34 | continue |
35 | ||
36 | format_id_list = [format_id] | |
37 | height = int_or_none(media.get('videoHeight')) | |
38 | if height is not None: | |
add96eb9 | 39 | format_id_list.append(f'{height}p') |
8b1da46e S |
40 | f = { |
41 | 'url': media_url, | |
42 | 'format_id': '-'.join(format_id_list), | |
43 | 'width': int_or_none(media.get('videoWidth')), | |
44 | 'height': height, | |
45 | 'vbr': int_or_none(media.get('videoKbps')), | |
46 | 'abr': int_or_none(media.get('audioKbps')), | |
47 | 'fps': int_or_none(media.get('fps')), | |
48 | 'vcodec': vcodec, | |
49 | 'acodec': acodec, | |
50 | } | |
51 | if 'rtmp' in format_id: | |
52 | f['ext'] = 'flv' | |
53 | elif 'hls' in format_id: | |
54 | f.update({ | |
2a49d019 | 55 | 'ext': 'mp4', |
8b1da46e | 56 | # hls skips fragments, preferring rtmp |
f983b875 | 57 | 'quality': -10, |
2a49d019 | 58 | }) |
8b1da46e | 59 | else: |
45b2ee6f | 60 | if format_id == 'jpeg': |
61 | thumbnails.append({ | |
62 | 'url': f['url'], | |
63 | 'width': f['width'], | |
64 | 'height': f['height'], | |
65 | 'format_id': f['format_id'], | |
66 | }) | |
8b1da46e S |
67 | continue |
68 | formats.append(f) | |
8b1da46e | 69 | |
2a49d019 | 70 | return { |
8b1da46e | 71 | 'id': user_id, |
39ca3b5c | 72 | 'title': user_id, |
45b2ee6f | 73 | 'thumbnails': thumbnails, |
8b1da46e S |
74 | 'is_live': True, |
75 | 'formats': formats, | |
add96eb9 | 76 | 'age_limit': 18, |
2a49d019 | 77 | } |