]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/mixch.py
1 from .common
import InfoExtractor
2 from ..networking
.exceptions
import HTTPError
3 from ..utils
import ExtractorError
, UserNotLive
, url_or_none
4 from ..utils
.traversal
import traverse_obj
7 class MixchIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?mixch\.tv/u/(?P<id>\d+)'
12 'url': 'https://mixch.tv/u/16236849/live',
13 'skip': 'don\'t know if this live persists',
16 'title': '24配信シェア⭕️投票🙏💦',
17 'comment_count': 13145,
19 'timestamp': 1636189377,
20 'uploader': '🦥伊咲👶🏻#フレアワ',
21 'uploader_id': '16236849',
24 'url': 'https://mixch.tv/u/16137876/live',
25 'only_matching': True,
28 def _real_extract(self
, url
):
29 video_id
= self
._match
_id
(url
)
30 webpage
= self
._download
_webpage
(f
'https://mixch.tv/u/{video_id}/live', video_id
)
32 initial_js_state
= self
._parse
_json
(self
._search
_regex
(
33 r
'(?m)^\s*window\.__INITIAL_JS_STATE__\s*=\s*(\{.+?\});\s*$', webpage
, 'initial JS state'), video_id
)
34 if not initial_js_state
.get('liveInfo'):
35 raise UserNotLive(video_id
=video_id
)
39 'title': traverse_obj(initial_js_state
, ('liveInfo', 'title')),
40 'comment_count': traverse_obj(initial_js_state
, ('liveInfo', 'comments')),
41 'view_count': traverse_obj(initial_js_state
, ('liveInfo', 'visitor')),
42 'timestamp': traverse_obj(initial_js_state
, ('liveInfo', 'created')),
43 'uploader': traverse_obj(initial_js_state
, ('broadcasterInfo', 'name')),
44 'uploader_id': video_id
,
47 'url': (traverse_obj(initial_js_state
, ('liveInfo', 'hls'))
48 or f
'https://d1hd0ww6piyb43.cloudfront.net/hls/torte_{video_id}.m3u8'),
56 class MixchArchiveIE(InfoExtractor
):
57 IE_NAME
= 'mixch:archive'
58 _VALID_URL
= r
'https?://(?:www\.)?mixch\.tv/archive/(?P<id>\d+)'
61 'url': 'https://mixch.tv/archive/421',
62 'skip': 'paid video, no DRM. expires at Jan 23',
66 'title': '96NEKO SHOW TIME',
69 'url': 'https://mixch.tv/archive/1213',
70 'skip': 'paid video, no DRM. expires at Dec 31, 2023',
74 'title': '【特別トーク番組アーカイブス】Merm4id×燐舞曲 2nd LIVE「VERSUS」',
75 'release_date': '20231201',
79 'url': 'https://mixch.tv/archive/1214',
80 'only_matching': True,
83 def _real_extract(self
, url
):
84 video_id
= self
._match
_id
(url
)
87 info_json
= self
._download
_json
(
88 f
'https://mixch.tv/api-web/archive/{video_id}', video_id
)['archive']
89 except ExtractorError
as e
:
90 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 401:
91 self
.raise_login_required()
96 'title': traverse_obj(info_json
, ('title', {str}
)),
97 'formats': self
._extract
_m
3u8_formats
(info_json
['archiveURL'], video_id
),
98 'thumbnail': traverse_obj(info_json
, ('thumbnailURL', {url_or_none}
)),