0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-12-29 01:51:06 +00:00

[ie/stripchat] Fix extractor (#11596)

Closes #11587
Authored by: gitninja1234
This commit is contained in:
gitninja1234 2024-11-24 01:10:45 +05:30 committed by GitHub
parent ccf0a6b86b
commit 16336c51d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,24 +28,21 @@ class StripchatIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id, headers=self.geo_verification_headers()) webpage = self._download_webpage(url, video_id, headers=self.geo_verification_headers())
data = self._search_json(
r'<script\b[^>]*>\s*window\.__PRELOADED_STATE__\s*=',
webpage, 'data', video_id, transform_source=lowercase_escape)
data = self._parse_json( if traverse_obj(data, ('viewCam', 'show', {dict})):
self._search_regex( raise ExtractorError('Model is in a private show', expected=True)
r'<script\b[^>]*>\s*window\.__PRELOADED_STATE__\s*=(?P<value>.*?)<\/script>', if not traverse_obj(data, ('viewCam', 'model', 'isLive', {bool})):
webpage, 'data', default='{}', group='value'),
video_id, transform_source=lowercase_escape, fatal=False)
if not data:
raise ExtractorError('Unable to find configuration for stream.')
if traverse_obj(data, ('viewCam', 'show'), expected_type=dict):
raise ExtractorError('Model is in private show', expected=True)
elif not traverse_obj(data, ('viewCam', 'model', 'isLive'), expected_type=bool):
raise UserNotLive(video_id=video_id) raise UserNotLive(video_id=video_id)
model_id = traverse_obj(data, ('viewCam', 'model', 'id'), expected_type=int) model_id = data['viewCam']['model']['id']
formats = [] formats = []
for host in traverse_obj(data, ('config', 'data', ( # 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')), (
(('features', 'featuresV2'), 'hlsFallback', 'fallbackDomains', ...), 'hlsStreamHost'))): (('features', 'featuresV2'), 'hlsFallback', 'fallbackDomains', ...), 'hlsStreamHost'))):
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
f'https://edge-hls.{host}/hls/{model_id}/master/{model_id}_auto.m3u8', f'https://edge-hls.{host}/hls/{model_id}/master/{model_id}_auto.m3u8',
@ -53,7 +50,7 @@ def _real_extract(self, url):
if formats: if formats:
break break
if not formats: if not formats:
self.raise_no_formats('No active streams found', expected=True) self.raise_no_formats('Unable to extract stream host', video_id=video_id)
return { return {
'id': video_id, 'id': video_id,