]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vube.py
debian/watch: Make use of the signing key from upstream.
[youtubedl] / youtube_dl / extractor / vube.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import int_or_none
7
8
9 class VubeIE(InfoExtractor):
10 IE_NAME = 'vube'
11 IE_DESC = 'Vube.com'
12 _VALID_URL = r'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b'
13
14 _TESTS = [
15 {
16 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon',
17 'md5': 'db7aba89d4603dadd627e9d1973946fe',
18 'info_dict': {
19 'id': 'YL2qNPkqon',
20 'ext': 'mp4',
21 'title': 'Chiara Grispo - Price Tag by Jessie J',
22 'description': 'md5:8ea652a1f36818352428cb5134933313',
23 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f.jpg',
24 'uploader': 'Chiara.Grispo',
25 'uploader_id': '1u3hX0znhP',
26 'timestamp': 1388743358,
27 'upload_date': '20140103',
28 'duration': 170.56
29 }
30 },
31 {
32 'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1',
33 'md5': '5d4a52492d76f72712117ce6b0d98d08',
34 'info_dict': {
35 'id': 'UeBhTudbfS',
36 'ext': 'mp4',
37 'title': 'My 7 year old Sister and I singing "Alive" by Krewella',
38 'description': 'md5:40bcacb97796339f1690642c21d56f4a',
39 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102265d5a9f-0f17-4f6b-5753-adf08484ee1e.jpg',
40 'uploader': 'Seraina',
41 'uploader_id': 'XU9VE2BQ2q',
42 'timestamp': 1396492438,
43 'upload_date': '20140403',
44 'duration': 240.107
45 }
46 }
47 ]
48
49 def _real_extract(self, url):
50 mobj = re.match(self._VALID_URL, url)
51 video_id = mobj.group('id')
52
53 video = self._download_json(
54 'http://vube.com/api/v2/video/%s' % video_id, video_id, 'Downloading video JSON')
55
56 public_id = video['public_id']
57
58 formats = [
59 {
60 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id),
61 'height': int(fmt['height']),
62 'abr': int(fmt['audio_bitrate']),
63 'vbr': int(fmt['video_bitrate']),
64 'format_id': fmt['media_resolution_id']
65 } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed'
66 ]
67
68 self._sort_formats(formats)
69
70 title = video['title']
71 description = video.get('description')
72 thumbnail = video['thumbnail_src']
73 if thumbnail.startswith('//'):
74 thumbnail = 'http:' + thumbnail
75 uploader = video['user_alias']
76 uploader_id = video['user_url_id']
77 timestamp = int(video['upload_time'])
78 duration = video['duration']
79 view_count = video.get('raw_view_count')
80 like_count = video.get('total_likes')
81 dislike_count= video.get('total_hates')
82
83 comment = self._download_json(
84 'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON')
85
86 comment_count = int_or_none(comment.get('total'))
87
88 return {
89 'id': video_id,
90 'formats': formats,
91 'title': title,
92 'description': description,
93 'thumbnail': thumbnail,
94 'uploader': uploader,
95 'uploader_id': uploader_id,
96 'timestamp': timestamp,
97 'duration': duration,
98 'view_count': view_count,
99 'like_count': like_count,
100 'dislike_count': dislike_count,
101 'comment_count': comment_count,
102 }