]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/hellporno.py
[ChangeLog] Actualize
[youtube-dl.git] / youtube_dl / extractor / hellporno.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5     int_or_none,
6     merge_dicts,
7     remove_end,
8     unified_timestamp,
9 )
10
11
12 class HellPornoIE(InfoExtractor):
13     _VALID_URL = r'https?://(?:www\.)?hellporno\.(?:com/videos|net/v)/(?P<id>[^/]+)'
14     _TESTS = [{
15         'url': 'http://hellporno.com/videos/dixie-is-posing-with-naked-ass-very-erotic/',
16         'md5': 'f0a46ebc0bed0c72ae8fe4629f7de5f3',
17         'info_dict': {
18             'id': '149116',
19             'display_id': 'dixie-is-posing-with-naked-ass-very-erotic',
20             'ext': 'mp4',
21             'title': 'Dixie is posing with naked ass very erotic',
22             'description': 'md5:9a72922749354edb1c4b6e540ad3d215',
23             'categories': list,
24             'thumbnail': r're:https?://.*\.jpg$',
25             'duration': 240,
26             'timestamp': 1398762720,
27             'upload_date': '20140429',
28             'view_count': int,
29             'age_limit': 18,
30         },
31     }, {
32         'url': 'http://hellporno.net/v/186271/',
33         'only_matching': True,
34     }]
35
36     def _real_extract(self, url):
37         display_id = self._match_id(url)
38
39         webpage = self._download_webpage(url, display_id)
40
41         title = remove_end(self._html_search_regex(
42             r'<title>([^<]+)</title>', webpage, 'title'), ' - Hell Porno')
43
44         info = self._parse_html5_media_entries(url, webpage, display_id)[0]
45         self._sort_formats(info['formats'])
46
47         video_id = self._search_regex(
48             (r'chs_object\s*=\s*["\'](\d+)',
49              r'params\[["\']video_id["\']\]\s*=\s*(\d+)'), webpage, 'video id',
50             default=display_id)
51         description = self._search_regex(
52             r'class=["\']desc_video_view_v2[^>]+>([^<]+)', webpage,
53             'description', fatal=False)
54         categories = [
55             c.strip()
56             for c in self._html_search_meta(
57                 'keywords', webpage, 'categories', default='').split(',')
58             if c.strip()]
59         duration = int_or_none(self._og_search_property(
60             'video:duration', webpage, fatal=False))
61         timestamp = unified_timestamp(self._og_search_property(
62             'video:release_date', webpage, fatal=False))
63         view_count = int_or_none(self._search_regex(
64             r'>Views\s+(\d+)', webpage, 'view count', fatal=False))
65
66         return merge_dicts(info, {
67             'id': video_id,
68             'display_id': display_id,
69             'title': title,
70             'description': description,
71             'categories': categories,
72             'duration': duration,
73             'timestamp': timestamp,
74             'view_count': view_count,
75             'age_limit': 18,
76         })