2021-11-18 21:43:22 +00:00
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..utils import (
|
|
|
|
|
ExtractorError,
|
|
|
|
|
traverse_obj,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MixchIE(InfoExtractor):
|
|
|
|
|
IE_NAME = 'mixch'
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?mixch\.tv/u/(?P<id>\d+)'
|
|
|
|
|
|
2022-01-19 13:45:35 +00:00
|
|
|
|
_TESTS = [{
|
2021-11-18 21:43:22 +00:00
|
|
|
|
'url': 'https://mixch.tv/u/16236849/live',
|
|
|
|
|
'skip': 'don\'t know if this live persists',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '16236849',
|
|
|
|
|
'title': '24配信シェア⭕️投票🙏💦',
|
|
|
|
|
'comment_count': 13145,
|
|
|
|
|
'view_count': 28348,
|
|
|
|
|
'timestamp': 1636189377,
|
|
|
|
|
'uploader': '🦥伊咲👶🏻#フレアワ',
|
|
|
|
|
'uploader_id': '16236849',
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://mixch.tv/u/16137876/live',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage(f'https://mixch.tv/u/{video_id}/live', video_id)
|
|
|
|
|
|
|
|
|
|
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)
|
2022-12-26 21:31:08 +00:00
|
|
|
|
|
|
|
|
|
is_live = initial_js_state.get('liveInfo')
|
|
|
|
|
if not is_live:
|
|
|
|
|
self.raise_no_formats('Livestream has ended or has not started', expected=True)
|
2021-11-18 21:43:22 +00:00
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'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,
|
|
|
|
|
'formats': [{
|
|
|
|
|
'format_id': 'hls',
|
|
|
|
|
'url': traverse_obj(initial_js_state, ('liveInfo', 'hls')) or 'https://d1hd0ww6piyb43.cloudfront.net/hls/torte_%s.m3u8' % video_id,
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'protocol': 'm3u8',
|
2022-12-26 21:31:08 +00:00
|
|
|
|
}] if is_live else [],
|
|
|
|
|
'live_status': 'is_live' if is_live else 'is_upcoming',
|
2021-11-18 21:43:22 +00:00
|
|
|
|
}
|
2022-01-19 13:45:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MixchArchiveIE(InfoExtractor):
|
|
|
|
|
IE_NAME = 'mixch:archive'
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?mixch\.tv/archive/(?P<id>\d+)'
|
|
|
|
|
|
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://mixch.tv/archive/421',
|
|
|
|
|
'skip': 'paid video, no DRM. expires at Jan 23',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '421',
|
|
|
|
|
'title': '96NEKO SHOW TIME',
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
|
|
html5_videos = self._parse_html5_media_entries(
|
|
|
|
|
url, webpage.replace('video-js', 'video'), video_id, 'hls')
|
|
|
|
|
if not html5_videos:
|
|
|
|
|
self.raise_login_required(method='cookies')
|
|
|
|
|
infodict = html5_videos[0]
|
|
|
|
|
infodict.update({
|
|
|
|
|
'id': video_id,
|
|
|
|
|
'title': self._html_search_regex(r'class="archive-title">(.+?)</', webpage, 'title')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return infodict
|