summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/cammodels.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
commit2415e66f889f38503b73e8ebc5f43ca342390e5c (patch)
treeac48ab69d1d96bae3d83756134921e0d90593aa5 /yt_dlp/extractor/cammodels.py
parentInitial commit. (diff)
downloadyt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.tar.xz
yt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.zip
Adding upstream version 2024.03.10.upstream/2024.03.10
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/cammodels.py')
-rw-r--r--yt_dlp/extractor/cammodels.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/yt_dlp/extractor/cammodels.py b/yt_dlp/extractor/cammodels.py
new file mode 100644
index 0000000..135b315
--- /dev/null
+++ b/yt_dlp/extractor/cammodels.py
@@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, url_or_none
+
+
+class CamModelsIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?cammodels\.com/cam/(?P<id>[^/?#&]+)'
+ _TESTS = [{
+ 'url': 'https://www.cammodels.com/cam/AutumnKnight/',
+ 'only_matching': True,
+ 'age_limit': 18
+ }]
+
+ def _real_extract(self, url):
+ user_id = self._match_id(url)
+
+ manifest = self._download_json(
+ 'https://manifest-server.naiadsystems.com/live/s:%s.json' % user_id, user_id)
+
+ formats = []
+ thumbnails = []
+ for format_id, format_dict in manifest['formats'].items():
+ if not isinstance(format_dict, dict):
+ continue
+ encodings = format_dict.get('encodings')
+ if not isinstance(encodings, list):
+ continue
+ vcodec = format_dict.get('videoCodec')
+ acodec = format_dict.get('audioCodec')
+ for media in encodings:
+ if not isinstance(media, dict):
+ continue
+ media_url = url_or_none(media.get('location'))
+ if not media_url:
+ continue
+
+ format_id_list = [format_id]
+ height = int_or_none(media.get('videoHeight'))
+ if height is not None:
+ format_id_list.append('%dp' % height)
+ f = {
+ 'url': media_url,
+ 'format_id': '-'.join(format_id_list),
+ 'width': int_or_none(media.get('videoWidth')),
+ 'height': height,
+ 'vbr': int_or_none(media.get('videoKbps')),
+ 'abr': int_or_none(media.get('audioKbps')),
+ 'fps': int_or_none(media.get('fps')),
+ 'vcodec': vcodec,
+ 'acodec': acodec,
+ }
+ if 'rtmp' in format_id:
+ f['ext'] = 'flv'
+ elif 'hls' in format_id:
+ f.update({
+ 'ext': 'mp4',
+ # hls skips fragments, preferring rtmp
+ 'quality': -10,
+ })
+ else:
+ if format_id == 'jpeg':
+ thumbnails.append({
+ 'url': f['url'],
+ 'width': f['width'],
+ 'height': f['height'],
+ 'format_id': f['format_id'],
+ })
+ continue
+ formats.append(f)
+
+ return {
+ 'id': user_id,
+ 'title': user_id,
+ 'thumbnails': thumbnails,
+ 'is_live': True,
+ 'formats': formats,
+ 'age_limit': 18
+ }