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