]>
Commit | Line | Data |
---|---|---|
c85e4cf7 | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
c85e4cf7 | 4 | |
5 | from .common import InfoExtractor | |
59610172 S |
6 | from ..utils import ( |
7 | int_or_none, | |
8 | compat_str, | |
9 | ) | |
c85e4cf7 | 10 | |
11 | ||
12 | class VubeIE(InfoExtractor): | |
13 | IE_NAME = 'vube' | |
14 | IE_DESC = 'Vube.com' | |
b5368ace | 15 | _VALID_URL = r'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b' |
c85e4cf7 | 16 | |
b5368ace S |
17 | _TESTS = [ |
18 | { | |
19 | 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon', | |
20 | 'md5': 'db7aba89d4603dadd627e9d1973946fe', | |
21 | 'info_dict': { | |
22 | 'id': 'YL2qNPkqon', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Chiara Grispo - Price Tag by Jessie J', | |
25 | 'description': 'md5:8ea652a1f36818352428cb5134933313', | |
1a2ecbfb | 26 | 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f\.jpg$', |
b5368ace | 27 | 'uploader': 'Chiara.Grispo', |
b5368ace S |
28 | 'timestamp': 1388743358, |
29 | 'upload_date': '20140103', | |
b090af59 PH |
30 | 'duration': 170.56, |
31 | 'like_count': int, | |
32 | 'dislike_count': int, | |
33 | 'comment_count': int, | |
59610172 | 34 | 'categories': ['pop', 'music', 'cover', 'singing', 'jessie j', 'price tag', 'chiara grispo'], |
b5368ace S |
35 | } |
36 | }, | |
37 | { | |
38 | 'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1', | |
39 | 'md5': '5d4a52492d76f72712117ce6b0d98d08', | |
40 | 'info_dict': { | |
41 | 'id': 'UeBhTudbfS', | |
42 | 'ext': 'mp4', | |
43 | 'title': 'My 7 year old Sister and I singing "Alive" by Krewella', | |
44 | 'description': 'md5:40bcacb97796339f1690642c21d56f4a', | |
1a2ecbfb | 45 | 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102265d5a9f-0f17-4f6b-5753-adf08484ee1e\.jpg$', |
b5368ace | 46 | 'uploader': 'Seraina', |
b5368ace S |
47 | 'timestamp': 1396492438, |
48 | 'upload_date': '20140403', | |
b090af59 PH |
49 | 'duration': 240.107, |
50 | 'like_count': int, | |
51 | 'dislike_count': int, | |
52 | 'comment_count': int, | |
59610172 | 53 | 'categories': ['seraina', 'jessica', 'krewella', 'alive'], |
b5368ace | 54 | } |
1a2ecbfb PH |
55 | }, { |
56 | 'url': 'http://vube.com/vote/Siren+Gene/0nmsMY5vEq?n=2&t=s', | |
57 | 'md5': '0584fc13b50f887127d9d1007589d27f', | |
58 | 'info_dict': { | |
59 | 'id': '0nmsMY5vEq', | |
60 | 'ext': 'mp4', | |
61 | 'title': 'Frozen - Let It Go Cover by Siren Gene', | |
62 | 'description': 'My rendition of "Let It Go" originally sung by Idina Menzel.', | |
1a2ecbfb | 63 | 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/10283ab622a-86c9-4681-51f2-30d1f65774af\.jpg$', |
59610172 S |
64 | 'uploader': 'Siren', |
65 | 'timestamp': 1395448018, | |
66 | 'upload_date': '20140322', | |
1a2ecbfb PH |
67 | 'duration': 221.788, |
68 | 'like_count': int, | |
69 | 'dislike_count': int, | |
b090af59 | 70 | 'comment_count': int, |
59610172 | 71 | 'categories': ['let it go', 'cover', 'idina menzel', 'frozen', 'singing', 'disney', 'siren gene'], |
1a2ecbfb | 72 | } |
c85e4cf7 | 73 | } |
b5368ace | 74 | ] |
c85e4cf7 | 75 | |
76 | def _real_extract(self, url): | |
77 | mobj = re.match(self._VALID_URL, url) | |
78 | video_id = mobj.group('id') | |
79 | ||
59610172 S |
80 | video = self._download_json( |
81 | 'http://vube.com/t-api/v1/video/%s' % video_id, video_id, 'Downloading video JSON') | |
c85e4cf7 | 82 | |
83 | public_id = video['public_id'] | |
84 | ||
59610172 S |
85 | formats = [] |
86 | ||
87 | for media in video['media'].get('video', []) + video['media'].get('audio', []): | |
88 | if media['transcoding_status'] != 'processed': | |
89 | continue | |
90 | fmt = { | |
91 | 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (media['media_resolution_id'], public_id), | |
92 | 'abr': int(media['audio_bitrate']), | |
93 | 'format_id': compat_str(media['media_resolution_id']), | |
94 | } | |
95 | vbr = int(media['video_bitrate']) | |
96 | if vbr: | |
97 | fmt.update({ | |
98 | 'vbr': vbr, | |
99 | 'height': int(media['height']), | |
100 | }) | |
101 | formats.append(fmt) | |
c85e4cf7 | 102 | |
103 | self._sort_formats(formats) | |
104 | ||
105 | title = video['title'] | |
f4635912 | 106 | description = video.get('description') |
59610172 S |
107 | thumbnail = self._proto_relative_url(video.get('thumbnail_src'), scheme='http:') |
108 | uploader = video.get('user_alias') or video.get('channel') | |
1a2ecbfb | 109 | timestamp = int_or_none(video.get('upload_time')) |
c85e4cf7 | 110 | duration = video['duration'] |
5f0f8013 | 111 | view_count = video.get('raw_view_count') |
59610172 S |
112 | like_count = video.get('total_likes') |
113 | dislike_count = video.get('total_hates') | |
c85e4cf7 | 114 | |
b090af59 PH |
115 | comments = video.get('comments') |
116 | comment_count = None | |
117 | if comments is None: | |
118 | comment_data = self._download_json( | |
119 | 'http://vube.com/api/video/%s/comment' % video_id, | |
120 | video_id, 'Downloading video comment JSON', fatal=False) | |
121 | if comment_data is not None: | |
122 | comment_count = int_or_none(comment_data.get('total')) | |
123 | else: | |
124 | comment_count = len(comments) | |
c85e4cf7 | 125 | |
59610172 S |
126 | categories = [tag['text'] for tag in video['tags']] |
127 | ||
c85e4cf7 | 128 | return { |
129 | 'id': video_id, | |
130 | 'formats': formats, | |
131 | 'title': title, | |
132 | 'description': description, | |
133 | 'thumbnail': thumbnail, | |
134 | 'uploader': uploader, | |
b5368ace | 135 | 'timestamp': timestamp, |
c85e4cf7 | 136 | 'duration': duration, |
137 | 'view_count': view_count, | |
138 | 'like_count': like_count, | |
139 | 'dislike_count': dislike_count, | |
140 | 'comment_count': comment_count, | |
59610172 | 141 | 'categories': categories, |
31f77343 | 142 | } |