]>
Commit | Line | Data |
---|---|---|
1d57b252 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
48d4681e PH |
7 | from ..utils import ( |
8 | parse_duration, | |
9 | str_to_int, | |
10 | ) | |
11 | ||
1d57b252 | 12 | |
13 | class EpornerIE(InfoExtractor): | |
4ee0b8af | 14 | _VALID_URL = r'https?://(?:www\.)?eporner\.com/hd-porn/(?P<id>\w+)/(?P<display_id>[\w-]+)' |
15 | _TESTS = [{ | |
1d57b252 | 16 | 'url': 'http://www.eporner.com/hd-porn/95008/Infamous-Tiffany-Teen-Strip-Tease-Video/', |
8c23945c | 17 | 'md5': '39d486f046212d8e1b911c52ab4691f8', |
1d57b252 | 18 | 'info_dict': { |
19 | 'id': '95008', | |
a7862a1b | 20 | 'display_id': 'Infamous-Tiffany-Teen-Strip-Tease-Video', |
8c23945c | 21 | 'ext': 'mp4', |
1d57b252 | 22 | 'title': 'Infamous Tiffany Teen Strip Tease Video', |
6a68bb57 | 23 | 'duration': 1838, |
48d4681e | 24 | 'view_count': int, |
563f6dea | 25 | 'age_limit': 18, |
4ee0b8af | 26 | }, |
6f748df4 S |
27 | }, { |
28 | # New (May 2016) URL layout | |
4ee0b8af | 29 | 'url': 'http://www.eporner.com/hd-porn/3YRUtzMcWn0/Star-Wars-XXX-Parody/', |
6f748df4 | 30 | 'only_matching': True, |
4ee0b8af | 31 | }] |
1d57b252 | 32 | |
33 | def _real_extract(self, url): | |
34 | mobj = re.match(self._VALID_URL, url) | |
35 | video_id = mobj.group('id') | |
a7862a1b S |
36 | display_id = mobj.group('display_id') |
37 | ||
38 | webpage = self._download_webpage(url, display_id) | |
48d4681e PH |
39 | title = self._html_search_regex( |
40 | r'<title>(.*?) - EPORNER', webpage, 'title') | |
1d57b252 | 41 | |
37f88565 | 42 | redirect_url = 'http://www.eporner.com/config5/%s' % video_id |
563f6dea | 43 | player_code = self._download_webpage( |
a7862a1b S |
44 | redirect_url, display_id, note='Downloading player config') |
45 | ||
46 | sources = self._search_regex( | |
47 | r'(?s)sources\s*:\s*\[\s*({.+?})\s*\]', player_code, 'sources') | |
48 | ||
49 | formats = [] | |
50 | for video_url, format_id in re.findall(r'file\s*:\s*"([^"]+)",\s*label\s*:\s*"([^"]+)"', sources): | |
51 | fmt = { | |
52 | 'url': video_url, | |
53 | 'format_id': format_id, | |
54 | } | |
55 | m = re.search(r'^(\d+)', format_id) | |
56 | if m: | |
57 | fmt['height'] = int(m.group(1)) | |
58 | formats.append(fmt) | |
59 | self._sort_formats(formats) | |
1d57b252 | 60 | |
6a68bb57 | 61 | duration = parse_duration(self._html_search_meta('duration', webpage)) |
48d4681e PH |
62 | view_count = str_to_int(self._search_regex( |
63 | r'id="cinemaviews">\s*([0-9,]+)\s*<small>views', | |
64 | webpage, 'view count', fatal=False)) | |
1d57b252 | 65 | |
66 | return { | |
67 | 'id': video_id, | |
a7862a1b | 68 | 'display_id': display_id, |
1d57b252 | 69 | 'title': title, |
48d4681e PH |
70 | 'duration': duration, |
71 | 'view_count': view_count, | |
a7862a1b | 72 | 'formats': formats, |
37f88565 | 73 | 'age_limit': 18, |
1d57b252 | 74 | } |