aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/__init__.py2
-rw-r--r--youtube_dl/extractor/common.py2
-rw-r--r--youtube_dl/extractor/mtv.py8
-rw-r--r--youtube_dl/extractor/vevo.py44
-rw-r--r--youtube_dl/extractor/youtube.py19
5 files changed, 67 insertions, 8 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index e27f58496..7b291f907 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -45,6 +45,7 @@ from .ted import TEDIE
from .tumblr import TumblrIE
from .ustream import UstreamIE
from .vbox7 import Vbox7IE
+from .vevo import VevoIE
from .vimeo import VimeoIE
from .vine import VineIE
from .worldstarhiphop import WorldStarHipHopIE
@@ -126,6 +127,7 @@ def gen_extractors():
GametrailersIE(),
StatigramIE(),
BreakIE(),
+ VevoIE(),
JukeboxIE(),
GenericIE()
]
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 062f4cf1e..64d63e109 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -211,7 +211,7 @@ class InfoExtractor(object):
raise ExtractorError(u'Unable to extract %s' % _name)
else:
self._downloader.report_warning(u'unable to extract %s; '
- u'please report this issue on GitHub.' % _name)
+ u'please report this issue on http://yt-dl.org/bug' % _name)
return None
def _html_search_regex(self, pattern, string, name, default=None, fatal=True, flags=0):
diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py
index a801c8123..969db7113 100644
--- a/youtube_dl/extractor/mtv.py
+++ b/youtube_dl/extractor/mtv.py
@@ -27,6 +27,14 @@ class MTVIE(InfoExtractor):
webpage = self._download_webpage(url, video_id)
+ # Some videos come from Vevo.com
+ m_vevo = re.search(r'isVevoVideo = true;.*?vevoVideoId = "(.*?)";',
+ webpage, re.DOTALL)
+ if m_vevo:
+ vevo_id = m_vevo.group(1);
+ self.to_screen(u'Vevo video detected: %s' % vevo_id)
+ return self.url_result('vevo:%s' % vevo_id, ie='Vevo')
+
#song_name = self._html_search_regex(r'<meta name="mtv_vt" content="([^"]+)"/>',
# webpage, u'song name', fatal=False)
diff --git a/youtube_dl/extractor/vevo.py b/youtube_dl/extractor/vevo.py
new file mode 100644
index 000000000..aa88e1a92
--- /dev/null
+++ b/youtube_dl/extractor/vevo.py
@@ -0,0 +1,44 @@
+import re
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ unified_strdate,
+ ExtractorError,
+)
+
+class VevoIE(InfoExtractor):
+ """
+ Accecps urls from vevo.com or in the format 'vevo:{id}'
+ (currently used by MTVIE)
+ """
+ _VALID_URL = r'((http://www.vevo.com/watch/.*?/.*?/)|(vevo:))(?P<id>.*)$'
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ video_id = mobj.group('id')
+
+ json_url = 'http://www.vevo.com/data/video/%s' % video_id
+ base_url = 'http://smil.lvl3.vevo.com'
+ videos_url = '%s/Video/V2/VFILE/%s/%sr.smil' % (base_url, video_id, video_id.lower())
+ info_json = self._download_webpage(json_url, video_id, u'Downloading json info')
+ links_webpage = self._download_webpage(videos_url, video_id, u'Downloading videos urls')
+
+ self.report_extraction(video_id)
+ video_info = json.loads(info_json)
+ m_urls = list(re.finditer(r'<video src="(?P<ext>.*?):(?P<url>.*?)"', links_webpage))
+ if m_urls is None or len(m_urls) == 0:
+ raise ExtractorError(u'Unable to extract video url')
+ # They are sorted from worst to best quality
+ m_url = m_urls[-1]
+ video_url = base_url + m_url.group('url')
+ ext = m_url.group('ext')
+
+ return {'url': video_url,
+ 'ext': ext,
+ 'id': video_id,
+ 'title': video_info['title'],
+ 'thumbnail': video_info['img'],
+ 'upload_date': video_info['launchDate'].replace('/',''),
+ 'uploader': video_info['Artists'][0]['title'],
+ }
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index fbe8d63a3..de653cb3d 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -58,7 +58,7 @@ class YoutubeIE(InfoExtractor):
'18': 'mp4',
'22': 'mp4',
'37': 'mp4',
- '38': 'video', # You actually don't know if this will be MOV, AVI or whatever
+ '38': 'mp4',
'43': 'webm',
'44': 'webm',
'45': 'webm',
@@ -129,12 +129,13 @@ class YoutubeIE(InfoExtractor):
"""Indicate the download will use the RTMP protocol."""
self.to_screen(u'RTMP download detected')
- @staticmethod
- def _decrypt_signature(s):
+ def _decrypt_signature(self, s):
"""Decrypt the key the two subkeys must have a length of 43"""
(a,b) = s.split('.')
if len(a) != 43 or len(b) != 43:
- raise ExtractorError(u'Unable to decrypt signature, subkeys lengths not valid')
+ raise ExtractorError(u'Unable to decrypt signature, subkeys lengths %d.%d not supported; retrying might work' % (len(a), len(b)))
+ if self._downloader.params.get('verbose'):
+ self.to_screen('encrypted signature length %d.%d' % (len(a), len(b)))
b = ''.join([b[:8],a[0],b[9:18],b[-4],b[19:39], b[18]])[0:40]
a = a[-40:]
s_dec = '.'.join((a,b))[::-1]
@@ -484,11 +485,15 @@ class YoutubeIE(InfoExtractor):
try:
mobj = re.search(r';ytplayer.config = ({.*?});', video_webpage)
+ if not mobj:
+ raise ValueError('Could not find vevo ID')
info = json.loads(mobj.group(1))
args = info['args']
- if args.get('ptk','') == 'vevo' or 'dashmpd':
- # Vevo videos with encrypted signatures
- self.to_screen(u'%s: Vevo video detected.' % video_id)
+ # Easy way to know if the 's' value is in url_encoded_fmt_stream_map
+ # this signatures are encrypted
+ 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)
video_info['url_encoded_fmt_stream_map'] = [args['url_encoded_fmt_stream_map']]
except ValueError:
pass