]>
Commit | Line | Data |
---|---|---|
6a1c4fbf | 1 | from __future__ import unicode_literals |
355e4146 S |
2 | |
3 | import re | |
4 | ||
6a1c4fbf | 5 | from .common import InfoExtractor |
355e4146 S |
6 | from ..utils import ( |
7 | js_to_json, | |
8 | remove_end, | |
868630fb | 9 | determine_ext, |
355e4146 | 10 | ) |
6a1c4fbf | 11 | |
513fd2a8 | 12 | |
6a1c4fbf | 13 | class HellPornoIE(InfoExtractor): |
868630fb AS |
14 | _VALID_URL = r'https?://(?:www\.)?hellporno\.(?:com/videos|net/v)/(?P<id>[^/]+)' |
15 | _TESTS = [{ | |
6a1c4fbf | 16 | 'url': 'http://hellporno.com/videos/dixie-is-posing-with-naked-ass-very-erotic/', |
17 | 'md5': '1fee339c610d2049699ef2aa699439f1', | |
18 | 'info_dict': { | |
19 | 'id': '149116', | |
513fd2a8 | 20 | 'display_id': 'dixie-is-posing-with-naked-ass-very-erotic', |
6a1c4fbf | 21 | 'ext': 'mp4', |
22 | 'title': 'Dixie is posing with naked ass very erotic', | |
ec85ded8 | 23 | 'thumbnail': r're:https?://.*\.jpg$', |
6a1c4fbf | 24 | 'age_limit': 18, |
25 | } | |
868630fb AS |
26 | }, { |
27 | 'url': 'http://hellporno.net/v/186271/', | |
28 | 'only_matching': True, | |
29 | }] | |
6a1c4fbf | 30 | |
31 | def _real_extract(self, url): | |
513fd2a8 | 32 | display_id = self._match_id(url) |
6a1c4fbf | 33 | |
355e4146 | 34 | webpage = self._download_webpage(url, display_id) |
6a1c4fbf | 35 | |
355e4146 S |
36 | title = remove_end(self._html_search_regex( |
37 | r'<title>([^<]+)</title>', webpage, 'title'), ' - Hell Porno') | |
6a1c4fbf | 38 | |
355e4146 S |
39 | flashvars = self._parse_json(self._search_regex( |
40 | r'var\s+flashvars\s*=\s*({.+?});', webpage, 'flashvars'), | |
41 | display_id, transform_source=js_to_json) | |
6a1c4fbf | 42 | |
355e4146 S |
43 | video_id = flashvars.get('video_id') |
44 | thumbnail = flashvars.get('preview_url') | |
868630fb | 45 | ext = determine_ext(flashvars.get('postfix'), 'mp4') |
6a1c4fbf | 46 | |
355e4146 S |
47 | formats = [] |
48 | for video_url_key in ['video_url', 'video_alt_url']: | |
49 | video_url = flashvars.get(video_url_key) | |
50 | if not video_url: | |
51 | continue | |
52 | video_text = flashvars.get('%s_text' % video_url_key) | |
53 | fmt = { | |
54 | 'url': video_url, | |
55 | 'ext': ext, | |
56 | 'format_id': video_text, | |
57 | } | |
58 | m = re.search(r'^(?P<height>\d+)[pP]', video_text) | |
59 | if m: | |
60 | fmt['height'] = int(m.group('height')) | |
61 | formats.append(fmt) | |
62 | self._sort_formats(formats) | |
6a1c4fbf | 63 | |
513fd2a8 | 64 | categories = self._html_search_meta( |
65 | 'keywords', webpage, 'categories', default='').split(',') | |
6a1c4fbf | 66 | |
67 | return { | |
68 | 'id': video_id, | |
513fd2a8 | 69 | 'display_id': display_id, |
6a1c4fbf | 70 | 'title': title, |
6a1c4fbf | 71 | 'thumbnail': thumbnail, |
72 | 'categories': categories, | |
73 | 'age_limit': 18, | |
355e4146 | 74 | 'formats': formats, |
6a1c4fbf | 75 | } |