1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-03 16:02:51 +08:00

DailymotionIE: Added hd1080URL, hd720URL, hqURL support. Now video_uploader is optional.

This commit is contained in:
knagano 2011-09-26 20:57:58 +09:00
parent efb113c736
commit 7401ca7c5f

View File

@ -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,17 +1585,18 @@ class DailymotionIE(InfoExtractor):
video_url = mediaURL
mobj = re.search(r'(?im)<title>Dailymotion\s*-\s*(.+)\s*-\s*[^<]+?</title>', webpage)
mobj = re.search(r'(?im)<title>Dailymotion\s*-\s*(.+)\s*-\s*[^<]+</title>', 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)<span class="owner[^\"]+?">[^<]+?<a [^>]+?>([^<]+?)</a></span>', webpage)
video_uploader = ''
mobj = re.search(r'(?im)<span class="owner[^\"]+">[^<]+<a [^>]+>([^<]+)</a></span>', webpage)
if mobj is None:
self._downloader.trouble(u'ERROR: unable to extract uploader nickname')
return
self._downloader.to_screen(u'WARNING: unable to extract uploader nickname')
else:
video_uploader = mobj.group(1)
try: