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