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