]>
Commit | Line | Data |
---|---|---|
41e8bca4 | 1 | from .common import InfoExtractor |
c64ed2a3 PH |
2 | from ..utils import ( |
3 | float_or_none, | |
4 | int_or_none, | |
796df3c6 | 5 | ) |
41e8bca4 PH |
6 | |
7 | ||
8 | class ViddlerIE(InfoExtractor): | |
e5855472 | 9 | _VALID_URL = r'https?://(?:www\.)?viddler\.com/(?:v|embed|player)/(?P<id>[a-z0-9]+)(?:.+?\bsecret=(\d+))?' |
796df3c6 | 10 | _TESTS = [{ |
b04fbd78 | 11 | 'url': 'http://www.viddler.com/v/43903784', |
47246ae2 | 12 | 'md5': '9eee21161d2c7f5b39690c3e325fab2f', |
c64ed2a3 PH |
13 | 'info_dict': { |
14 | 'id': '43903784', | |
47246ae2 | 15 | 'ext': 'mov', |
b04fbd78 S |
16 | 'title': 'Video Made Easy', |
17 | 'description': 'md5:6a697ebd844ff3093bd2e82c37b409cd', | |
18 | 'uploader': 'viddler', | |
c64ed2a3 PH |
19 | 'timestamp': 1335371429, |
20 | 'upload_date': '20120425', | |
b04fbd78 | 21 | 'duration': 100.89, |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.jpg$', |
c64ed2a3 | 23 | 'view_count': int, |
18b4e9e7 | 24 | 'comment_count': int, |
c64ed2a3 | 25 | 'categories': ['video content', 'high quality video', 'video made easy', 'how to produce video with limited resources', 'viddler'], |
41e8bca4 | 26 | } |
796df3c6 | 27 | }, { |
b04fbd78 | 28 | 'url': 'http://www.viddler.com/v/4d03aad9/', |
47246ae2 | 29 | 'md5': 'f12c5a7fa839c47a79363bfdf69404fb', |
b04fbd78 S |
30 | 'info_dict': { |
31 | 'id': '4d03aad9', | |
47246ae2 | 32 | 'ext': 'ts', |
b04fbd78 | 33 | 'title': 'WALL-TO-GORTAT', |
796df3c6 S |
34 | 'upload_date': '20150126', |
35 | 'uploader': 'deadspin', | |
796df3c6 | 36 | 'timestamp': 1422285291, |
18b4e9e7 S |
37 | 'view_count': int, |
38 | 'comment_count': int, | |
796df3c6 S |
39 | } |
40 | }, { | |
b04fbd78 | 41 | 'url': 'http://www.viddler.com/player/221ebbbd/0/', |
47246ae2 | 42 | 'md5': '740511f61d3d1bb71dc14a0fe01a1c10', |
b04fbd78 S |
43 | 'info_dict': { |
44 | 'id': '221ebbbd', | |
47246ae2 | 45 | 'ext': 'mov', |
b04fbd78 S |
46 | 'title': 'LETeens-Grammar-snack-third-conditional', |
47 | 'description': ' ', | |
796df3c6 S |
48 | 'upload_date': '20140929', |
49 | 'uploader': 'BCLETeens', | |
796df3c6 | 50 | 'timestamp': 1411997190, |
18b4e9e7 S |
51 | 'view_count': int, |
52 | 'comment_count': int, | |
796df3c6 | 53 | } |
9c15869c S |
54 | }, { |
55 | # secret protected | |
56 | 'url': 'http://www.viddler.com/v/890c0985?secret=34051570', | |
57 | 'info_dict': { | |
58 | 'id': '890c0985', | |
59 | 'ext': 'mp4', | |
60 | 'title': 'Complete Property Training - Traineeships', | |
61 | 'description': ' ', | |
62 | 'upload_date': '20130606', | |
63 | 'uploader': 'TiffanyBowtell', | |
64 | 'timestamp': 1370496993, | |
65 | 'view_count': int, | |
66 | 'comment_count': int, | |
67 | }, | |
68 | 'params': { | |
69 | 'skip_download': True, | |
70 | }, | |
796df3c6 | 71 | }] |
41e8bca4 PH |
72 | |
73 | def _real_extract(self, url): | |
5ad28e7f | 74 | video_id, secret = self._match_valid_url(url).groups() |
c64ed2a3 | 75 | |
9c15869c S |
76 | query = { |
77 | 'video_id': video_id, | |
78 | 'key': 'v0vhrt7bg2xq1vyxhkct', | |
79 | } | |
9c15869c S |
80 | if secret: |
81 | query['secret'] = secret | |
82 | ||
e5855472 RA |
83 | data = self._download_json( |
84 | 'http://api.viddler.com/api/v2/viddler.videos.getPlaybackDetails.json', | |
85 | video_id, headers={'Referer': url}, query=query)['video'] | |
c64ed2a3 PH |
86 | |
87 | formats = [] | |
88 | for filed in data['files']: | |
89 | if filed.get('status', 'ready') != 'ready': | |
90 | continue | |
18b4e9e7 | 91 | format_id = filed.get('profile_id') or filed['profile_name'] |
c64ed2a3 | 92 | f = { |
18b4e9e7 | 93 | 'format_id': format_id, |
c64ed2a3 PH |
94 | 'format_note': filed['profile_name'], |
95 | 'url': self._proto_relative_url(filed['url']), | |
96 | 'width': int_or_none(filed.get('width')), | |
97 | 'height': int_or_none(filed.get('height')), | |
98 | 'filesize': int_or_none(filed.get('size')), | |
99 | 'ext': filed.get('ext'), | |
100 | 'source_preference': -1, | |
101 | } | |
102 | formats.append(f) | |
103 | ||
104 | if filed.get('cdn_url'): | |
105 | f = f.copy() | |
796df3c6 | 106 | f['url'] = self._proto_relative_url(filed['cdn_url'], 'http:') |
18b4e9e7 | 107 | f['format_id'] = format_id + '-cdn' |
c64ed2a3 PH |
108 | f['source_preference'] = 1 |
109 | formats.append(f) | |
110 | ||
111 | if filed.get('html5_video_source'): | |
112 | f = f.copy() | |
b04fbd78 | 113 | f['url'] = self._proto_relative_url(filed['html5_video_source']) |
18b4e9e7 | 114 | f['format_id'] = format_id + '-html5' |
c64ed2a3 PH |
115 | f['source_preference'] = 0 |
116 | formats.append(f) | |
117 | self._sort_formats(formats) | |
118 | ||
119 | categories = [ | |
120 | t.get('text') for t in data.get('tags', []) if 'text' in t] | |
41e8bca4 | 121 | |
fb7abb31 | 122 | return { |
41e8bca4 | 123 | 'id': video_id, |
c64ed2a3 | 124 | 'title': data['title'], |
41e8bca4 | 125 | 'formats': formats, |
c64ed2a3 PH |
126 | 'description': data.get('description'), |
127 | 'timestamp': int_or_none(data.get('upload_time')), | |
128 | 'thumbnail': self._proto_relative_url(data.get('thumbnail_url')), | |
129 | 'uploader': data.get('author'), | |
130 | 'duration': float_or_none(data.get('length')), | |
131 | 'view_count': int_or_none(data.get('view_count')), | |
18b4e9e7 | 132 | 'comment_count': int_or_none(data.get('comment_count')), |
c64ed2a3 | 133 | 'categories': categories, |
41e8bca4 | 134 | } |