1 from .common
import InfoExtractor
9 class CamModelsIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?cammodels\.com/cam/(?P<id>[^/?#&]+)'
12 'url': 'https://www.cammodels.com/cam/AutumnKnight/',
13 'only_matching': True,
17 def _real_extract(self
, url
):
18 user_id
= self
._match
_id
(url
)
20 webpage
= self
._download
_webpage
(
21 url
, user_id
, headers
=self
.geo_verification_headers())
23 manifest_root
= self
._html
_search
_regex
(
24 r
'manifestUrlRoot=([^&\']+)', webpage, 'manifest
', default=None)
28 ("I'm offline
, but let
's stay connected", 'This user
is currently offline
'),
29 ('in a private show
', 'This user
is in a private show
'),
30 ('is currently performing LIVE
', 'This model
is currently performing live
'),
32 for pattern, message in ERRORS:
33 if pattern in webpage:
38 error = 'Unable to find manifest URL root
'
40 raise ExtractorError(error, expected=expected)
42 manifest = self._download_json(
43 '%s%s.json
' % (manifest_root, user_id), user_id)
46 for format_id, format_dict in manifest['formats
'].items():
47 if not isinstance(format_dict, dict):
49 encodings = format_dict.get('encodings
')
50 if not isinstance(encodings, list):
52 vcodec = format_dict.get('videoCodec
')
53 acodec = format_dict.get('audioCodec
')
54 for media in encodings:
55 if not isinstance(media, dict):
57 media_url = url_or_none(media.get('location
'))
61 format_id_list = [format_id]
62 height = int_or_none(media.get('videoHeight
'))
63 if height is not None:
64 format_id_list.append('%dp
' % height)
67 'format_id
': '-'.join(format_id_list),
68 'width
': int_or_none(media.get('videoWidth
')),
70 'vbr
': int_or_none(media.get('videoKbps
')),
71 'abr
': int_or_none(media.get('audioKbps
')),
72 'fps
': int_or_none(media.get('fps
')),
76 if 'rtmp
' in format_id:
78 elif 'hls
' in format_id:
81 # hls skips fragments, preferring rtmp
87 self._sort_formats(formats)