]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/vube.py
[vube] Remove unnecessary coding cookie
[yt-dlp.git] / youtube_dl / extractor / vube.py
CommitLineData
c85e4cf7 1from __future__ import unicode_literals
2
3import re
4import datetime
5
6from .common import InfoExtractor
7
8
9class VubeIE(InfoExtractor):
10 IE_NAME = 'vube'
11 IE_DESC = 'Vube.com'
12 _VALID_URL = r'http://vube\.com/[^/]+/(?P<id>[\da-zA-Z]{10})'
13
14 _TEST = {
15 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon',
16 'file': 'YL2qNPkqon.mp4',
17 'md5': 'f81dcf6d0448e3291f54380181695821',
18 'info_dict': {
19 'title': 'Chiara Grispo - Price Tag by Jessie J',
20 'description': 'md5:8ea652a1f36818352428cb5134933313',
21 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f.jpg',
22 'uploader': 'Chiara.Grispo',
23 'uploader_id': '1u3hX0znhP',
24 'upload_date': '20140103',
25 'duration': 170.56
26 }
27 }
28
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
32
33 video = self._download_json('http://vube.com/api/v2/video/%s' % video_id,
34 video_id, 'Downloading video JSON')
35
36 public_id = video['public_id']
37
38 formats = [{'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id),
39 'height': int(fmt['height']),
40 'abr': int(fmt['audio_bitrate']),
41 'vbr': int(fmt['video_bitrate']),
42 'format_id': fmt['media_resolution_id']
43 } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed']
44
45 self._sort_formats(formats)
46
47 title = video['title']
48 description = video['description']
49 thumbnail = video['thumbnail_src']
50 if thumbnail.startswith('//'):
51 thumbnail = 'http:' + thumbnail
52 uploader = video['user_alias']
53 uploader_id = video['user_url_id']
54 upload_date = datetime.datetime.fromtimestamp(int(video['upload_time'])).strftime('%Y%m%d')
55 duration = video['duration']
56 view_count = video['raw_view_count']
57 like_count = video['total_likes']
58 dislike_count= video['total_hates']
59
60 comment = self._download_json('http://vube.com/api/video/%s/comment' % video_id,
61 video_id, 'Downloading video comment JSON')
62
63 comment_count = comment['total']
64
65 return {
66 'id': video_id,
67 'formats': formats,
68 'title': title,
69 'description': description,
70 'thumbnail': thumbnail,
71 'uploader': uploader,
72 'uploader_id': uploader_id,
73 'upload_date': upload_date,
74 'duration': duration,
75 'view_count': view_count,
76 'like_count': like_count,
77 'dislike_count': dislike_count,
78 'comment_count': comment_count,
79 }