From 368cb1fd0a4f92f041ad3d11eb52beec59417715 Mon Sep 17 00:00:00 2001 From: Laurent Raufaste Date: Sun, 29 May 2011 12:36:12 -0400 Subject: [PATCH] Fixed dailymotion video nd uploader extractor --- youtube-dl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/youtube-dl b/youtube-dl index 3ac27a857..bd666071d 100755 --- a/youtube-dl +++ b/youtube-dl @@ -30,6 +30,7 @@ import time import urllib import urllib2 import zlib +import json # parse_qs was moved from the cgi module to the urlparse module recently. try: @@ -1328,16 +1329,21 @@ class DailymotionIE(InfoExtractor): return # Extract URL, uploader and title from webpage + # First we need to get the sequence urlencoded json variable self.report_extraction(video_id) - mobj = re.search(r'(?i)addVariable\(\"video\"\s*,\s*\"([^\"]*)\"\)', webpage) + mobj = re.search(r'(?i)addVariable\(\"sequence\"\s*,\s*\"([^\"]*)\"\)', webpage) if mobj is None: self._downloader.trouble(u'ERROR: unable to extract media URL') return - mediaURL = urllib.unquote(mobj.group(1)) # if needed add http://www.dailymotion.com/ if relative URL - - video_url = mediaURL + sequenceJsonContent = urllib.unquote_plus(mobj.group(1)) + sequenceJson = json.loads(sequenceJsonContent) + try: + video_url = sequenceJson[0]["layerList"][0]["sequenceList"][1]["layerList"][2]["param"]["videoPluginParameters"]["hqURL"] + except: + self._downloader.trouble(u'ERROR: unable to extract media URL') + return # '' mobj = re.search(r'(?im)Dailymotion\s*[\-:]\s*(.+?)', webpage) @@ -1347,11 +1353,12 @@ class DailymotionIE(InfoExtractor): video_title = mobj.group(1).decode('utf-8') video_title = sanitize_title(video_title) - mobj = re.search(r'(?im)(.+?)', webpage) - if mobj is None: + # Extract the video uploader nickname from the sequence JSON + try: + video_uploader = sequenceJson[0]["layerList"][0]["sequenceList"][1]["layerList"][0]["param"]["metadata"]["uploader"] + except: self._downloader.trouble(u'ERROR: unable to extract uploader nickname') return - video_uploader = mobj.group(1) try: # Process video information