Merge branch 'hellporno' of https://github.com/peugeot/youtube-dl into peugeot-hellporno
[youtube-dl] / youtube_dl / extractor / hellporno.py
1 from __future__ import unicode_literals
2 from .common import InfoExtractor
3
4
5 class HellPornoIE(InfoExtractor):
6     _VALID_URL = r'https?://(?:www\.)?hellporno\.com/videos/(?P<id>[^/]+)'
7     _TEST = {
8         'url': 'http://hellporno.com/videos/dixie-is-posing-with-naked-ass-very-erotic/',
9         'md5': '1fee339c610d2049699ef2aa699439f1',
10         'info_dict': {
11             'id': '149116',
12             'display_id': 'dixie-is-posing-with-naked-ass-very-erotic',
13             'ext': 'mp4',
14             'title': 'Dixie is posing with naked ass very erotic',
15             'thumbnail': 're:https?://.*\.jpg$',
16             'age_limit': 18,
17         }
18     }
19
20     def _real_extract(self, url):
21         display_id = self._match_id(url)
22         webpage = self._download_webpage(url, display_id)
23
24         video_id = self._html_search_regex(
25             r'video_id:\s*\'([^\']+)\'', webpage, 'id')
26
27         ext = self._html_search_regex(
28             r'postfix:\s*\'([^\']+)\'', webpage, 'ext')[1:]
29
30         video_url = self._html_search_regex(
31             r'video_url:\s*\'([^\']+)\'', webpage, 'video_url')
32
33         title = self._html_search_regex(
34             r'<title>([^<]+)\s*-\s*Hell Porno</title>', webpage, 'title')
35
36         thumbnail = self._html_search_regex(
37             r'preview_url:\s*\'([^\']+)\'',
38             webpage, 'thumbnail', fatal=False)
39
40         categories = self._html_search_meta(
41             'keywords', webpage, 'categories', default='').split(',')
42
43         return {
44             'id': video_id,
45             'display_id': display_id,
46             'url': video_url,
47             'title': title,
48             'ext': ext,
49             'thumbnail': thumbnail,
50             'categories': categories,
51             'age_limit': 18,
52         }