X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fvube.py;h=f1b9e9a19d05d9026feb24b6f22d395cd3990e5f;hb=94a20aa5f88762f4a80f79e039405f3865075569;hp=a09c003dd22d96103815592a799a90eeff332dfb;hpb=b5368acee875fbbf1d7c92b4d6a94c402c048a92;p=youtube-dl diff --git a/youtube_dl/extractor/vube.py b/youtube_dl/extractor/vube.py index a09c003dd..f1b9e9a19 100644 --- a/youtube_dl/extractor/vube.py +++ b/youtube_dl/extractor/vube.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import json import re from .common import InfoExtractor +from ..utils import int_or_none class VubeIE(InfoExtractor): @@ -19,12 +21,14 @@ class VubeIE(InfoExtractor): 'ext': 'mp4', 'title': 'Chiara Grispo - Price Tag by Jessie J', 'description': 'md5:8ea652a1f36818352428cb5134933313', - 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f.jpg', + 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f\.jpg$', 'uploader': 'Chiara.Grispo', - 'uploader_id': '1u3hX0znhP', 'timestamp': 1388743358, 'upload_date': '20140103', - 'duration': 170.56 + 'duration': 170.56, + 'like_count': int, + 'dislike_count': int, + 'comment_count': int, } }, { @@ -35,12 +39,30 @@ class VubeIE(InfoExtractor): 'ext': 'mp4', 'title': 'My 7 year old Sister and I singing "Alive" by Krewella', 'description': 'md5:40bcacb97796339f1690642c21d56f4a', - 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102265d5a9f-0f17-4f6b-5753-adf08484ee1e.jpg', + 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102265d5a9f-0f17-4f6b-5753-adf08484ee1e\.jpg$', 'uploader': 'Seraina', - 'uploader_id': 'XU9VE2BQ2q', 'timestamp': 1396492438, 'upload_date': '20140403', - 'duration': 240.107 + 'duration': 240.107, + 'like_count': int, + 'dislike_count': int, + 'comment_count': int, + } + }, { + 'url': 'http://vube.com/vote/Siren+Gene/0nmsMY5vEq?n=2&t=s', + 'md5': '0584fc13b50f887127d9d1007589d27f', + 'info_dict': { + 'id': '0nmsMY5vEq', + 'ext': 'mp4', + 'title': 'Frozen - Let It Go Cover by Siren Gene', + 'description': 'My rendition of "Let It Go" originally sung by Idina Menzel.', + 'uploader': 'Siren Gene', + 'uploader_id': 'Siren', + 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/10283ab622a-86c9-4681-51f2-30d1f65774af\.jpg$', + 'duration': 221.788, + 'like_count': int, + 'dislike_count': int, + 'comment_count': int, } } ] @@ -49,37 +71,58 @@ class VubeIE(InfoExtractor): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') - video = self._download_json('http://vube.com/api/v2/video/%s' % video_id, - video_id, 'Downloading video JSON') + webpage = self._download_webpage(url, video_id) + data_json = self._search_regex( + r'(?s)window\["(?:tapiVideoData|vubeOriginalVideoData)"\]\s*=\s*(\{.*?\n});\n', + webpage, 'video data' + ) + data = json.loads(data_json) + video = ( + data.get('video') or + data) + assert isinstance(video, dict) public_id = video['public_id'] - formats = [{'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id), - 'height': int(fmt['height']), - 'abr': int(fmt['audio_bitrate']), - 'vbr': int(fmt['video_bitrate']), - 'format_id': fmt['media_resolution_id'] - } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed'] + formats = [ + { + 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id), + 'height': int(fmt['height']), + 'abr': int(fmt['audio_bitrate']), + 'vbr': int(fmt['video_bitrate']), + 'format_id': fmt['media_resolution_id'] + } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed' + ] self._sort_formats(formats) title = video['title'] description = video.get('description') - thumbnail = video['thumbnail_src'] - if thumbnail.startswith('//'): - thumbnail = 'http:' + thumbnail - uploader = video['user_alias'] - uploader_id = video['user_url_id'] - timestamp = int(video['upload_time']) + thumbnail = self._proto_relative_url( + video.get('thumbnail') or video.get('thumbnail_src'), + scheme='http:') + uploader = data.get('user', {}).get('channel', {}).get('name') or video.get('user_alias') + uploader_id = data.get('user', {}).get('name') + timestamp = int_or_none(video.get('upload_time')) duration = video['duration'] - view_count = video['raw_view_count'] - like_count = video['total_likes'] - dislike_count= video['total_hates'] - - comment = self._download_json('http://vube.com/api/video/%s/comment' % video_id, - video_id, 'Downloading video comment JSON') + view_count = video.get('raw_view_count') + like_count = video.get('rlikes') + if like_count is None: + like_count = video.get('total_likes') + dislike_count = video.get('rhates') + if dislike_count is None: + dislike_count = video.get('total_hates') - comment_count = comment['total'] + comments = video.get('comments') + comment_count = None + if comments is None: + comment_data = self._download_json( + 'http://vube.com/api/video/%s/comment' % video_id, + video_id, 'Downloading video comment JSON', fatal=False) + if comment_data is not None: + comment_count = int_or_none(comment_data.get('total')) + else: + comment_count = len(comments) return { 'id': video_id,