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/',
22 'md5': '317a5f7f6b544ce8419b784ca8edae65',
26 'title': '【SKY】字幕 铠武昭和VS平成 假面骑士大战FEAT战队 魔星字幕组 字幕',
30 'url': 'http://www.miomio.tv/watch/cc184024/',
33 'title': '《动漫同人插画绘制》',
35 'playlist_mincount': 86,
36 'skip': 'This video takes time too long for retrieving the URL',
38 'url': 'http://www.miomio.tv/watch/cc173113/',
41 'title': 'The New Macbook 2015 上手试玩与简评'
43 'playlist_mincount': 2,
46 'url': 'http://www.miomio.tv/watch/cc273295/',
51 'title': 'アウト×デラックス 20160526',
54 # intermittent HTTP 500
55 'skip_download': True,
59 def _extract_mioplayer(self, webpage, video_id, title, http_headers):
60 xml_config = self._search_regex(
61 r'flashvars="type=(?:sina|video)&(.+?)&',
62 webpage, 'xml config')
64 # skipping the following page causes lags and eventually connection drop-outs
65 self._request_webpage(
66 'http://www.miomio.tv/mioplayer/mioplayerconfigfiles/xml.php?id=%s&r=%s' % (id, random.randint(100, 999)),
69 vid_config_request = sanitized_Request(
70 'http://www.miomio.tv/mioplayer/mioplayerconfigfiles/sina.php?{0}'.format(xml_config),
73 # the following xml contains the actual configuration information on the video file(s)
74 vid_config = self._download_xml(vid_config_request, video_id)
76 if not int_or_none(xpath_text(vid_config, 'timelength')):
77 raise ExtractorError('Unable to load videos!', expected=True)
80 for f in vid_config.findall('./durl'):
81 segment_url = xpath_text(f, 'url', 'video url')
84 order = xpath_text(f, 'order', 'order')
88 segment_id += '-%s' % order
89 segment_title += ' part %s' % order
93 'title': segment_title,
94 'duration': int_or_none(xpath_text(f, 'length', 'duration'), 1000),
95 'http_headers': http_headers,
100 def _real_extract(self, url):
101 video_id = self._match_id(url)
102 webpage = self._download_webpage(url, video_id)
104 title = self._html_search_meta(
105 'description', webpage, 'title', fatal=True)
107 mioplayer_path = self._search_regex(
108 r'src="(/mioplayer(?:_h5)?/[^"]+)"', webpage, 'ref_path')
110 if '_h5' in mioplayer_path:
111 player_url = compat_urlparse.urljoin(url, mioplayer_path)
112 player_webpage = self._download_webpage(
113 player_url, video_id,
114 note='Downloading player webpage', headers={'Referer': url})
115 entries = self._parse_html5_media_entries(player_url, player_webpage)
116 http_headers = {'Referer': player_url}
118 http_headers = {'Referer': 'http://www.miomio.tv%s' % mioplayer_path}
119 entries = self._extract_mioplayer(webpage, video_id, title, http_headers)
121 if len(entries) == 1:
123 segment['id'] = video_id
124 segment['title'] = title
125 segment['http_headers'] = http_headers
129 '_type': 'multi_video',
133 'http_headers': http_headers,