]>
Commit | Line | Data |
---|---|---|
f46f4a99 PH |
1 | from __future__ import unicode_literals |
2 | ||
99e350d9 | 3 | from .common import InfoExtractor |
1cc79574 | 4 | from ..utils import ( |
b540697a | 5 | int_or_none, |
197cf8b7 RA |
6 | parse_duration, |
7 | qualities, | |
b540697a | 8 | ) |
f46f4a99 | 9 | |
99e350d9 JMF |
10 | |
11 | class VeohIE(InfoExtractor): | |
a072a12e | 12 | _VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|embed|iphone/#_Watch)/(?P<id>(?:v|e|yapi-)[\da-zA-Z]+)' |
b540697a | 13 | |
15237fcd | 14 | _TESTS = [{ |
15 | 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3', | |
197cf8b7 | 16 | 'md5': '9e7ecc0fd8bbee7a69fe38953aeebd30', |
15237fcd | 17 | 'info_dict': { |
197cf8b7 | 18 | 'id': 'v56314296nk7Zdmz3', |
15237fcd | 19 | 'ext': 'mp4', |
20 | 'title': 'Straight Backs Are Stronger', | |
21 | 'uploader': 'LUMOback', | |
22 | 'description': 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ', | |
b540697a | 23 | }, |
a072a12e JS |
24 | }, { |
25 | 'url': 'http://www.veoh.com/embed/v56314296nk7Zdmz3', | |
26 | 'only_matching': True, | |
15237fcd | 27 | }, { |
28 | 'url': 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage', | |
29 | 'md5': '4a6ff84b87d536a6a71e6aa6c0ad07fa', | |
30 | 'info_dict': { | |
31 | 'id': '27701988', | |
32 | 'ext': 'mp4', | |
33 | 'title': 'Chile workers cover up to avoid skin damage', | |
34 | 'description': 'md5:2bd151625a60a32822873efc246ba20d', | |
35 | 'uploader': 'afp-news', | |
36 | 'duration': 123, | |
b540697a | 37 | }, |
15237fcd | 38 | 'skip': 'This video has been deleted.', |
39 | }, { | |
40 | 'url': 'http://www.veoh.com/watch/v69525809F6Nc4frX', | |
41 | 'md5': '4fde7b9e33577bab2f2f8f260e30e979', | |
42 | 'note': 'Embedded ooyala video', | |
43 | 'info_dict': { | |
44 | 'id': '69525809', | |
45 | 'ext': 'mp4', | |
46 | 'title': 'Doctors Alter Plan For Preteen\'s Weight Loss Surgery', | |
47 | 'description': 'md5:f5a11c51f8fb51d2315bca0937526891', | |
48 | 'uploader': 'newsy-videos', | |
b540697a | 49 | }, |
15237fcd | 50 | 'skip': 'This video has been deleted.', |
51 | }, { | |
52 | 'url': 'http://www.veoh.com/watch/e152215AJxZktGS', | |
53 | 'only_matching': True, | |
54 | }] | |
b540697a | 55 | |
b540697a S |
56 | def _extract_video(self, source): |
57 | return { | |
58 | 'id': source.get('videoId'), | |
59 | 'title': source.get('title'), | |
60 | 'description': source.get('description'), | |
61 | 'thumbnail': source.get('highResImage') or source.get('medResImage'), | |
62 | 'uploader': source.get('username'), | |
63 | 'duration': int_or_none(source.get('length')), | |
64 | 'view_count': int_or_none(source.get('views')), | |
65 | 'age_limit': 18 if source.get('isMature') == 'true' or source.get('isSexy') == 'true' else 0, | |
66 | 'formats': self._extract_formats(source), | |
99e350d9 | 67 | } |
99e350d9 JMF |
68 | |
69 | def _real_extract(self, url): | |
197cf8b7 RA |
70 | video_id = self._match_id(url) |
71 | video = self._download_json( | |
72 | 'https://www.veoh.com/watch/getVideo/' + video_id, | |
73 | video_id)['video'] | |
74 | title = video['title'] | |
99e350d9 | 75 | |
197cf8b7 RA |
76 | thumbnail_url = None |
77 | q = qualities(['HQ', 'Regular']) | |
78 | formats = [] | |
79 | for f_id, f_url in video.get('src', {}).items(): | |
80 | if not f_url: | |
81 | continue | |
82 | if f_id == 'poster': | |
83 | thumbnail_url = f_url | |
84 | else: | |
85 | formats.append({ | |
86 | 'format_id': f_id, | |
87 | 'quality': q(f_id), | |
88 | 'url': f_url, | |
89 | }) | |
90 | self._sort_formats(formats) | |
b540697a | 91 | |
197cf8b7 RA |
92 | return { |
93 | 'id': video_id, | |
94 | 'title': title, | |
95 | 'description': video.get('description'), | |
96 | 'thumbnail': thumbnail_url, | |
97 | 'uploader': video.get('author', {}).get('nickname'), | |
98 | 'duration': int_or_none(video.get('lengthBySec')) or parse_duration(video.get('length')), | |
99 | 'view_count': int_or_none(video.get('views')), | |
100 | 'formats': formats, | |
101 | 'average_rating': int_or_none(video.get('rating')), | |
102 | 'comment_count': int_or_none(video.get('numOfComments')), | |
103 | } |