]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | ExtractorError, | |
4 | encode_base_n, | |
5 | get_elements_by_class, | |
6 | int_or_none, | |
7 | join_nonempty, | |
8 | merge_dicts, | |
9 | parse_duration, | |
10 | str_to_int, | |
11 | url_or_none, | |
12 | ) | |
13 | ||
14 | ||
15 | class EpornerIE(InfoExtractor): | |
16 | _VALID_URL = r'https?://(?:www\.)?eporner\.com/(?:(?:hd-porn|embed)/|video-)(?P<id>\w+)(?:/(?P<display_id>[\w-]+))?' | |
17 | _TESTS = [{ | |
18 | 'url': 'http://www.eporner.com/hd-porn/95008/Infamous-Tiffany-Teen-Strip-Tease-Video/', | |
19 | 'md5': '39d486f046212d8e1b911c52ab4691f8', | |
20 | 'info_dict': { | |
21 | 'id': 'qlDUmNsj6VS', | |
22 | 'display_id': 'Infamous-Tiffany-Teen-Strip-Tease-Video', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Infamous Tiffany Teen Strip Tease Video', | |
25 | 'description': 'md5:764f39abf932daafa37485eb46efa152', | |
26 | 'timestamp': 1232520922, | |
27 | 'upload_date': '20090121', | |
28 | 'duration': 1838, | |
29 | 'view_count': int, | |
30 | 'age_limit': 18, | |
31 | }, | |
32 | 'params': { | |
33 | 'proxy': '127.0.0.1:8118', | |
34 | }, | |
35 | }, { | |
36 | # New (May 2016) URL layout | |
37 | 'url': 'http://www.eporner.com/hd-porn/3YRUtzMcWn0/Star-Wars-XXX-Parody/', | |
38 | 'only_matching': True, | |
39 | }, { | |
40 | 'url': 'http://www.eporner.com/hd-porn/3YRUtzMcWn0', | |
41 | 'only_matching': True, | |
42 | }, { | |
43 | 'url': 'http://www.eporner.com/embed/3YRUtzMcWn0', | |
44 | 'only_matching': True, | |
45 | }, { | |
46 | 'url': 'https://www.eporner.com/video-FJsA19J3Y3H/one-of-the-greats/', | |
47 | 'only_matching': True, | |
48 | }] | |
49 | ||
50 | def _real_extract(self, url): | |
51 | mobj = self._match_valid_url(url) | |
52 | video_id = mobj.group('id') | |
53 | display_id = mobj.group('display_id') or video_id | |
54 | ||
55 | webpage, urlh = self._download_webpage_handle(url, display_id) | |
56 | ||
57 | video_id = self._match_id(urlh.url) | |
58 | ||
59 | vid_hash = self._search_regex( | |
60 | r'hash\s*[:=]\s*["\']([\da-f]{32})', webpage, 'hash') | |
61 | ||
62 | title = self._og_search_title(webpage, default=None) or self._html_search_regex( | |
63 | r'<title>(.+?) - EPORNER', webpage, 'title') | |
64 | ||
65 | # Reverse engineered from vjs.js | |
66 | def calc_hash(s): | |
67 | return ''.join(encode_base_n(int(s[lb:lb + 8], 16), 36) for lb in range(0, 32, 8)) | |
68 | ||
69 | video = self._download_json( | |
70 | f'http://www.eporner.com/xhr/video/{video_id}', | |
71 | display_id, note='Downloading video JSON', | |
72 | query={ | |
73 | 'hash': calc_hash(vid_hash), | |
74 | 'device': 'generic', | |
75 | 'domain': 'www.eporner.com', | |
76 | 'fallback': 'false', | |
77 | }) | |
78 | ||
79 | if video.get('available') is False: | |
80 | raise ExtractorError( | |
81 | '{} said: {}'.format(self.IE_NAME, video['message']), expected=True) | |
82 | ||
83 | sources = video['sources'] | |
84 | ||
85 | formats = [] | |
86 | has_av1 = bool(get_elements_by_class('download-av1', webpage)) | |
87 | for kind, formats_dict in sources.items(): | |
88 | if not isinstance(formats_dict, dict): | |
89 | continue | |
90 | for format_id, format_dict in formats_dict.items(): | |
91 | if not isinstance(format_dict, dict): | |
92 | continue | |
93 | src = url_or_none(format_dict.get('src')) | |
94 | if not src or not src.startswith('http'): | |
95 | continue | |
96 | if kind == 'hls': | |
97 | formats.extend(self._extract_m3u8_formats( | |
98 | src, display_id, 'mp4', entry_protocol='m3u8_native', | |
99 | m3u8_id=kind, fatal=False)) | |
100 | else: | |
101 | height = int_or_none(self._search_regex( | |
102 | r'(\d+)[pP]', format_id, 'height', default=None)) | |
103 | fps = int_or_none(self._search_regex( | |
104 | r'(\d+)fps', format_id, 'fps', default=None)) | |
105 | ||
106 | formats.append({ | |
107 | 'url': src, | |
108 | 'format_id': format_id, | |
109 | 'height': height, | |
110 | 'fps': fps, | |
111 | }) | |
112 | if has_av1: | |
113 | formats.append({ | |
114 | 'url': src.replace('.mp4', '-av1.mp4'), | |
115 | 'format_id': join_nonempty('av1', format_id), | |
116 | 'height': height, | |
117 | 'fps': fps, | |
118 | 'vcodec': 'av1', | |
119 | }) | |
120 | ||
121 | json_ld = self._search_json_ld(webpage, display_id, default={}) | |
122 | ||
123 | duration = parse_duration(self._html_search_meta( | |
124 | 'duration', webpage, default=None)) | |
125 | view_count = str_to_int(self._search_regex( | |
126 | r'id=["\']cinemaviews1["\'][^>]*>\s*([0-9,]+)', | |
127 | webpage, 'view count', default=None)) | |
128 | ||
129 | return merge_dicts(json_ld, { | |
130 | 'id': video_id, | |
131 | 'display_id': display_id, | |
132 | 'title': title, | |
133 | 'duration': duration, | |
134 | 'view_count': view_count, | |
135 | 'formats': formats, | |
136 | 'age_limit': 18, | |
137 | }) |