X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fvevo.py;h=d2ffd1b6ba893f2cb2cc50f00a3131a835dba97d;hb=cc7fec5818254f4679896823c7de9d17f50201ca;hp=dd87158db2c8019ad7cf5332e4bcfc8d31f51680;hpb=27579b9e4c4adf5411faeacbbf45dae97a7df5e9;p=youtube-dl diff --git a/youtube_dl/extractor/vevo.py b/youtube_dl/extractor/vevo.py index dd87158db..d2ffd1b6b 100644 --- a/youtube_dl/extractor/vevo.py +++ b/youtube_dl/extractor/vevo.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals import re import xml.etree.ElementTree -import datetime from .common import InfoExtractor from ..utils import ( @@ -17,11 +16,12 @@ class VevoIE(InfoExtractor): (currently used by MTVIE) """ _VALID_URL = r'''(?x) - (?:https?://www\.vevo\.com/watch/(?:[^/]+/[^/]+/)?| + (?:https?://www\.vevo\.com/watch/(?:[^/]+/(?:[^/]+/)?)?| https?://cache\.vevo\.com/m/html/embed\.html\?video=| https?://videoplayer\.vevo\.com/embed/embedded\?videoId=| vevo:) (?P[^&?#]+)''' + _TESTS = [{ 'url': 'http://www.vevo.com/watch/hurts/somebody-to-die-for/GB1101300280', "md5": "06bea460acb744eab74a9d7dcb4bfd61", @@ -34,6 +34,8 @@ class VevoIE(InfoExtractor): "duration": 230.12, "width": 1920, "height": 1080, + # timestamp and upload_date are often incorrect; seem to change randomly + 'timestamp': int, } }, { 'note': 'v3 SMIL format', @@ -46,6 +48,23 @@ class VevoIE(InfoExtractor): 'uploader': 'Cassadee Pope', 'title': 'I Wish I Could Break Your Heart', 'duration': 226.101, + 'age_limit': 0, + 'timestamp': int, + } + }, { + 'note': 'Age-limited video', + 'url': 'https://www.vevo.com/watch/justin-timberlake/tunnel-vision-explicit/USRV81300282', + 'info_dict': { + 'id': 'USRV81300282', + 'ext': 'mp4', + 'age_limit': 18, + 'title': 'Tunnel Vision (Explicit)', + 'uploader': 'Justin Timberlake', + 'upload_date': 're:2013070[34]', + 'timestamp': int, + }, + 'params': { + 'skip_download': 'true', } }] _SMIL_BASE_URL = 'http://smil.lvl3.vevo.com/' @@ -115,10 +134,24 @@ class VevoIE(InfoExtractor): video_id = mobj.group('id') json_url = 'http://videoplayer.vevo.com/VideoService/AuthenticateVideo?isrc=%s' % video_id - video_info = self._download_json(json_url, video_id)['video'] + response = self._download_json(json_url, video_id) + video_info = response['video'] + + if not video_info: + if 'statusMessage' in response: + raise ExtractorError('%s said: %s' % (self.IE_NAME, response['statusMessage']), expected=True) + raise ExtractorError('Unable to extract videos') formats = self._formats_from_json(video_info) + is_explicit = video_info.get('isExplicit') + if is_explicit is True: + age_limit = 18 + elif is_explicit is False: + age_limit = 0 + else: + age_limit = None + # Download SMIL smil_blocks = sorted(( f for f in video_info['videoVersions'] @@ -144,15 +177,17 @@ class VevoIE(InfoExtractor): self._downloader.report_warning( 'Cannot download SMIL information, falling back to JSON ..') + self._sort_formats(formats) timestamp_ms = int(self._search_regex( r'/Date\((\d+)\)/', video_info['launchDate'], 'launch date')) - upload_date = datetime.datetime.fromtimestamp(timestamp_ms // 1000) + return { 'id': video_id, 'title': video_info['title'], 'formats': formats, 'thumbnail': video_info['imageUrl'], - 'upload_date': upload_date.strftime('%Y%m%d'), + 'timestamp': timestamp_ms // 1000, 'uploader': video_info['mainArtists'][0]['artistName'], 'duration': video_info['duration'], + 'age_limit': age_limit, }