]>
Commit | Line | Data |
---|---|---|
e299f6d2 PH |
1 | from __future__ import unicode_literals |
2 | ||
8e05c870 MO |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
842cca7d | 6 | from ..utils import ( |
48fb963b | 7 | determine_ext, |
667d9648 | 8 | ExtractorError, |
842cca7d S |
9 | int_or_none, |
10 | js_to_json, | |
48fb963b | 11 | urljoin, |
842cca7d | 12 | ) |
8e05c870 | 13 | |
6f5dcd4e | 14 | |
8e05c870 | 15 | class PornHdIE(InfoExtractor): |
5886b38d | 16 | _VALID_URL = r'https?://(?:www\.)?pornhd\.com/(?:[a-z]{2,4}/)?videos/(?P<id>\d+)(?:/(?P<display_id>.+))?' |
e3944c26 S |
17 | _TESTS = [{ |
18 | 'url': 'http://www.pornhd.com/videos/9864/selfie-restroom-masturbation-fun-with-chubby-cutie-hd-porn-video', | |
48fb963b | 19 | 'md5': '87f1540746c1d32ec7a2305c12b96b25', |
e3944c26 S |
20 | 'info_dict': { |
21 | 'id': '9864', | |
22 | 'display_id': 'selfie-restroom-masturbation-fun-with-chubby-cutie-hd-porn-video', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Restroom selfie masturbation', | |
25 | 'description': 'md5:3748420395e03e31ac96857a8f125b2b', | |
ec85ded8 | 26 | 'thumbnail': r're:^https?://.*\.jpg', |
e3944c26 | 27 | 'view_count': int, |
70c3ee13 | 28 | 'like_count': int, |
e3944c26 | 29 | 'age_limit': 18, |
19a107f2 | 30 | } |
e3944c26 | 31 | }, { |
19a107f2 | 32 | # removed video |
e299f6d2 | 33 | 'url': 'http://www.pornhd.com/videos/1962/sierra-day-gets-his-cum-all-over-herself-hd-porn-video', |
19a107f2 | 34 | 'md5': '956b8ca569f7f4d8ec563e2c41598441', |
e299f6d2 | 35 | 'info_dict': { |
4b9cced1 | 36 | 'id': '1962', |
842cca7d | 37 | 'display_id': 'sierra-day-gets-his-cum-all-over-herself-hd-porn-video', |
4b9cced1 | 38 | 'ext': 'mp4', |
19a107f2 | 39 | 'title': 'Sierra loves doing laundry', |
4b9cced1 | 40 | 'description': 'md5:8ff0523848ac2b8f9b065ba781ccf294', |
ec85ded8 | 41 | 'thumbnail': r're:^https?://.*\.jpg', |
842cca7d | 42 | 'view_count': int, |
70c3ee13 | 43 | 'like_count': int, |
4b9cced1 | 44 | 'age_limit': 18, |
e3944c26 | 45 | }, |
19a107f2 | 46 | 'skip': 'Not available anymore', |
e3944c26 | 47 | }] |
8e05c870 MO |
48 | |
49 | def _real_extract(self, url): | |
50 | mobj = re.match(self._VALID_URL, url) | |
4b9cced1 | 51 | video_id = mobj.group('id') |
842cca7d | 52 | display_id = mobj.group('display_id') |
8e05c870 | 53 | |
842cca7d | 54 | webpage = self._download_webpage(url, display_id or video_id) |
8e05c870 | 55 | |
ceff3fd8 | 56 | title = self._html_search_regex( |
1b381853 S |
57 | [r'<span[^>]+class=["\']video-name["\'][^>]*>([^<]+)', |
58 | r'<title>(.+?) - .*?[Pp]ornHD.*?</title>'], webpage, 'title') | |
4b9cced1 | 59 | |
667d9648 | 60 | sources = self._parse_json(js_to_json(self._search_regex( |
3902cdd0 | 61 | r"(?s)sources'?\s*[:=]\s*(\{.+?\})", |
667d9648 S |
62 | webpage, 'sources', default='{}')), video_id) |
63 | ||
64 | if not sources: | |
65 | message = self._html_search_regex( | |
66 | r'(?s)<(div|p)[^>]+class="no-video"[^>]*>(?P<value>.+?)</\1', | |
67 | webpage, 'error message', group='value') | |
68 | raise ExtractorError('%s said: %s' % (self.IE_NAME, message), expected=True) | |
69 | ||
807962f4 | 70 | formats = [] |
e6fe993c | 71 | for format_id, video_url in sources.items(): |
48fb963b | 72 | video_url = urljoin(url, video_url) |
f7a211dc PH |
73 | if not video_url: |
74 | continue | |
e6fe993c S |
75 | height = int_or_none(self._search_regex( |
76 | r'^(\d+)[pP]', format_id, 'height', default=None)) | |
f7a211dc PH |
77 | formats.append({ |
78 | 'url': video_url, | |
48fb963b | 79 | 'ext': determine_ext(video_url, 'mp4'), |
e6fe993c S |
80 | 'format_id': format_id, |
81 | 'height': height, | |
f7a211dc | 82 | }) |
19a107f2 | 83 | self._sort_formats(formats) |
8e05c870 | 84 | |
667d9648 | 85 | description = self._html_search_regex( |
19a107f2 AG |
86 | r'<(div|p)[^>]+class="description"[^>]*>(?P<value>[^<]+)</\1', |
87 | webpage, 'description', fatal=False, group='value') | |
667d9648 S |
88 | view_count = int_or_none(self._html_search_regex( |
89 | r'(\d+) views\s*<', webpage, 'view count', fatal=False)) | |
90 | thumbnail = self._search_regex( | |
3902cdd0 | 91 | r"poster'?\s*:\s*([\"'])(?P<url>(?:(?!\1).)+)\1", webpage, |
19a107f2 | 92 | 'thumbnail', fatal=False, group='url') |
667d9648 | 93 | |
70c3ee13 | 94 | like_count = int_or_none(self._search_regex( |
19a107f2 | 95 | (r'(\d+)\s*</11[^>]+>(?: |\s)*\blikes', |
70c3ee13 J |
96 | r'class=["\']save-count["\'][^>]*>\s*(\d+)'), |
97 | webpage, 'like count', fatal=False)) | |
98 | ||
19a107f2 | 99 | return { |
6f5dcd4e | 100 | 'id': video_id, |
842cca7d | 101 | 'display_id': display_id, |
4b9cced1 S |
102 | 'title': title, |
103 | 'description': description, | |
104 | 'thumbnail': thumbnail, | |
105 | 'view_count': view_count, | |
70c3ee13 | 106 | 'like_count': like_count, |
4b9cced1 S |
107 | 'formats': formats, |
108 | 'age_limit': 18, | |
19a107f2 | 109 | } |