]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/pornhd.py
Merge pull request #2340 from Fnordlab/master
[youtube-dl.git] / youtube_dl / extractor / pornhd.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import compat_urllib_parse
7
8
9 class PornHdIE(InfoExtractor):
10     _VALID_URL = r'(?:http://)?(?:www\.)?pornhd\.com/(?:[a-z]{2,4}/)?videos/(?P<video_id>[0-9]+)/(?P<video_title>.+)'
11     _TEST = {
12         'url': 'http://www.pornhd.com/videos/1962/sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
13         'file': '1962.flv',
14         'md5': '35272469887dca97abd30abecc6cdf75',
15         'info_dict': {
16             "title": "sierra-day-gets-his-cum-all-over-herself-hd-porn-video",
17             "age_limit": 18,
18         }
19     }
20
21     def _real_extract(self, url):
22         mobj = re.match(self._VALID_URL, url)
23
24         video_id = mobj.group('video_id')
25         video_title = mobj.group('video_title')
26
27         webpage = self._download_webpage(url, video_id)
28
29         next_url = self._html_search_regex(
30             r'&hd=(http.+?)&', webpage, 'video URL')
31         next_url = compat_urllib_parse.unquote(next_url)
32
33         video_url = self._download_webpage(
34             next_url, video_id, note='Retrieving video URL',
35             errnote='Could not retrieve video URL')
36         age_limit = 18
37
38         return {
39             'id': video_id,
40             'url': video_url,
41             'ext': 'flv',
42             'title': video_title,
43             'age_limit': age_limit,
44         }