aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/dailymotion.py43
-rw-r--r--youtube_dl/extractor/youtube.py25
2 files changed, 54 insertions, 14 deletions
diff --git a/youtube_dl/extractor/dailymotion.py b/youtube_dl/extractor/dailymotion.py
index 3f012aedc..259806f38 100644
--- a/youtube_dl/extractor/dailymotion.py
+++ b/youtube_dl/extractor/dailymotion.py
@@ -27,15 +27,31 @@ class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
_VALID_URL = r'(?i)(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/(?:embed/)?video/([^/]+)'
IE_NAME = u'dailymotion'
- _TEST = {
- u'url': u'http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech',
- u'file': u'x33vw9.mp4',
- u'md5': u'392c4b85a60a90dc4792da41ce3144eb',
- u'info_dict': {
- u"uploader": u"Amphora Alex and Van .",
- u"title": u"Tutoriel de Youtubeur\"DL DES VIDEO DE YOUTUBE\""
- }
- }
+ _TESTS = [
+ {
+ u'url': u'http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech',
+ u'file': u'x33vw9.mp4',
+ u'md5': u'392c4b85a60a90dc4792da41ce3144eb',
+ u'info_dict': {
+ u"uploader": u"Amphora Alex and Van .",
+ u"title": u"Tutoriel de Youtubeur\"DL DES VIDEO DE YOUTUBE\""
+ }
+ },
+ # Vevo video
+ {
+ u'url': u'http://www.dailymotion.com/video/x149uew_katy-perry-roar-official_musi',
+ u'file': u'USUV71301934.mp4',
+ u'info_dict': {
+ u'title': u'Roar (Official)',
+ u'uploader': u'Katy Perry',
+ u'upload_date': u'20130905',
+ },
+ u'params': {
+ u'skip_download': True,
+ },
+ u'skip': u'VEVO is only available in some countries',
+ },
+ ]
def _real_extract(self, url):
# Extract id and simplified title from URL
@@ -53,6 +69,15 @@ class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
# Extract URL, uploader and title from webpage
self.report_extraction(video_id)
+ # It may just embed a vevo video:
+ m_vevo = re.search(
+ r'<link rel="video_src" href="[^"]*?vevo.com[^"]*?videoId=(?P<id>[\w]*)',
+ webpage)
+ if m_vevo is not None:
+ vevo_id = m_vevo.group('id')
+ self.to_screen(u'Vevo video detected: %s' % vevo_id)
+ return self.url_result(u'vevo:%s' % vevo_id, ie='Vevo')
+
video_uploader = self._search_regex([r'(?im)<span class="owner[^\"]+?">[^<]+?<a [^>]+?>([^<]+?)</a>',
# Looking for official user
r'<(?:span|a) .*?rel="author".*?>([^<]+?)</'],
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 23e384ba2..f3d279210 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -23,6 +23,7 @@ from ..utils import (
compat_urllib_error,
compat_urllib_parse,
compat_urllib_request,
+ compat_urlparse,
compat_str,
clean_html,
@@ -1090,7 +1091,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
elif len(s) == 83:
return s[80:63:-1] + s[0] + s[62:0:-1] + s[63]
elif len(s) == 82:
- return s[80:73:-1] + s[81] + s[72:54:-1] + s[2] + s[53:43:-1] + s[0] + s[42:2:-1] + s[43] + s[1] + s[54]
+ return s[12] + s[79:12:-1] + s[80] + s[11::-1]
elif len(s) == 81:
return s[56] + s[79:56:-1] + s[41] + s[55:41:-1] + s[80] + s[40:34:-1] + s[0] + s[33:29:-1] + s[34] + s[28:9:-1] + s[29] + s[8:0:-1] + s[9]
elif len(s) == 80:
@@ -1337,9 +1338,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
self._downloader.report_warning(u'unable to extract uploader nickname')
# title
- if 'title' not in video_info:
- raise ExtractorError(u'Unable to extract video title')
- video_title = compat_urllib_parse.unquote_plus(video_info['title'][0])
+ if 'title' in video_info:
+ video_title = compat_urllib_parse.unquote_plus(video_info['title'][0])
+ else:
+ self._downloader.report_warning(u'Unable to extract video title')
+ video_title = u'_'
# thumbnail image
# We try first to get a high quality image:
@@ -1394,6 +1397,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
args = info['args']
# Easy way to know if the 's' value is in url_encoded_fmt_stream_map
# this signatures are encrypted
+ if 'url_encoded_fmt_stream_map' not in args:
+ raise ValueError(u'No stream_map present') # caught below
m_s = re.search(r'[&,]s=', args['url_encoded_fmt_stream_map'])
if m_s is not None:
self.to_screen(u'%s: Encrypted signatures detected.' % video_id)
@@ -1527,9 +1532,19 @@ class YoutubePlaylistIE(InfoExtractor):
mobj = re.match(self._VALID_URL, url, re.VERBOSE)
if mobj is None:
raise ExtractorError(u'Invalid URL: %s' % url)
+ playlist_id = mobj.group(1) or mobj.group(2)
+
+ # Check if it's a video-specific URL
+ query_dict = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
+ if 'v' in query_dict:
+ video_id = query_dict['v'][0]
+ if self._downloader.params.get('noplaylist'):
+ self.to_screen(u'Downloading just video %s because of --no-playlist' % video_id)
+ return self.url_result('https://www.youtube.com/watch?v=' + video_id, 'Youtube')
+ else:
+ self.to_screen(u'Downloading playlist PL%s - add --no-playlist to just download video %s' % (playlist_id, video_id))
# Download playlist videos from API
- playlist_id = mobj.group(1) or mobj.group(2)
videos = []
for page_num in itertools.count(1):