]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/hellporno.py
[cleanup] Use `_html_extract_title`
[yt-dlp.git] / yt_dlp / 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_extract_title(webpage), ' - Hell Porno')
42
43 info = self._parse_html5_media_entries(url, webpage, display_id)[0]
44 self._sort_formats(info['formats'])
45
46 video_id = self._search_regex(
47 (r'chs_object\s*=\s*["\'](\d+)',
48 r'params\[["\']video_id["\']\]\s*=\s*(\d+)'), webpage, 'video id',
49 default=display_id)
50 description = self._search_regex(
51 r'class=["\']desc_video_view_v2[^>]+>([^<]+)', webpage,
52 'description', fatal=False)
53 categories = [
54 c.strip()
55 for c in self._html_search_meta(
56 'keywords', webpage, 'categories', default='').split(',')
57 if c.strip()]
58 duration = int_or_none(self._og_search_property(
59 'video:duration', webpage, fatal=False))
60 timestamp = unified_timestamp(self._og_search_property(
61 'video:release_date', webpage, fatal=False))
62 view_count = int_or_none(self._search_regex(
63 r'>Views\s+(\d+)', webpage, 'view count', fatal=False))
64
65 return merge_dicts(info, {
66 'id': video_id,
67 'display_id': display_id,
68 'title': title,
69 'description': description,
70 'categories': categories,
71 'duration': duration,
72 'timestamp': timestamp,
73 'view_count': view_count,
74 'age_limit': 18,
75 })