aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-08-12 19:15:26 +0200
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-10-31 11:28:41 +0100
commitc6c555cf8a3e5457f84c6650b1f96a332db50d44 (patch)
treee78cb0f7f875e2f259e43d065bc5f5c10b8701f2
parentdb7e31b853d888d129c7eeb8532ac29fd704b977 (diff)
Fix metacafe.com downloads for some videos (fixes issue #189)
-rwxr-xr-xyoutube-dl36
1 files changed, 23 insertions, 13 deletions
diff --git a/youtube-dl b/youtube-dl
index 717d97d96..e9211b240 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -1036,20 +1036,30 @@ class MetacafeIE(InfoExtractor):
# Extract URL, uploader and title from webpage
self.report_extraction(video_id)
mobj = re.search(r'(?m)&mediaURL=([^&]+)', webpage)
- if mobj is None:
- self._downloader.trouble(u'ERROR: unable to extract media URL')
- return
- mediaURL = urllib.unquote(mobj.group(1))
-
- # Extract gdaKey if available
- mobj = re.search(r'(?m)&gdaKey=(.*?)&', webpage)
- if mobj is None:
- video_url = mediaURL
- #self._downloader.trouble(u'ERROR: unable to extract gdaKey')
- #return
+ if mobj is not None:
+ mediaURL = urllib.unquote(mobj.group(1))
+
+ # Extract gdaKey if available
+ mobj = re.search(r'(?m)&gdaKey=(.*?)&', webpage)
+ if mobj is None:
+ video_url = mediaURL
+ else:
+ gdaKey = mobj.group(1)
+ video_url = '%s?__gda__=%s' % (mediaURL, gdaKey)
else:
- gdaKey = mobj.group(1)
- video_url = '%s?__gda__=%s' % (mediaURL, gdaKey)
+ mobj = re.search(r' name="flashvars" value="(.*?)"', webpage)
+ if mobj is None:
+ self._downloader.trouble(u'ERROR: unable to extract media URL')
+ return
+ vardict = parse_qs(mobj.group(1))
+ if 'mediaData' not in vardict:
+ self._downloader.trouble(u'ERROR: unable to extract media URL')
+ return
+ mobj = re.search(r'"mediaURL":"(http.*?)","key":"(.*?)"', vardict['mediaData'][0])
+ if mobj is None:
+ self._downloader.trouble(u'ERROR: unable to extract media URL')
+ return
+ video_url = '%s?__gda__=%s' % (mobj.group(1).replace('\\/', '/'), mobj.group(2))
mobj = re.search(r'(?im)<title>(.*) - Video</title>', webpage)
if mobj is None: