1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-20 20:02:53 +08:00

[vube] Add support for new data format (Fixes #3325)

This commit is contained in:
Philipp Hagemeister 2014-07-23 01:18:27 +02:00
parent 38e292b112
commit 1a2ecbfbc4

View File

@ -1,5 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import json
import re import re
from .common import InfoExtractor from .common import InfoExtractor
@ -20,9 +21,8 @@ class VubeIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'Chiara Grispo - Price Tag by Jessie J', 'title': 'Chiara Grispo - Price Tag by Jessie J',
'description': 'md5:8ea652a1f36818352428cb5134933313', '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': 'Chiara.Grispo',
'uploader_id': '1u3hX0znhP',
'timestamp': 1388743358, 'timestamp': 1388743358,
'upload_date': '20140103', 'upload_date': '20140103',
'duration': 170.56 'duration': 170.56
@ -36,13 +36,27 @@ class VubeIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'My 7 year old Sister and I singing "Alive" by Krewella', 'title': 'My 7 year old Sister and I singing "Alive" by Krewella',
'description': 'md5:40bcacb97796339f1690642c21d56f4a', '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': 'Seraina',
'uploader_id': 'XU9VE2BQ2q',
'timestamp': 1396492438, 'timestamp': 1396492438,
'upload_date': '20140403', 'upload_date': '20140403',
'duration': 240.107 'duration': 240.107
} }
}, {
'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,
}
} }
] ]
@ -50,8 +64,17 @@ class VubeIE(InfoExtractor):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id') video_id = mobj.group('id')
video = self._download_json( webpage = self._download_webpage(url, video_id)
'http://vube.com/api/v2/video/%s' % video_id, video_id, 'Downloading video JSON') data_json = self._search_regex(
r'(?s)window\["(?:tapiVideoData|vubeOriginalVideoData)"\]\s*=\s*(\{.*?\n});\n',
webpage, 'video data'
)
data = json.loads(data_json)
open('/dev/shm/f', 'w').write(json.dumps(data, indent=2))
video = (
data.get('video') or
data)
assert isinstance(video, dict)
public_id = video['public_id'] public_id = video['public_id']
@ -69,16 +92,16 @@ class VubeIE(InfoExtractor):
title = video['title'] title = video['title']
description = video.get('description') description = video.get('description')
thumbnail = video['thumbnail_src'] thumbnail = self._proto_relative_url(
if thumbnail.startswith('//'): video.get('thumbnail') or video.get('thumbnail_src'),
thumbnail = 'http:' + thumbnail scheme='http:')
uploader = video['user_alias'] uploader = data.get('user', {}).get('channel', {}).get('name') or video.get('user_alias')
uploader_id = video['user_url_id'] uploader_id = data.get('user', {}).get('name')
timestamp = int(video['upload_time']) timestamp = int_or_none(video.get('upload_time'))
duration = video['duration'] duration = video['duration']
view_count = video.get('raw_view_count') view_count = video.get('raw_view_count')
like_count = video.get('total_likes') like_count = video.get('rlikes')
dislike_count= video.get('total_hates') dislike_count = video.get('rhates')
comment = self._download_json( comment = self._download_json(
'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON') 'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON')