]>
Commit | Line | Data |
---|---|---|
aec74dd9 PH |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
1cc79574 | 4 | from ..compat import ( |
aec74dd9 | 5 | compat_urllib_parse_urlparse, |
1cc79574 PH |
6 | ) |
7 | from ..utils import ( | |
59c03a9b | 8 | ExtractorError, |
aec74dd9 | 9 | parse_duration, |
e2dbcaa1 | 10 | remove_end, |
aec74dd9 PH |
11 | ) |
12 | ||
13 | ||
14 | class VuClipIE(InfoExtractor): | |
5886b38d | 15 | _VALID_URL = r'https?://(?:m\.)?vuclip\.com/w\?.*?cid=(?P<id>[0-9]+)' |
aec74dd9 PH |
16 | |
17 | _TEST = { | |
ecc90093 | 18 | 'url': 'http://m.vuclip.com/w?cid=1129900602&bu=8589892792&frm=w&z=34801&op=0&oc=843169247§ion=recommend', |
aec74dd9 | 19 | 'info_dict': { |
ecc90093 | 20 | 'id': '1129900602', |
aec74dd9 | 21 | 'ext': '3gp', |
ecc90093 YCH |
22 | 'title': 'Top 10 TV Convicts', |
23 | 'duration': 733, | |
aec74dd9 PH |
24 | } |
25 | } | |
26 | ||
27 | def _real_extract(self, url): | |
1cc79574 | 28 | video_id = self._match_id(url) |
a7a747d6 | 29 | webpage = self._download_webpage(url, video_id) |
1cc79574 | 30 | |
aec74dd9 PH |
31 | ad_m = re.search( |
32 | r'''value="No.*?" onClick="location.href='([^"']+)'"''', webpage) | |
33 | if ad_m: | |
34 | urlr = compat_urllib_parse_urlparse(url) | |
35 | adfree_url = urlr.scheme + '://' + urlr.netloc + ad_m.group(1) | |
36 | webpage = self._download_webpage( | |
37 | adfree_url, video_id, note='Download post-ad page') | |
38 | ||
59c03a9b PH |
39 | error_msg = self._html_search_regex( |
40 | r'<p class="message">(.*?)</p>', webpage, 'error message', | |
41 | default=None) | |
42 | if error_msg: | |
43 | raise ExtractorError( | |
44 | '%s said: %s' % (self.IE_NAME, error_msg), expected=True) | |
45 | ||
46 | # These clowns alternate between two page types | |
e2dbcaa1 YCH |
47 | video_url = self._search_regex( |
48 | r'<a[^>]+href="([^"]+)"[^>]*><img[^>]+src="[^"]*/play\.gif', | |
49 | webpage, 'video URL', default=None) | |
50 | if video_url: | |
51 | formats = [{ | |
52 | 'url': video_url, | |
53 | }] | |
54 | else: | |
ecc90093 | 55 | formats = self._parse_html5_media_entries(url, webpage, video_id)[0]['formats'] |
aec74dd9 | 56 | |
e2dbcaa1 YCH |
57 | title = remove_end(self._html_search_regex( |
58 | r'<title>(.*?)-\s*Vuclip</title>', webpage, 'title').strip(), ' - Video') | |
aec74dd9 | 59 | |
e2dbcaa1 YCH |
60 | duration = parse_duration(self._html_search_regex( |
61 | r'[(>]([0-9]+:[0-9]+)(?:<span|\))', webpage, 'duration', fatal=False)) | |
aec74dd9 PH |
62 | |
63 | return { | |
64 | 'id': video_id, | |
65 | 'formats': formats, | |
66 | 'title': title, | |
67 | 'duration': duration, | |
68 | } |