aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo.valsorda@gmail.com>2012-10-09 12:28:44 +0200
committerFilippo Valsorda <filippo.valsorda@gmail.com>2012-10-09 12:28:44 +0200
commit0bfd0b598a4f66ca86af57708b37b87931ef9e8c (patch)
tree09194181ef4766a8cfd0d549cb30af6c9bd2b28b /youtube_dl
parentfd873c69a42eb596290ec53e53ac802298128095 (diff)
Re-engineered Dailymotion qualities selection (thanks @knagano, sort of merges #176)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/InfoExtractors.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py
index f97611cb9..693f07332 100644
--- a/youtube_dl/InfoExtractors.py
+++ b/youtube_dl/InfoExtractors.py
@@ -658,15 +658,21 @@ class DailymotionIE(InfoExtractor):
self._downloader.trouble(u'ERROR: unable to extract media URL')
return
flashvars = urllib.unquote(mobj.group(1))
- if 'hqURL' in flashvars: max_quality = 'hqURL'
- elif 'sdURL' in flashvars: max_quality = 'sdURL'
- else: max_quality = 'ldURL'
+
+ for key in ['hd1080URL', 'hd720URL', 'hqURL', 'sdURL', 'ldURL', 'video_url']:
+ if key in flashvars:
+ max_quality = key
+ self._downloader.to_screen(u'[dailymotion] Using %s' % key)
+ break
+ else:
+ self._downloader.trouble(u'ERROR: unable to extract video URL')
+ return
+
mobj = re.search(r'"' + max_quality + r'":"(.+?)"', flashvars)
if mobj is None:
- mobj = re.search(r'"video_url":"(.*?)",', flashvars)
- if mobj is None:
- self._downloader.trouble(u'ERROR: unable to extract media URL')
+ self._downloader.trouble(u'ERROR: unable to extract video URL')
return
+
video_url = urllib.unquote(mobj.group(1)).replace('\\/', '/')
# TODO: support choosing qualities
@@ -677,11 +683,12 @@ class DailymotionIE(InfoExtractor):
return
video_title = unescapeHTML(mobj.group('title').decode('utf-8'))
+ video_uploader = u'NA'
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
- video_uploader = mobj.group(1)
+ self._downloader.trouble(u'WARNING: unable to extract uploader nickname')
+ else:
+ video_uploader = mobj.group(1)
video_upload_date = u'NA'
mobj = re.search(r'<div class="[^"]*uploaded_cont[^"]*" title="[^"]*">([0-9]{2})-([0-9]{2})-([0-9]{4})</div>', webpage)