[alphaporno] new extractor
[youtube-dl] / youtube_dl / extractor / alphaporno.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7 class AlphaPornoIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P<display_id>[^/]+)'
9     _TEST = {
10         'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/',
11         'md5': 'feb6d3bba8848cd54467a87ad34bd38e',
12         'info_dict': {
13             'id': '258807',
14             'ext': 'mp4',
15             'title': 'Sensual striptease porn with Samantha Alexandra - Striptease Porn',
16             'description': 'md5:c4447dc80e5be4c5f2711f7806e45424',
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_meta('encodingFormat', webpage, 'ext')[1:]
31
32         title = self._html_search_regex(
33             r'<title>([^<]+)</title>', webpage, 'title')
34
35         description = self._html_search_meta('description', webpage, 'description', fatal=False)
36
37         thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail', fatal=False)
38
39         categories_str = self._html_search_meta(
40             'keywords', webpage, 'categories', fatal=False)
41         categories = (
42             None if categories_str is None
43             else categories_str.split(','))
44
45         return {
46             'id': video_id,
47             'url': video_url,
48             'title': title,
49             'ext': ext,
50             'description': description,
51             'thumbnail': thumbnail,
52             'categories': categories,
53             'age_limit': 18,
54         }