]>
Commit | Line | Data |
---|---|---|
1 | import re | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | parse_duration, | |
6 | int_or_none, | |
7 | strip_or_none, | |
8 | traverse_obj, | |
9 | url_or_none, | |
10 | ) | |
11 | ||
12 | ||
13 | class NuvidIE(InfoExtractor): | |
14 | _VALID_URL = r'https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)' | |
15 | _TESTS = [{ | |
16 | 'url': 'https://www.nuvid.com/video/6513023/italian-babe', | |
17 | 'md5': '772d2f8288f3d3c5c45f7a41761c7844', | |
18 | 'info_dict': { | |
19 | 'id': '6513023', | |
20 | 'ext': 'mp4', | |
21 | 'title': 'italian babe', | |
22 | 'duration': 321.0, | |
23 | 'age_limit': 18, | |
24 | 'thumbnail': r're:https?://.+\.jpg', | |
25 | } | |
26 | }, { | |
27 | 'url': 'https://m.nuvid.com/video/6523263', | |
28 | 'md5': 'ebd22ce8e47e1d9a4d0756a15c67da52', | |
29 | 'info_dict': { | |
30 | 'id': '6523263', | |
31 | 'ext': 'mp4', | |
32 | 'title': 'Slut brunette college student anal dorm', | |
33 | 'duration': 421.0, | |
34 | 'age_limit': 18, | |
35 | 'thumbnail': r're:https?://.+\.jpg', | |
36 | 'thumbnails': list, | |
37 | } | |
38 | }, { | |
39 | 'url': 'http://m.nuvid.com/video/6415801/', | |
40 | 'md5': '638d5ececb138d5753593f751ae3f697', | |
41 | 'info_dict': { | |
42 | 'id': '6415801', | |
43 | 'ext': 'mp4', | |
44 | 'title': 'My best friend wanted to fuck my wife for a long time', | |
45 | 'duration': 1882, | |
46 | 'age_limit': 18, | |
47 | 'thumbnail': r're:https?://.+\.jpg', | |
48 | } | |
49 | }] | |
50 | ||
51 | def _real_extract(self, url): | |
52 | video_id = self._match_id(url) | |
53 | ||
54 | qualities = { | |
55 | 'lq': '360p', | |
56 | 'hq': '720p', | |
57 | } | |
58 | ||
59 | json_url = f'https://www.nuvid.com/player_config_json/?vid={video_id}&aid=0&domain_id=0&embed=0&check_speed=0' | |
60 | video_data = self._download_json( | |
61 | json_url, video_id, headers={ | |
62 | 'Accept': 'application/json, text/javascript, */*; q = 0.01', | |
63 | 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', | |
64 | }) | |
65 | ||
66 | webpage = self._download_webpage( | |
67 | 'http://m.nuvid.com/video/%s' % (video_id, ), | |
68 | video_id, 'Downloading video page', fatal=False) or '' | |
69 | ||
70 | title = strip_or_none(video_data.get('title') or self._html_search_regex( | |
71 | (r'''<span\s[^>]*?\btitle\s*=\s*(?P<q>"|'|\b)(?P<title>[^"]+)(?P=q)\s*>''', | |
72 | r'''<div\s[^>]*?\bclass\s*=\s*(?P<q>"|'|\b)thumb-holder video(?P=q)>\s*<h5\b[^>]*>(?P<title>[^<]+)</h5''', | |
73 | r'''<span\s[^>]*?\bclass\s*=\s*(?P<q>"|'|\b)title_thumb(?P=q)>(?P<title>[^<]+)</span'''), | |
74 | webpage, 'title', group='title')) | |
75 | ||
76 | formats = [{ | |
77 | 'url': source, | |
78 | 'format_id': qualities.get(quality), | |
79 | 'height': int_or_none(qualities.get(quality)[:-1]), | |
80 | } for quality, source in video_data.get('files').items() if source] | |
81 | ||
82 | self._check_formats(formats, video_id) | |
83 | ||
84 | duration = parse_duration(traverse_obj(video_data, 'duration', 'duration_format')) | |
85 | thumbnails = [ | |
86 | {'url': thumb_url} for thumb_url in re.findall( | |
87 | r'<div\s+class\s*=\s*"video-tmb-wrap"\s*>\s*<img\s+src\s*=\s*"([^"]+)"\s*/>', webpage) | |
88 | if url_or_none(thumb_url)] | |
89 | if url_or_none(video_data.get('poster')): | |
90 | thumbnails.append({'url': video_data['poster'], 'preference': 1}) | |
91 | ||
92 | return { | |
93 | 'id': video_id, | |
94 | 'formats': formats, | |
95 | 'title': title, | |
96 | 'thumbnails': thumbnails, | |
97 | 'duration': duration, | |
98 | 'age_limit': 18, | |
99 | } |