]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/bongacams.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / bongacams.py
index 4e346e7b6ec47efe9f0c40465799aa0d74b34284..ab85477de45c094a121ea777319b6f1438d7bfa4 100644 (file)
@@ -1,8 +1,4 @@
-from __future__ import unicode_literals
-
-
 from .common import InfoExtractor
-from ..compat import compat_str
 from ..utils import (
     int_or_none,
     try_get,
 
 
 class BongaCamsIE(InfoExtractor):
-    _VALID_URL = r'https?://(?P<host>(?:[^/]+\.)?bongacams\d*\.com)/(?P<id>[^/?&#]+)'
+    _VALID_URL = r'https?://(?P<host>(?:[^/]+\.)?bongacams\d*\.(?:com|net))/(?P<id>[^/?&#]+)'
     _TESTS = [{
         'url': 'https://de.bongacams.com/azumi-8',
         'only_matching': True,
     }, {
         'url': 'https://cn.bongacams.com/azumi-8',
         'only_matching': True,
+    }, {
+        'url': 'https://de.bongacams.net/claireashton',
+        'info_dict': {
+            'id': 'claireashton',
+            'ext': 'mp4',
+            'title': r're:ClaireAshton \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
+            'age_limit': 18,
+            'uploader_id': 'ClaireAshton',
+            'uploader': 'ClaireAshton',
+            'like_count': int,
+            'is_live': True,
+        },
+        'params': {
+            'skip_download': True,
+        },
     }]
 
     def _real_extract(self, url):
@@ -26,7 +37,7 @@ def _real_extract(self, url):
         channel_id = mobj.group('id')
 
         amf = self._download_json(
-            'https://%s/tools/amf.php' % host, channel_id,
+            f'https://{host}/tools/amf.php', channel_id,
             data=urlencode_postdata((
                 ('method', 'getRoomData'),
                 ('args[]', channel_id),
@@ -36,16 +47,15 @@ def _real_extract(self, url):
         server_url = amf['localData']['videoServerUrl']
 
         uploader_id = try_get(
-            amf, lambda x: x['performerData']['username'], compat_str) or channel_id
+            amf, lambda x: x['performerData']['username'], str) or channel_id
         uploader = try_get(
-            amf, lambda x: x['performerData']['displayName'], compat_str)
+            amf, lambda x: x['performerData']['displayName'], str)
         like_count = int_or_none(try_get(
             amf, lambda x: x['performerData']['loversCount']))
 
         formats = self._extract_m3u8_formats(
-            '%s/hls/stream_%s/playlist.m3u8' % (server_url, uploader_id),
+            f'{server_url}/hls/stream_{uploader_id}/playlist.m3u8',
             channel_id, 'mp4', m3u8_id='hls', live=True)
-        self._sort_formats(formats)
 
         return {
             'id': channel_id,