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