diff options
author | Philipp Hagemeister <[email protected]> | 2014-08-21 13:37:19 +0200 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2014-08-21 13:37:19 +0200 |
commit | c15235cd073c3dd7d796e36c69cc5ec67f97ffe7 (patch) | |
tree | 708fe62de94974748d689c86e4f2def39c378a46 /youtube_dl/extractor/metacafe.py | |
parent | 12c3ec3382c2eace1afe1840da4f91939bd6b785 (diff) | |
download | youtube-dl-c15235cd073c3dd7d796e36c69cc5ec67f97ffe7.tar.gz youtube-dl-c15235cd073c3dd7d796e36c69cc5ec67f97ffe7.zip |
[metacafe] Avoid excessive nesting
Diffstat (limited to 'youtube_dl/extractor/metacafe.py')
-rw-r--r-- | youtube_dl/extractor/metacafe.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/youtube_dl/extractor/metacafe.py b/youtube_dl/extractor/metacafe.py index c3a4a333c..96a4f1018 100644 --- a/youtube_dl/extractor/metacafe.py +++ b/youtube_dl/extractor/metacafe.py @@ -134,6 +134,7 @@ class MetacafeIE(InfoExtractor): # Extract URL, uploader and title from webpage self.report_extraction(video_id) + video_url = None mobj = re.search(r'(?m)&mediaURL=([^&]+)', webpage) if mobj is not None: mediaURL = compat_urllib_parse.unquote(mobj.group(1)) @@ -146,14 +147,16 @@ class MetacafeIE(InfoExtractor): else: gdaKey = mobj.group(1) video_url = '%s?__gda__=%s' % (mediaURL, gdaKey) - else: + if video_url is None: mobj = re.search(r'<video src="([^"]+)"', webpage) if mobj: video_url = mobj.group(1) video_ext = 'mp4' - else: - flashvars = self._search_regex( - r' name="flashvars" value="(.*?)"', webpage, 'flashvars') + if video_url is None: + flashvars = self._search_regex( + r' name="flashvars" value="(.*?)"', webpage, 'flashvars', + default=None) + if flashvars: vardict = compat_parse_qs(flashvars) if 'mediaData' not in vardict: raise ExtractorError('Unable to extract media URL') @@ -165,6 +168,7 @@ class MetacafeIE(InfoExtractor): video_url = '%s?__gda__=%s' % (mediaURL, mobj.group('key')) video_ext = determine_ext(video_url) + video_title = self._html_search_regex( r'(?im)<title>(.*) - Video</title>', webpage, 'title') description = self._og_search_description(webpage) |