]>
Commit | Line | Data |
---|---|---|
676e3ecf | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
7b53af7f S |
6 | from ..utils import ( |
7 | parse_duration, | |
8 | str_to_int, | |
9 | ) | |
10 | ||
676e3ecf | 11 | |
12 | class VpornIE(InfoExtractor): | |
7b53af7f | 13 | _VALID_URL = r'https?://(?:www\.)?vporn\.com/[^/]+/(?P<display_id>[^/]+)/(?P<id>\d+)' |
676e3ecf | 14 | _TEST = { |
15 | 'url': 'http://www.vporn.com/masturbation/violet-on-her-th-birthday/497944/', | |
16 | 'md5': 'facf37c1b86546fa0208058546842c55', | |
17 | 'info_dict': { | |
18 | 'id': '497944', | |
7b53af7f | 19 | 'display_id': 'violet-on-her-th-birthday', |
676e3ecf | 20 | 'ext': 'mp4', |
7b53af7f | 21 | 'title': 'Violet on her 19th birthday', |
676e3ecf | 22 | 'description': 'Violet dances in front of the camera which is sure to get you horny.', |
676e3ecf | 23 | 'thumbnail': 're:^https?://.*\.jpg$', |
7b53af7f S |
24 | 'uploader': 'kileyGrope', |
25 | 'categories': ['Masturbation', 'Teen'], | |
26 | 'duration': 393, | |
27 | 'age_limit': 18, | |
676e3ecf | 28 | } |
29 | } | |
30 | ||
31 | def _real_extract(self, url): | |
32 | mobj = re.match(self._VALID_URL, url) | |
33 | video_id = mobj.group('id') | |
7b53af7f S |
34 | display_id = mobj.group('display_id') |
35 | ||
36 | webpage = self._download_webpage(url, display_id) | |
37 | ||
38 | title = self._html_search_regex( | |
39 | r'videoname\s*=\s*\'([^\']+)\'', webpage, 'title').strip() | |
40 | description = self._html_search_regex( | |
41 | r'<div class="description_txt">(.*?)</div>', webpage, 'description', fatal=False) | |
42 | thumbnail = self._html_search_regex( | |
43 | r'flashvars\.imageUrl\s*=\s*"([^"]+)"', webpage, 'description', fatal=False, default=None) | |
44 | if thumbnail: | |
45 | thumbnail = 'http://www.vporn.com' + thumbnail | |
46 | ||
47 | uploader = self._html_search_regex( | |
48 | r'(?s)UPLOADED BY.*?<a href="/user/[^"]+">([^<]+)</a>', | |
49 | webpage, 'uploader', fatal=False) | |
676e3ecf | 50 | |
7b53af7f | 51 | categories = re.findall(r'<a href="/cat/[^"]+">([^<]+)</a>', webpage) |
676e3ecf | 52 | |
7b53af7f S |
53 | duration = parse_duration(self._search_regex( |
54 | r'duration (\d+ min \d+ sec)', webpage, 'duration', fatal=False)) | |
676e3ecf | 55 | |
7b53af7f S |
56 | view_count = str_to_int(self._html_search_regex( |
57 | r'<span>([\d,\.]+) VIEWS</span>', webpage, 'view count', fatal=False)) | |
58 | like_count = str_to_int(self._html_search_regex( | |
59 | r'<span id="like" class="n">([\d,\.]+)</span>', webpage, 'like count', fatal=False)) | |
60 | dislike_count = str_to_int(self._html_search_regex( | |
61 | r'<span id="dislike" class="n">([\d,\.]+)</span>', webpage, 'dislike count', fatal=False)) | |
62 | comment_count = str_to_int(self._html_search_regex( | |
63 | r'<h4>Comments \(<b>([\d,\.]+)</b>\)</h4>', webpage, 'comment count', fatal=False)) | |
64 | ||
65 | formats = [] | |
66 | ||
67 | for video in re.findall(r'flashvars\.videoUrl([^=]+?)\s*=\s*"([^"]+)"', webpage): | |
68 | video_url = video[1] | |
69 | fmt = { | |
70 | 'url': video_url, | |
71 | 'format_id': video[0], | |
72 | } | |
73 | m = re.search(r'_(?P<width>\d+)x(?P<height>\d+)_(?P<vbr>\d+)k\.mp4$', video_url) | |
74 | if m: | |
75 | fmt.update({ | |
76 | 'width': int(m.group('width')), | |
77 | 'height': int(m.group('height')), | |
78 | 'vbr': int(m.group('vbr')), | |
79 | }) | |
80 | formats.append(fmt) | |
81 | ||
82 | self._sort_formats(formats) | |
12c82cf9 | 83 | |
676e3ecf | 84 | return { |
85 | 'id': video_id, | |
7b53af7f | 86 | 'display_id': display_id, |
676e3ecf | 87 | 'title': title, |
88 | 'description': description, | |
7b53af7f S |
89 | 'thumbnail': thumbnail, |
90 | 'uploader': uploader, | |
91 | 'categories': categories, | |
92 | 'duration': duration, | |
93 | 'view_count': view_count, | |
94 | 'like_count': like_count, | |
95 | 'dislike_count': dislike_count, | |
96 | 'comment_count': comment_count, | |
97 | 'age_limit': 18, | |
98 | 'formats': formats, | |
676e3ecf | 99 | } |