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