]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pornhd.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
16 class PornHdIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?pornhd\.com/(?:[a-z]{2,4}/)?videos/(?P<id>\d+)(?:/(?P<display_id>.+))?'
19 'url': 'http://www.pornhd.com/videos/9864/selfie-restroom-masturbation-fun-with-chubby-cutie-hd-porn-video',
20 'md5': '87f1540746c1d32ec7a2305c12b96b25',
23 'display_id': 'selfie-restroom-masturbation-fun-with-chubby-cutie-hd-porn-video',
25 'title': 'Restroom selfie masturbation',
26 'description': 'md5:3748420395e03e31ac96857a8f125b2b',
27 'thumbnail': r
're:^https?://.*\.jpg',
32 'skip': 'HTTP Error 404: Not Found',
34 'url': 'http://www.pornhd.com/videos/1962/sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
35 'md5': '1b7b3a40b9d65a8e5b25f7ab9ee6d6de',
38 'display_id': 'sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
40 'title': 'md5:98c6f8b2d9c229d0f0fde47f61a1a759',
41 'description': 'md5:8ff0523848ac2b8f9b065ba781ccf294',
42 'thumbnail': r
're:^https?://.*\.jpg',
49 def _real_extract(self
, url
):
50 mobj
= re
.match(self
._VALID
_URL
, url
)
51 video_id
= mobj
.group('id')
52 display_id
= mobj
.group('display_id')
54 webpage
= self
._download
_webpage
(url
, display_id
or video_id
)
56 title
= self
._html
_search
_regex
(
57 [r
'<span[^>]+class=["\']video
-name
["\'][^>]*>([^<]+)',
58 r'<title>(.+?) - .*?[Pp]ornHD.*?</title>'], webpage, 'title')
60 sources = self._parse_json(js_to_json(self._search_regex(
61 r"(?s
)sources
'?\s*[:=]\s*(\{.+?\})",
62 webpage, 'sources
', default='{}')), video_id)
66 entries = self._parse_html5_media_entries(url, webpage, video_id)
70 if not sources and not info:
71 message = self._html_search_regex(
72 r'(?s
)<(div|p
)[^
>]+class="no-video"[^
>]*>(?P
<value
>.+?
)</\
1',
73 webpage, 'error message
', group='value
')
74 raise ExtractorError('%s said
: %s' % (self.IE_NAME, message), expected=True)
77 for format_id, video_url in sources.items():
78 video_url = urljoin(url, video_url)
81 height = int_or_none(self._search_regex(
82 r'^
(\d
+)[pP
]', format_id, 'height
', default=None))
85 'ext
': determine_ext(video_url, 'mp4
'),
86 'format_id
': format_id,
90 info['formats
'] = formats
91 self._sort_formats(info['formats
'])
93 description = self._html_search_regex(
94 (r'(?s
)<section
[^
>]+class=["\']video-description[^>]+>(?P<value>.+?)</section>',
95 r'<(div|p)[^>]+class="description
"[^>]*>(?P<value>[^<]+)</\1'),
96 webpage, 'description', fatal=False,
97 group='value') or self._html_search_meta(
98 'description', webpage, default=None) or self._og_search_description(webpage)
99 view_count = int_or_none(self._html_search_regex(
100 r'(\d+) views\s*<', webpage, 'view count', fatal=False))
101 thumbnail = self._search_regex(
102 r"poster
'?\s*:\s*([\"'])(?P
<url
>(?
:(?
!\
1).)+)\
1", webpage,
103 'thumbnail', default=None, group='url')
105 like_count = int_or_none(self._search_regex(
106 (r'(\d+)</span>\s*likes',
107 r'(\d+)\s*</11[^>]+>(?: |\s)*\blikes',
108 r'class=["\']save
-count
["\'][^>]*>\s*(\d+)'),
109 webpage, 'like count', fatal=False))
111 return merge_dicts(info, {
113 'display_id': display_id,
115 'description': description,
116 'thumbnail': thumbnail,
117 'view_count': view_count,
118 'like_count': like_count,