X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fvideomega.py;h=27303031620a8c126797bcdd6207d2f2355c74be;hb=48246541da66a12486505804f9519391a298ff54;hp=9fc64d172e63ecb15469efc2a2085d8bccc06e53;hpb=a45c0a5d67b87e9ea16e2812f44753c9cb946636;p=youtube-dl diff --git a/youtube_dl/extractor/videomega.py b/youtube_dl/extractor/videomega.py index 9fc64d172..273030316 100644 --- a/youtube_dl/extractor/videomega.py +++ b/youtube_dl/extractor/videomega.py @@ -1,12 +1,15 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..compat import ( compat_urllib_parse, compat_urllib_request, ) from ..utils import ( + ExtractorError, remove_start, ) @@ -35,8 +38,11 @@ class VideoMegaIE(InfoExtractor): req.add_header('Referer', url) webpage = self._download_webpage(req, video_id) - escaped_data = self._search_regex( - r'unescape\("([^"]+)"\)', webpage, 'escaped data') + try: + escaped_data = re.findall(r'unescape\("([^"]+)"\)', webpage)[-1] + except IndexError: + raise ExtractorError('Unable to extract escaped data') + playlist = compat_urllib_parse.unquote(escaped_data) thumbnail = self._search_regex( @@ -56,5 +62,7 @@ class VideoMegaIE(InfoExtractor): 'title': title, 'formats': formats, 'thumbnail': thumbnail, - 'http_referer': iframe_url, + 'http_headers': { + 'Referer': iframe_url, + }, }