]>
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$',
24 # no tbr extracted from stream_url
25 'url': 'http://www.mgtv.com/v/1/1/f/3324755.html',
26 'only_matching': True,
29 def _real_extract(self
, url
):
30 video_id
= self
._match
_id
(url
)
31 api_data
= self
._download
_json
(
32 'http://v.api.mgtv.com/player/video', video_id
,
33 query
={'video_id': video_id
},
34 headers
=self
.geo_verification_headers())['data']
35 info
= api_data
['info']
38 for idx
, stream
in enumerate(api_data
['stream']):
39 stream_url
= stream
.get('url')
42 tbr
= int_or_none(self
._search
_regex
(
43 r
'(\d+)\.mp4', stream_url
, 'tbr', default
=None))
45 def extract_format(stream_url
, format_id
, idx
, query
={}):
46 format_info
= self
._download
_json
(
48 note
='Download video info for format %s' % (format_id
or '#%d' % idx
),
51 'format_id': format_id
,
52 'url': format_info
['info'],
57 formats
.append(extract_format(
58 stream_url
, 'hls-%d' % tbr
if tbr
else None, idx
* 2))
59 formats
.append(extract_format(stream_url
.replace(
60 '/playlist.m3u8', ''), 'http-%d' % tbr
if tbr
else None, idx
* 2 + 1, {'pno': 1031}))
61 self
._sort
_formats
(formats
)
65 'title': info
['title'].strip(),
67 'description': info
.get('desc'),
68 'duration': int_or_none(info
.get('duration')),
69 'thumbnail': info
.get('thumb'),