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