]>
Commit | Line | Data |
---|---|---|
676e3ecf | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
7b53af7f | 6 | from ..utils import ( |
a2252385 | 7 | ExtractorError, |
7b53af7f S |
8 | parse_duration, |
9 | str_to_int, | |
0ae9560e | 10 | urljoin, |
7b53af7f S |
11 | ) |
12 | ||
676e3ecf | 13 | |
14 | class VpornIE(InfoExtractor): | |
7b53af7f | 15 | _VALID_URL = r'https?://(?:www\.)?vporn\.com/[^/]+/(?P<display_id>[^/]+)/(?P<id>\d+)' |
59d284c3 S |
16 | _TESTS = [ |
17 | { | |
18 | 'url': 'http://www.vporn.com/masturbation/violet-on-her-th-birthday/497944/', | |
19 | 'md5': 'facf37c1b86546fa0208058546842c55', | |
20 | 'info_dict': { | |
21 | 'id': '497944', | |
22 | 'display_id': 'violet-on-her-th-birthday', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Violet on her 19th birthday', | |
25 | 'description': 'Violet dances in front of the camera which is sure to get you horny.', | |
ec85ded8 | 26 | 'thumbnail': r're:^https?://.*\.jpg$', |
59d284c3 S |
27 | 'uploader': 'kileyGrope', |
28 | 'categories': ['Masturbation', 'Teen'], | |
29 | 'duration': 393, | |
30 | 'age_limit': 18, | |
31 | 'view_count': int, | |
a2252385 YCH |
32 | }, |
33 | 'skip': 'video removed', | |
59d284c3 S |
34 | }, |
35 | { | |
36 | 'url': 'http://www.vporn.com/female/hana-shower/523564/', | |
37 | 'md5': 'ced35a4656198a1664cf2cda1575a25f', | |
38 | 'info_dict': { | |
39 | 'id': '523564', | |
40 | 'display_id': 'hana-shower', | |
41 | 'ext': 'mp4', | |
42 | 'title': 'Hana Shower', | |
43 | 'description': 'Hana showers at the bathroom.', | |
ec85ded8 | 44 | 'thumbnail': r're:^https?://.*\.jpg$', |
59d284c3 | 45 | 'uploader': 'Hmmmmm', |
a2252385 | 46 | 'categories': ['Big Boobs', 'Erotic', 'Teen', 'Female', '720p'], |
59d284c3 S |
47 | 'duration': 588, |
48 | 'age_limit': 18, | |
49 | 'view_count': int, | |
59d284c3 S |
50 | } |
51 | }, | |
52 | ] | |
676e3ecf | 53 | |
54 | def _real_extract(self, url): | |
55 | mobj = re.match(self._VALID_URL, url) | |
56 | video_id = mobj.group('id') | |
7b53af7f S |
57 | display_id = mobj.group('display_id') |
58 | ||
59 | webpage = self._download_webpage(url, display_id) | |
60 | ||
a2252385 YCH |
61 | errmsg = 'This video has been deleted due to Copyright Infringement or by the account owner!' |
62 | if errmsg in webpage: | |
63 | raise ExtractorError('%s said: %s' % (self.IE_NAME, errmsg), expected=True) | |
64 | ||
7b53af7f S |
65 | title = self._html_search_regex( |
66 | r'videoname\s*=\s*\'([^\']+)\'', webpage, 'title').strip() | |
67 | description = self._html_search_regex( | |
cd298882 S |
68 | r'class="(?:descr|description_txt)">(.*?)</div>', |
69 | webpage, 'description', fatal=False) | |
0ae9560e S |
70 | thumbnail = urljoin('http://www.vporn.com', self._html_search_regex( |
71 | r'flashvars\.imageUrl\s*=\s*"([^"]+)"', webpage, 'description', | |
72 | default=None)) | |
7b53af7f S |
73 | |
74 | uploader = self._html_search_regex( | |
7a03280d | 75 | r'(?s)Uploaded by:.*?<a href="/user/[^"]+"[^>]*>(.+?)</a>', |
7b53af7f | 76 | webpage, 'uploader', fatal=False) |
676e3ecf | 77 | |
7a03280d | 78 | categories = re.findall(r'<a href="/cat/[^"]+"[^>]*>([^<]+)</a>', webpage) |
676e3ecf | 79 | |
7b53af7f | 80 | duration = parse_duration(self._search_regex( |
cd298882 S |
81 | r'Runtime:\s*</span>\s*(\d+ min \d+ sec)', |
82 | webpage, 'duration', fatal=False)) | |
676e3ecf | 83 | |
cd298882 S |
84 | view_count = str_to_int(self._search_regex( |
85 | r'class="views">([\d,\.]+) [Vv]iews<', | |
86 | webpage, 'view count', fatal=False)) | |
7b53af7f | 87 | comment_count = str_to_int(self._html_search_regex( |
cd298882 S |
88 | r"'Comments \(([\d,\.]+)\)'", |
89 | webpage, 'comment count', default=None)) | |
7b53af7f S |
90 | |
91 | formats = [] | |
92 | ||
59d284c3 | 93 | for video in re.findall(r'flashvars\.videoUrl([^=]+?)\s*=\s*"(https?://[^"]+)"', webpage): |
7b53af7f S |
94 | video_url = video[1] |
95 | fmt = { | |
96 | 'url': video_url, | |
97 | 'format_id': video[0], | |
98 | } | |
99 | m = re.search(r'_(?P<width>\d+)x(?P<height>\d+)_(?P<vbr>\d+)k\.mp4$', video_url) | |
100 | if m: | |
101 | fmt.update({ | |
102 | 'width': int(m.group('width')), | |
103 | 'height': int(m.group('height')), | |
104 | 'vbr': int(m.group('vbr')), | |
105 | }) | |
106 | formats.append(fmt) | |
107 | ||
108 | self._sort_formats(formats) | |
12c82cf9 | 109 | |
676e3ecf | 110 | return { |
111 | 'id': video_id, | |
7b53af7f | 112 | 'display_id': display_id, |
676e3ecf | 113 | 'title': title, |
114 | 'description': description, | |
7b53af7f S |
115 | 'thumbnail': thumbnail, |
116 | 'uploader': uploader, | |
117 | 'categories': categories, | |
118 | 'duration': duration, | |
119 | 'view_count': view_count, | |
7b53af7f S |
120 | 'comment_count': comment_count, |
121 | 'age_limit': 18, | |
122 | 'formats': formats, | |
676e3ecf | 123 | } |