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