]>
Commit | Line | Data |
---|---|---|
b970dfdd | 1 | from .common import InfoExtractor |
1306f5ed RA |
2 | from ..utils import ( |
3 | int_or_none, | |
4 | parse_codecs, | |
5 | ) | |
b970dfdd | 6 | |
7 | ||
8 | class MinotoIE(InfoExtractor): | |
9 | _VALID_URL = r'(?:minoto:|https?://(?:play|iframe|embed)\.minoto-video\.com/(?P<player_id>[0-9]+)/)(?P<id>[a-zA-Z0-9]+)' | |
10 | ||
11 | def _real_extract(self, url): | |
5ad28e7f | 12 | mobj = self._match_valid_url(url) |
b970dfdd | 13 | player_id = mobj.group('player_id') or '1' |
14 | video_id = mobj.group('id') | |
15 | video_data = self._download_json('http://play.minoto-video.com/%s/%s.js' % (player_id, video_id), video_id) | |
16 | video_metadata = video_data['video-metadata'] | |
17 | formats = [] | |
18 | for fmt in video_data['video-files']: | |
19 | fmt_url = fmt.get('url') | |
20 | if not fmt_url: | |
21 | continue | |
22 | container = fmt.get('container') | |
23 | if container == 'hls': | |
24 | formats.extend(fmt_url, video_id, 'mp4', m3u8_id='hls', fatal=False) | |
25 | else: | |
26 | fmt_profile = fmt.get('profile') or {} | |
1306f5ed | 27 | formats.append({ |
b970dfdd | 28 | 'format_id': fmt_profile.get('name-short'), |
29 | 'format_note': fmt_profile.get('name'), | |
30 | 'url': fmt_url, | |
31 | 'container': container, | |
32 | 'tbr': int_or_none(fmt.get('bitrate')), | |
33 | 'filesize': int_or_none(fmt.get('filesize')), | |
34 | 'width': int_or_none(fmt.get('width')), | |
35 | 'height': int_or_none(fmt.get('height')), | |
b5ae35ee | 36 | **parse_codecs(fmt.get('codecs')), |
1306f5ed | 37 | }) |
b970dfdd | 38 | |
39 | return { | |
40 | 'id': video_id, | |
41 | 'title': video_metadata['title'], | |
42 | 'description': video_metadata.get('description'), | |
43 | 'thumbnail': video_metadata.get('video-poster', {}).get('url'), | |
44 | 'formats': formats, | |
45 | } |