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