2021-11-18 22:45:13 +00:00
|
|
|
from .common import InfoExtractor
|
2023-02-12 04:17:37 +00:00
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
|
|
|
UserNotLive,
|
|
|
|
lowercase_escape,
|
2024-05-26 19:27:21 +00:00
|
|
|
traverse_obj,
|
2023-02-12 04:17:37 +00:00
|
|
|
)
|
2021-11-18 22:45:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StripchatIE(InfoExtractor):
|
2022-07-30 11:35:07 +00:00
|
|
|
_VALID_URL = r'https?://stripchat\.com/(?P<id>[^/?#]+)'
|
2021-11-18 22:45:13 +00:00
|
|
|
_TESTS = [{
|
2022-11-06 20:39:09 +00:00
|
|
|
'url': 'https://stripchat.com/Joselin_Flower',
|
2021-11-18 22:45:13 +00:00
|
|
|
'info_dict': {
|
2022-11-06 20:39:09 +00:00
|
|
|
'id': 'Joselin_Flower',
|
2021-11-18 22:45:13 +00:00
|
|
|
'ext': 'mp4',
|
2022-11-06 20:39:09 +00:00
|
|
|
'title': 're:^Joselin_Flower [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
2021-11-18 22:45:13 +00:00
|
|
|
'description': str,
|
|
|
|
'is_live': True,
|
|
|
|
'age_limit': 18,
|
|
|
|
},
|
|
|
|
'skip': 'Room is offline',
|
2022-07-30 11:35:07 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://stripchat.com/Rakhijaan@xh',
|
2024-06-11 23:09:58 +00:00
|
|
|
'only_matching': True,
|
2021-11-18 22:45:13 +00:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
2022-08-31 15:40:59 +00:00
|
|
|
webpage = self._download_webpage(url, video_id, headers=self.geo_verification_headers())
|
2024-11-23 19:40:45 +00:00
|
|
|
data = self._search_json(
|
|
|
|
r'<script\b[^>]*>\s*window\.__PRELOADED_STATE__\s*=',
|
|
|
|
webpage, 'data', video_id, transform_source=lowercase_escape)
|
2021-11-18 22:45:13 +00:00
|
|
|
|
2024-11-23 19:40:45 +00:00
|
|
|
if traverse_obj(data, ('viewCam', 'show', {dict})):
|
|
|
|
raise ExtractorError('Model is in a private show', expected=True)
|
|
|
|
if not traverse_obj(data, ('viewCam', 'model', 'isLive', {bool})):
|
2023-02-12 04:17:37 +00:00
|
|
|
raise UserNotLive(video_id=video_id)
|
2021-11-18 22:45:13 +00:00
|
|
|
|
2024-11-23 19:40:45 +00:00
|
|
|
model_id = data['viewCam']['model']['id']
|
2022-11-06 20:39:09 +00:00
|
|
|
|
2022-11-08 06:44:47 +00:00
|
|
|
formats = []
|
2024-11-23 19:40:45 +00:00
|
|
|
# HLS hosts are currently found in .configV3.static.features.hlsFallback.fallbackDomains[]
|
|
|
|
# The rest of the path is for backwards compatibility and to guard against A/B testing
|
|
|
|
for host in traverse_obj(data, ((('config', 'data'), ('configV3', 'static')), (
|
2023-02-12 04:17:37 +00:00
|
|
|
(('features', 'featuresV2'), 'hlsFallback', 'fallbackDomains', ...), 'hlsStreamHost'))):
|
2022-11-06 20:39:09 +00:00
|
|
|
formats = self._extract_m3u8_formats(
|
2023-06-15 10:56:26 +00:00
|
|
|
f'https://edge-hls.{host}/hls/{model_id}/master/{model_id}_auto.m3u8',
|
2022-11-06 20:39:09 +00:00
|
|
|
video_id, ext='mp4', m3u8_id='hls', fatal=False, live=True)
|
|
|
|
if formats:
|
|
|
|
break
|
2022-11-08 06:44:47 +00:00
|
|
|
if not formats:
|
2024-11-23 19:40:45 +00:00
|
|
|
self.raise_no_formats('Unable to extract stream host', video_id=video_id)
|
2021-11-18 22:45:13 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2021-12-15 16:00:46 +00:00
|
|
|
'title': video_id,
|
2021-11-18 22:45:13 +00:00
|
|
|
'description': self._og_search_description(webpage),
|
|
|
|
'is_live': True,
|
|
|
|
'formats': formats,
|
|
|
|
# Stripchat declares the RTA meta-tag, but in an non-standard format so _rta_search() can't be used
|
|
|
|
'age_limit': 18,
|
|
|
|
}
|