summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-08-12 19:21:06 +0200
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-10-31 11:28:41 +0100
commit6b57e8c5ac169f3406eafcbe5db095242c811748 (patch)
treea509a0d52ec6e6593a48416248269569fa3eafc8
parentc6c555cf8a3e5457f84c6650b1f96a332db50d44 (diff)
downloadyoutube-dl-6b57e8c5ac169f3406eafcbe5db095242c811748.tar.gz
youtube-dl-6b57e8c5ac169f3406eafcbe5db095242c811748.tar.xz
youtube-dl-6b57e8c5ac169f3406eafcbe5db095242c811748.zip
Extract the video extension from the media URL in metacafe.com
-rwxr-xr-xyoutube-dl6
1 files changed, 4 insertions, 2 deletions
diff --git a/youtube-dl b/youtube-dl
index e9211b240..7bb8146e0 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -1022,7 +1022,6 @@ class MetacafeIE(InfoExtractor):
 		self._downloader.increment_downloads()
 
 		simple_title = mobj.group(2).decode('utf-8')
-		video_extension = 'flv'
 
 		# Retrieve video webpage to extract further information
 		request = urllib2.Request('http://www.metacafe.com/watch/%s/' % video_id)
@@ -1038,6 +1037,7 @@ class MetacafeIE(InfoExtractor):
 		mobj = re.search(r'(?m)&mediaURL=([^&]+)', webpage)
 		if mobj is not None:
 			mediaURL = urllib.unquote(mobj.group(1))
+			video_extension = mediaURL[-3:]
 			
 			# Extract gdaKey if available
 			mobj = re.search(r'(?m)&gdaKey=(.*?)&', webpage)
@@ -1059,7 +1059,9 @@ class MetacafeIE(InfoExtractor):
 			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))
+			mediaURL = mobj.group(1).replace('\\/', '/')
+			video_extension = mediaURL[-3:]
+			video_url = '%s?__gda__=%s' % (mediaURL, mobj.group(2))
 
 		mobj = re.search(r'(?im)<title>(.*) - Video</title>', webpage)
 		if mobj is None: