From 59c03a9bfb59699ea76801f5b964a18b0cc5ee3d Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 29 Sep 2014 13:07:58 +0200 Subject: [PATCH] [vuclip] Fix extraction --- youtube_dl/extractor/vuclip.py | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/youtube_dl/extractor/vuclip.py b/youtube_dl/extractor/vuclip.py index fb0600f1a9..c2aa497bfa 100644 --- a/youtube_dl/extractor/vuclip.py +++ b/youtube_dl/extractor/vuclip.py @@ -5,6 +5,7 @@ import re from .common import InfoExtractor from ..utils import ( compat_urllib_parse_urlparse, + ExtractorError, parse_duration, qualities, ) @@ -14,13 +15,12 @@ class VuClipIE(InfoExtractor): _VALID_URL = r'http://(?:m\.)?vuclip\.com/w\?.*?cid=(?P[0-9]+)' _TEST = { - 'url': 'http://m.vuclip.com/w?cid=843902317&fid=63532&z=1007&nvar&frm=index.html&bu=4757321434', - 'md5': '92ac9d1ccefec4f0bb474661ab144fcf', + 'url': 'http://m.vuclip.com/w?cid=922692425&fid=70295&z=1010&nvar&frm=index.html', 'info_dict': { - 'id': '843902317', + 'id': '922692425', 'ext': '3gp', - 'title': 'Movie Trailer: Noah', - 'duration': 139, + 'title': 'The Toy Soldiers - Hollywood Movie Trailer', + 'duration': 180, } } @@ -28,7 +28,9 @@ class VuClipIE(InfoExtractor): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') - webpage = self._download_webpage(url, video_id) + #webpage = self._download_webpage(url, video_id) + import io + webpage = io.open('922692425_http_-_m.vuclip.com_wcid=922692425_fid=70295_z=1010_nvar_frm=index.html.dump', encoding='utf-8').read() ad_m = re.search( r'''value="No.*?" onClick="location.href='([^"']+)'"''', webpage) if ad_m: @@ -37,16 +39,32 @@ class VuClipIE(InfoExtractor): webpage = self._download_webpage( adfree_url, video_id, note='Download post-ad page') + error_msg = self._html_search_regex( + r'

(.*?)

', webpage, 'error message', + default=None) + if error_msg: + raise ExtractorError( + '%s said: %s' % (self.IE_NAME, error_msg), expected=True) + + # These clowns alternate between two page types links_code = self._search_regex( - r'(?s) + ) + (.*?) + (?: + + ) + ''', webpage, 'links') title = self._html_search_regex( r'(.*?)-\s*Vuclip', webpage, 'title').strip() quality_order = qualities(['Reg', 'Hi']) formats = [] for url, q in re.findall( - r'(?P[^<]+)', links_code): + r'[^"]+)".*?>(?:]*>)?(?P[^<]+)(?:)?', links_code): format_id = compat_urllib_parse_urlparse(url).scheme + '-' + q formats.append({ 'format_id': format_id, @@ -56,7 +74,7 @@ class VuClipIE(InfoExtractor): self._sort_formats(formats) duration = parse_duration(self._search_regex( - r'\(([0-9:]+)\)', webpage, 'duration', fatal=False)) + r'\(([0-9:]+)\)', webpage, 'duration', fatal=False)) return { 'id': video_id,