mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-02 11:26:41 +00:00
[ie/mixch] Fix extractor (#9608)
Closes #9536 Authored by: bashonly, nipotan
This commit is contained in:
parent
16be117729
commit
4c3b7a0769
|
@ -1,6 +1,6 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..networking.exceptions import HTTPError
|
from ..networking.exceptions import HTTPError
|
||||||
from ..utils import ExtractorError, UserNotLive, url_or_none
|
from ..utils import ExtractorError, UserNotLive, int_or_none, url_or_none
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,25 +27,23 @@ class MixchIE(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(f'https://mixch.tv/u/{video_id}/live', video_id)
|
data = self._download_json(f'https://mixch.tv/api-web/users/{video_id}/live', video_id)
|
||||||
|
if not traverse_obj(data, ('liveInfo', {dict})):
|
||||||
initial_js_state = self._parse_json(self._search_regex(
|
|
||||||
r'(?m)^\s*window\.__INITIAL_JS_STATE__\s*=\s*(\{.+?\});\s*$', webpage, 'initial JS state'), video_id)
|
|
||||||
if not initial_js_state.get('liveInfo'):
|
|
||||||
raise UserNotLive(video_id=video_id)
|
raise UserNotLive(video_id=video_id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': traverse_obj(initial_js_state, ('liveInfo', 'title')),
|
|
||||||
'comment_count': traverse_obj(initial_js_state, ('liveInfo', 'comments')),
|
|
||||||
'view_count': traverse_obj(initial_js_state, ('liveInfo', 'visitor')),
|
|
||||||
'timestamp': traverse_obj(initial_js_state, ('liveInfo', 'created')),
|
|
||||||
'uploader': traverse_obj(initial_js_state, ('broadcasterInfo', 'name')),
|
|
||||||
'uploader_id': video_id,
|
'uploader_id': video_id,
|
||||||
|
**traverse_obj(data, {
|
||||||
|
'title': ('liveInfo', 'title', {str}),
|
||||||
|
'comment_count': ('liveInfo', 'comments', {int_or_none}),
|
||||||
|
'view_count': ('liveInfo', 'visitor', {int_or_none}),
|
||||||
|
'timestamp': ('liveInfo', 'created', {int_or_none}),
|
||||||
|
'uploader': ('broadcasterInfo', 'name', {str}),
|
||||||
|
}),
|
||||||
'formats': [{
|
'formats': [{
|
||||||
'format_id': 'hls',
|
'format_id': 'hls',
|
||||||
'url': (traverse_obj(initial_js_state, ('liveInfo', 'hls'))
|
'url': data['liveInfo']['hls'],
|
||||||
or f'https://d1hd0ww6piyb43.cloudfront.net/hls/torte_{video_id}.m3u8'),
|
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'protocol': 'm3u8',
|
'protocol': 'm3u8',
|
||||||
}],
|
}],
|
||||||
|
|
Loading…
Reference in a new issue