]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hellporno.py
Update upstream source from tag 'upstream/2019.09.28'
[youtubedl] / youtube_dl / extractor / hellporno.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 js_to_json,
8 remove_end,
9 determine_ext,
10 )
11
12
13 class HellPornoIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?hellporno\.(?:com/videos|net/v)/(?P<id>[^/]+)'
15 _TESTS = [{
16 'url': 'http://hellporno.com/videos/dixie-is-posing-with-naked-ass-very-erotic/',
17 'md5': '1fee339c610d2049699ef2aa699439f1',
18 'info_dict': {
19 'id': '149116',
20 'display_id': 'dixie-is-posing-with-naked-ass-very-erotic',
21 'ext': 'mp4',
22 'title': 'Dixie is posing with naked ass very erotic',
23 'thumbnail': r're:https?://.*\.jpg$',
24 'age_limit': 18,
25 }
26 }, {
27 'url': 'http://hellporno.net/v/186271/',
28 'only_matching': True,
29 }]
30
31 def _real_extract(self, url):
32 display_id = self._match_id(url)
33
34 webpage = self._download_webpage(url, display_id)
35
36 title = remove_end(self._html_search_regex(
37 r'<title>([^<]+)</title>', webpage, 'title'), ' - Hell Porno')
38
39 flashvars = self._parse_json(self._search_regex(
40 r'var\s+flashvars\s*=\s*({.+?});', webpage, 'flashvars'),
41 display_id, transform_source=js_to_json)
42
43 video_id = flashvars.get('video_id')
44 thumbnail = flashvars.get('preview_url')
45 ext = determine_ext(flashvars.get('postfix'), 'mp4')
46
47 formats = []
48 for video_url_key in ['video_url', 'video_alt_url']:
49 video_url = flashvars.get(video_url_key)
50 if not video_url:
51 continue
52 video_text = flashvars.get('%s_text' % video_url_key)
53 fmt = {
54 'url': video_url,
55 'ext': ext,
56 'format_id': video_text,
57 }
58 m = re.search(r'^(?P<height>\d+)[pP]', video_text)
59 if m:
60 fmt['height'] = int(m.group('height'))
61 formats.append(fmt)
62 self._sort_formats(formats)
63
64 categories = self._html_search_meta(
65 'keywords', webpage, 'categories', default='').split(',')
66
67 return {
68 'id': video_id,
69 'display_id': display_id,
70 'title': title,
71 'thumbnail': thumbnail,
72 'categories': categories,
73 'age_limit': 18,
74 'formats': formats,
75 }