]>
Commit | Line | Data |
---|---|---|
c85e4cf7 | 1 | from __future__ import unicode_literals |
2 | ||
1a2ecbfb | 3 | import json |
c85e4cf7 | 4 | import re |
c85e4cf7 | 5 | |
6 | from .common import InfoExtractor | |
5f0f8013 | 7 | from ..utils import int_or_none |
c85e4cf7 | 8 | |
9 | ||
10 | class VubeIE(InfoExtractor): | |
11 | IE_NAME = 'vube' | |
12 | IE_DESC = 'Vube.com' | |
b5368ace | 13 | _VALID_URL = r'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b' |
c85e4cf7 | 14 | |
b5368ace S |
15 | _TESTS = [ |
16 | { | |
17 | 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon', | |
18 | 'md5': 'db7aba89d4603dadd627e9d1973946fe', | |
19 | 'info_dict': { | |
20 | 'id': 'YL2qNPkqon', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'Chiara Grispo - Price Tag by Jessie J', | |
23 | 'description': 'md5:8ea652a1f36818352428cb5134933313', | |
1a2ecbfb | 24 | 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f\.jpg$', |
b5368ace | 25 | 'uploader': 'Chiara.Grispo', |
b5368ace S |
26 | 'timestamp': 1388743358, |
27 | 'upload_date': '20140103', | |
28 | 'duration': 170.56 | |
29 | } | |
30 | }, | |
31 | { | |
32 | 'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1', | |
33 | 'md5': '5d4a52492d76f72712117ce6b0d98d08', | |
34 | 'info_dict': { | |
35 | 'id': 'UeBhTudbfS', | |
36 | 'ext': 'mp4', | |
37 | 'title': 'My 7 year old Sister and I singing "Alive" by Krewella', | |
38 | 'description': 'md5:40bcacb97796339f1690642c21d56f4a', | |
1a2ecbfb | 39 | 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102265d5a9f-0f17-4f6b-5753-adf08484ee1e\.jpg$', |
b5368ace | 40 | 'uploader': 'Seraina', |
b5368ace S |
41 | 'timestamp': 1396492438, |
42 | 'upload_date': '20140403', | |
43 | 'duration': 240.107 | |
44 | } | |
1a2ecbfb PH |
45 | }, { |
46 | 'url': 'http://vube.com/vote/Siren+Gene/0nmsMY5vEq?n=2&t=s', | |
47 | 'md5': '0584fc13b50f887127d9d1007589d27f', | |
48 | 'info_dict': { | |
49 | 'id': '0nmsMY5vEq', | |
50 | 'ext': 'mp4', | |
51 | 'title': 'Frozen - Let It Go Cover by Siren Gene', | |
52 | 'description': 'My rendition of "Let It Go" originally sung by Idina Menzel.', | |
53 | 'uploader': 'Siren Gene', | |
54 | 'uploader_id': 'Siren', | |
55 | 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/10283ab622a-86c9-4681-51f2-30d1f65774af\.jpg$', | |
56 | 'duration': 221.788, | |
57 | 'like_count': int, | |
58 | 'dislike_count': int, | |
59 | } | |
c85e4cf7 | 60 | } |
b5368ace | 61 | ] |
c85e4cf7 | 62 | |
63 | def _real_extract(self, url): | |
64 | mobj = re.match(self._VALID_URL, url) | |
65 | video_id = mobj.group('id') | |
66 | ||
1a2ecbfb PH |
67 | webpage = self._download_webpage(url, video_id) |
68 | data_json = self._search_regex( | |
69 | r'(?s)window\["(?:tapiVideoData|vubeOriginalVideoData)"\]\s*=\s*(\{.*?\n});\n', | |
70 | webpage, 'video data' | |
71 | ) | |
72 | data = json.loads(data_json) | |
73 | open('/dev/shm/f', 'w').write(json.dumps(data, indent=2)) | |
74 | video = ( | |
75 | data.get('video') or | |
76 | data) | |
77 | assert isinstance(video, dict) | |
c85e4cf7 | 78 | |
79 | public_id = video['public_id'] | |
80 | ||
5f0f8013 S |
81 | formats = [ |
82 | { | |
83 | 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id), | |
84 | 'height': int(fmt['height']), | |
85 | 'abr': int(fmt['audio_bitrate']), | |
86 | 'vbr': int(fmt['video_bitrate']), | |
87 | 'format_id': fmt['media_resolution_id'] | |
88 | } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed' | |
89 | ] | |
c85e4cf7 | 90 | |
91 | self._sort_formats(formats) | |
92 | ||
93 | title = video['title'] | |
f4635912 | 94 | description = video.get('description') |
1a2ecbfb PH |
95 | thumbnail = self._proto_relative_url( |
96 | video.get('thumbnail') or video.get('thumbnail_src'), | |
97 | scheme='http:') | |
98 | uploader = data.get('user', {}).get('channel', {}).get('name') or video.get('user_alias') | |
99 | uploader_id = data.get('user', {}).get('name') | |
100 | timestamp = int_or_none(video.get('upload_time')) | |
c85e4cf7 | 101 | duration = video['duration'] |
5f0f8013 | 102 | view_count = video.get('raw_view_count') |
1a2ecbfb PH |
103 | like_count = video.get('rlikes') |
104 | dislike_count = video.get('rhates') | |
c85e4cf7 | 105 | |
5f0f8013 S |
106 | comment = self._download_json( |
107 | 'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON') | |
c85e4cf7 | 108 | |
5f0f8013 | 109 | comment_count = int_or_none(comment.get('total')) |
c85e4cf7 | 110 | |
111 | return { | |
112 | 'id': video_id, | |
113 | 'formats': formats, | |
114 | 'title': title, | |
115 | 'description': description, | |
116 | 'thumbnail': thumbnail, | |
117 | 'uploader': uploader, | |
118 | 'uploader_id': uploader_id, | |
b5368ace | 119 | 'timestamp': timestamp, |
c85e4cf7 | 120 | 'duration': duration, |
121 | 'view_count': view_count, | |
122 | 'like_count': like_count, | |
123 | 'dislike_count': dislike_count, | |
124 | 'comment_count': comment_count, | |
31f77343 | 125 | } |