From 7401ca7c5f5fe84f4d2e638adc4cd50e2a9b6285 Mon Sep 17 00:00:00 2001 From: knagano Date: Mon, 26 Sep 2011 20:57:58 +0900 Subject: [PATCH] DailymotionIE: Added hd1080URL, hd720URL, hqURL support. Now video_uploader is optional. --- youtube-dl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/youtube-dl b/youtube-dl index 2b08fab74..59ff1a854 100755 --- a/youtube-dl +++ b/youtube-dl @@ -1563,12 +1563,19 @@ class DailymotionIE(InfoExtractor): # Extract URL, uploader and title from webpage self.report_extraction(video_id) - mobj = re.search(r'(?i)addVariable\(\"sequence\"\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 sequence = urllib.unquote(mobj.group(1)) - mobj = re.search(r',\"sdURL\"\:\"([^\"]+?)\",', sequence) + + mobj = None + for key in ['hd1080URL', 'hd720URL', 'hqURL', 'sdURL']: + pattern = re.compile(r',\"%s\"\:\"([^\"]+)\",' % key) + mobj = re.search(pattern, sequence) + if mobj is not None: + self._downloader.to_screen(u'[dailymotion] Using %s' % key) + break if mobj is None: self._downloader.trouble(u'ERROR: unable to extract media URL') return @@ -1578,18 +1585,19 @@ class DailymotionIE(InfoExtractor): video_url = mediaURL - mobj = re.search(r'(?im)Dailymotion\s*-\s*(.+)\s*-\s*[^<]+?', webpage) + mobj = re.search(r'(?im)Dailymotion\s*-\s*(.+)\s*-\s*[^<]+', webpage) if mobj is None: self._downloader.trouble(u'ERROR: unable to extract title') return video_title = mobj.group(1).decode('utf-8') video_title = sanitize_title(video_title) - mobj = re.search(r'(?im)[^<]+?]+?>([^<]+?)', webpage) + video_uploader = '' + mobj = re.search(r'(?im)[^<]+]+>([^<]+)', webpage) if mobj is None: - self._downloader.trouble(u'ERROR: unable to extract uploader nickname') - return - video_uploader = mobj.group(1) + self._downloader.to_screen(u'WARNING: unable to extract uploader nickname') + else: + video_uploader = mobj.group(1) try: # Process video information