]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/miomio.py
937ba0f28bc41799f6489f4e246c9fac8a7c86e2
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战队 魔星字幕组 字幕',
29 # The server provides broken file
30 'skip_download': True,
33 'url': 'http://www.miomio.tv/watch/cc184024/',
36 'title': '《动漫同人插画绘制》',
38 'playlist_mincount': 86,
39 'skip': 'Unable to load videos',
41 'url': 'http://www.miomio.tv/watch/cc173113/',
44 'title': 'The New Macbook 2015 上手试玩与简评'
46 'playlist_mincount': 2,
47 'skip': 'Unable to load videos',
50 'url': 'http://www.miomio.tv/watch/cc273295/',
55 'title': 'アウト×デラックス 20160526',
58 # intermittent HTTP 500
59 'skip_download': True,
63 def _extract_mioplayer(self
, webpage
, video_id
, title
, http_headers
):
64 xml_config
= self
._search
_regex
(
65 r
'flashvars="type=(?:sina|video)&(.+?)&',
66 webpage
, 'xml config')
68 # skipping the following page causes lags and eventually connection drop-outs
69 self
._request
_webpage
(
70 'http://www.miomio.tv/mioplayer/mioplayerconfigfiles/xml.php?id=%s&r=%s' % (id, random
.randint(100, 999)),
73 vid_config_request
= sanitized_Request(
74 'http://www.miomio.tv/mioplayer/mioplayerconfigfiles/sina.php?{0}'.format(xml_config
),
77 # the following xml contains the actual configuration information on the video file(s)
78 vid_config
= self
._download
_xml
(vid_config_request
, video_id
)
80 if not int_or_none(xpath_text(vid_config
, 'timelength')):
81 raise ExtractorError('Unable to load videos!', expected
=True)
84 for f
in vid_config
.findall('./durl'):
85 segment_url
= xpath_text(f
, 'url', 'video url')
88 order
= xpath_text(f
, 'order', 'order')
92 segment_id
+= '-%s' % order
93 segment_title
+= ' part %s' % order
97 'title': segment_title
,
98 'duration': int_or_none(xpath_text(f
, 'length', 'duration'), 1000),
99 'http_headers': http_headers
,
104 def _real_extract(self
, url
):
105 video_id
= self
._match
_id
(url
)
106 webpage
= self
._download
_webpage
(url
, video_id
)
108 title
= self
._html
_search
_meta
(
109 'description', webpage
, 'title', fatal
=True)
111 mioplayer_path
= self
._search
_regex
(
112 r
'src="(/mioplayer(?:_h5)?/[^"]+)"', webpage
, 'ref_path')
114 if '_h5' in mioplayer_path
:
115 player_url
= compat_urlparse
.urljoin(url
, mioplayer_path
)
116 player_webpage
= self
._download
_webpage
(
117 player_url
, video_id
,
118 note
='Downloading player webpage', headers
={'Referer': url
})
119 entries
= self
._parse
_html
5_media
_entries
(player_url
, player_webpage
)
120 http_headers
= {'Referer': player_url
}
122 http_headers
= {'Referer': 'http://www.miomio.tv%s' % mioplayer_path
}
123 entries
= self
._extract
_mioplayer
(webpage
, video_id
, title
, http_headers
)
125 if len(entries
) == 1:
127 segment
['id'] = video_id
128 segment
['title'] = title
129 segment
['http_headers'] = http_headers
133 '_type': 'multi_video',
137 'http_headers': http_headers
,