]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mgtv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..utils
import int_or_none
8 class MGTVIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://www\.mgtv\.com/v/(?:[^/]+/)*(?P<id>\d+)\.html'
13 'url': 'http://www.mgtv.com/v/1/290525/f/3116640.html',
14 'md5': '1bdadcf760a0b90946ca68ee9a2db41a',
18 'title': '我是歌手第四季双年巅峰会:韩红李玟“双王”领军对抗',
19 'description': '我是歌手第四季双年巅峰会',
21 'thumbnail': 're:^https?://.*\.jpg$',
25 def _real_extract(self
, url
):
26 video_id
= self
._match
_id
(url
)
27 api_data
= self
._download
_json
(
28 'http://v.api.mgtv.com/player/video', video_id
,
29 query
={'video_id': video_id
})['data']
30 info
= api_data
['info']
33 for idx
, stream
in enumerate(api_data
['stream']):
34 stream_url
= stream
.get('url')
37 tbr
= int_or_none(self
._search
_regex
(
38 r
'(\d+)\.mp4', stream_url
, 'tbr', default
=None))
40 def extract_format(stream_url
, format_id
, idx
, query
={}):
41 format_info
= self
._download
_json
(
43 note
='Download video info for format %s' % format_id
or '#%d' % idx
, query
=query
)
45 'format_id': format_id
,
46 'url': format_info
['info'],
51 formats
.append(extract_format(
52 stream_url
, 'hls-%d' % tbr
if tbr
else None, idx
* 2))
53 formats
.append(extract_format(stream_url
.replace(
54 '/playlist.m3u8', ''), 'http-%d' % tbr
if tbr
else None, idx
* 2 + 1, {'pno': 1031}))
55 self
._sort
_formats
(formats
)
59 'title': info
['title'].strip(),
61 'description': info
.get('desc'),
62 'duration': int_or_none(info
.get('duration')),
63 'thumbnail': info
.get('thumb'),