mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-15 17:08:29 +00:00
fix: Update SouthParkDeIE to use modern API extraction
This commit is contained in:
parent
fdfac32149
commit
52876aa5a7
@ -1,7 +1,7 @@
|
|||||||
from .mtv import MTVServicesInfoExtractor
|
from .mtv import MTVServicesInfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
traverse_obj,
|
|
||||||
random_uuidv4,
|
random_uuidv4,
|
||||||
|
traverse_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -110,26 +110,20 @@ def _real_extract(self, url):
|
|||||||
data = self._parse_json(self._search_regex(
|
data = self._parse_json(self._search_regex(
|
||||||
r'window\.__DATA__\s*=\s*({.+?});', webpage, 'data'), display_id)
|
r'window\.__DATA__\s*=\s*({.+?});', webpage, 'data'), display_id)
|
||||||
|
|
||||||
# Find the videoDetail object by first finding the MainContainer component
|
|
||||||
video_detail = traverse_obj(data, (
|
video_detail = traverse_obj(data, (
|
||||||
'children', lambda _, v: v.get('type') == 'MainContainer',
|
'children', lambda _, v: v.get('type') == 'MainContainer',
|
||||||
'children', 0, 'children', 0, 'props', 'videoDetail'
|
'children', 0, 'children', 0, 'props', 'videoDetail'
|
||||||
), get_all=False)
|
), default=traverse_obj(data, ('children', 0, 'videoDetail')))
|
||||||
|
|
||||||
# Fallback for a simpler data structure found on some pages
|
|
||||||
if not video_detail:
|
|
||||||
video_detail = traverse_obj(data, ('children', 0, 'videoDetail'), get_all=False)
|
|
||||||
|
|
||||||
api_url = video_detail['videoServiceUrl']
|
api_url = video_detail['videoServiceUrl']
|
||||||
|
|
||||||
# Call the Topaz API to get the final stream URL
|
|
||||||
api_data = self._download_json(
|
api_data = self._download_json(
|
||||||
api_url, display_id, 'Fetching video metadata', query={
|
api_url, display_id, 'Fetching video metadata', query={
|
||||||
'ssus': random_uuidv4(),
|
'ssus': random_uuidv4(),
|
||||||
'clientPlatform': 'mobile',
|
'clientPlatform': 'mobile',
|
||||||
})
|
})
|
||||||
|
|
||||||
hls_url = traverse_obj(api_data, ('stitchedstream', 'source'))
|
hls_url = traverse_obj(api_data, ('stitchedstream', 'source'), expected_type=str)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_detail['id'],
|
'id': video_detail['id'],
|
||||||
|
Loading…
Reference in New Issue
Block a user