]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/miomio.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urlparse
16 class MioMioIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?miomio\.tv/watch/cc(?P<id>[0-9]+)'
20 # "type=video" in flashvars
21 'url': 'http://www.miomio.tv/watch/cc88912/',
25 'title': '【SKY】字幕 铠武昭和VS平成 假面骑士大战FEAT战队 魔星字幕组 字幕',
28 'skip': 'Unable to load videos',
30 'url': 'http://www.miomio.tv/watch/cc184024/',
33 'title': '《动漫同人插画绘制》',
35 'playlist_mincount': 86,
36 'skip': 'Unable to load videos',
38 'url': 'http://www.miomio.tv/watch/cc173113/',
41 'title': 'The New Macbook 2015 上手试玩与简评'
43 'playlist_mincount': 2,
44 'skip': 'Unable to load videos',
47 'url': 'http://www.miomio.tv/watch/cc273997/',
48 'md5': '0b27a4b4495055d826813f8c3a6b2070',
52 'title': 'マツコの知らない世界【劇的進化SP!ビニール傘&冷凍食品2016】 1_2 - 16 05 31',
56 def _extract_mioplayer(self
, webpage
, video_id
, title
, http_headers
):
57 xml_config
= self
._search
_regex
(
58 r
'flashvars="type=(?:sina|video)&(.+?)&',
59 webpage
, 'xml config')
61 # skipping the following page causes lags and eventually connection drop-outs
62 self
._request
_webpage
(
63 'http://www.miomio.tv/mioplayer/mioplayerconfigfiles/xml.php?id=%s&r=%s' % (id, random
.randint(100, 999)),
66 vid_config_request
= sanitized_Request(
67 'http://www.miomio.tv/mioplayer/mioplayerconfigfiles/sina.php?{0}'.format(xml_config
),
70 # the following xml contains the actual configuration information on the video file(s)
71 vid_config
= self
._download
_xml
(vid_config_request
, video_id
)
73 if not int_or_none(xpath_text(vid_config
, 'timelength')):
74 raise ExtractorError('Unable to load videos!', expected
=True)
77 for f
in vid_config
.findall('./durl'):
78 segment_url
= xpath_text(f
, 'url', 'video url')
81 order
= xpath_text(f
, 'order', 'order')
85 segment_id
+= '-%s' % order
86 segment_title
+= ' part %s' % order
90 'title': segment_title
,
91 'duration': int_or_none(xpath_text(f
, 'length', 'duration'), 1000),
92 'http_headers': http_headers
,
97 def _real_extract(self
, url
):
98 video_id
= self
._match
_id
(url
)
99 webpage
= self
._download
_webpage
(url
, video_id
)
101 title
= self
._html
_search
_meta
(
102 'description', webpage
, 'title', fatal
=True)
104 mioplayer_path
= self
._search
_regex
(
105 r
'src="(/mioplayer(?:_h5)?/[^"]+)"', webpage
, 'ref_path')
107 if '_h5' in mioplayer_path
:
108 player_url
= compat_urlparse
.urljoin(url
, mioplayer_path
)
109 player_webpage
= self
._download
_webpage
(
110 player_url
, video_id
,
111 note
='Downloading player webpage', headers
={'Referer': url
})
112 entries
= self
._parse
_html
5_media
_entries
(player_url
, player_webpage
, video_id
)
113 http_headers
= {'Referer': player_url
}
115 http_headers
= {'Referer': 'http://www.miomio.tv%s' % mioplayer_path
}
116 entries
= self
._extract
_mioplayer
(webpage
, video_id
, title
, http_headers
)
118 if len(entries
) == 1:
120 segment
['id'] = video_id
121 segment
['title'] = title
122 segment
['http_headers'] = http_headers
126 '_type': 'multi_video',
130 'http_headers': http_headers
,