2016-03-12 22:13:25 +01:00
|
|
|
from .common import InfoExtractor
|
2018-05-16 20:11:48 +02:00
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
parse_codecs,
|
|
|
|
)
|
2016-03-12 22:13:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MinotoIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'(?:minoto:|https?://(?:play|iframe|embed)\.minoto-video\.com/(?P<player_id>[0-9]+)/)(?P<id>[a-zA-Z0-9]+)'
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
mobj = self._match_valid_url(url)
|
2016-03-12 22:13:25 +01:00
|
|
|
player_id = mobj.group('player_id') or '1'
|
|
|
|
video_id = mobj.group('id')
|
2024-06-12 01:09:58 +02:00
|
|
|
video_data = self._download_json(f'http://play.minoto-video.com/{player_id}/{video_id}.js', video_id)
|
2016-03-12 22:13:25 +01:00
|
|
|
video_metadata = video_data['video-metadata']
|
|
|
|
formats = []
|
|
|
|
for fmt in video_data['video-files']:
|
|
|
|
fmt_url = fmt.get('url')
|
|
|
|
if not fmt_url:
|
|
|
|
continue
|
|
|
|
container = fmt.get('container')
|
|
|
|
if container == 'hls':
|
2024-03-10 15:22:49 +01:00
|
|
|
formats.extend(self._extract_m3u8_formats(fmt_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
|
2016-03-12 22:13:25 +01:00
|
|
|
else:
|
|
|
|
fmt_profile = fmt.get('profile') or {}
|
2018-05-16 20:11:48 +02:00
|
|
|
formats.append({
|
2016-03-12 22:13:25 +01:00
|
|
|
'format_id': fmt_profile.get('name-short'),
|
|
|
|
'format_note': fmt_profile.get('name'),
|
|
|
|
'url': fmt_url,
|
|
|
|
'container': container,
|
|
|
|
'tbr': int_or_none(fmt.get('bitrate')),
|
|
|
|
'filesize': int_or_none(fmt.get('filesize')),
|
|
|
|
'width': int_or_none(fmt.get('width')),
|
|
|
|
'height': int_or_none(fmt.get('height')),
|
2021-10-09 02:23:15 +02:00
|
|
|
**parse_codecs(fmt.get('codecs')),
|
2018-05-16 20:11:48 +02:00
|
|
|
})
|
2016-03-12 22:13:25 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': video_metadata['title'],
|
|
|
|
'description': video_metadata.get('description'),
|
|
|
|
'thumbnail': video_metadata.get('video-poster', {}).get('url'),
|
|
|
|
'formats': formats,
|
|
|
|
}
|