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