]>
Commit | Line | Data |
---|---|---|
7eb21356 | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
6 | from ..utils import ( | |
7 | parse_duration, | |
8 | int_or_none, | |
ae7246e7 S |
9 | qualities, |
10 | determine_ext, | |
7eb21356 | 11 | ) |
12 | ||
13 | ||
14 | class SunPornoIE(InfoExtractor): | |
b69b2ff7 S |
15 | _VALID_URL = r'https?://(?:(?:www\.)?sunporno\.com/videos|embeds\.sunporno\.com/embed)/(?P<id>\d+)' |
16 | _TESTS = [{ | |
7eb21356 | 17 | 'url': 'http://www.sunporno.com/videos/807778/', |
794e5dcd | 18 | 'md5': '507887e29033502f29dba69affeebfc9', |
7eb21356 | 19 | 'info_dict': { |
20 | 'id': '807778', | |
794e5dcd | 21 | 'ext': 'mp4', |
7eb21356 | 22 | 'title': 'md5:0a400058e8105d39e35c35e7c5184164', |
23 | 'description': 'md5:a31241990e1bd3a64e72ae99afb325fb', | |
ec85ded8 | 24 | 'thumbnail': r're:^https?://.*\.jpg$', |
7eb21356 | 25 | 'duration': 302, |
9b330db7 | 26 | 'age_limit': 18, |
7eb21356 | 27 | } |
b69b2ff7 S |
28 | }, { |
29 | 'url': 'http://embeds.sunporno.com/embed/807778', | |
30 | 'only_matching': True, | |
31 | }] | |
7eb21356 | 32 | |
33 | def _real_extract(self, url): | |
31424c12 | 34 | video_id = self._match_id(url) |
7eb21356 | 35 | |
b69b2ff7 S |
36 | webpage = self._download_webpage( |
37 | 'http://www.sunporno.com/videos/%s' % video_id, video_id) | |
7eb21356 | 38 | |
31424c12 S |
39 | title = self._html_search_regex( |
40 | r'<title>([^<]+)</title>', webpage, 'title') | |
41 | description = self._html_search_meta( | |
42 | 'description', webpage, 'description') | |
7eb21356 | 43 | thumbnail = self._html_search_regex( |
ae7246e7 | 44 | r'poster="([^"]+)"', webpage, 'thumbnail', fatal=False) |
7eb21356 | 45 | |
46 | duration = parse_duration(self._search_regex( | |
794e5dcd S |
47 | (r'itemprop="duration"[^>]*>\s*(\d+:\d+)\s*<', |
48 | r'>Duration:\s*<span[^>]+>\s*(\d+:\d+)\s*<'), | |
31424c12 | 49 | webpage, 'duration', fatal=False)) |
7eb21356 | 50 | |
51 | view_count = int_or_none(self._html_search_regex( | |
05aa9c82 | 52 | r'class="views">(?:<noscript>)?\s*(\d+)\s*<', |
31424c12 | 53 | webpage, 'view count', fatal=False)) |
ae7246e7 | 54 | comment_count = int_or_none(self._html_search_regex( |
31424c12 | 55 | r'(\d+)</b> Comments?', |
794e5dcd | 56 | webpage, 'comment count', fatal=False, default=None)) |
ae7246e7 S |
57 | |
58 | formats = [] | |
59 | quality = qualities(['mp4', 'flv']) | |
68f2d273 | 60 | for video_url in re.findall(r'<(?:source|video) src="([^"]+)"', webpage): |
ae7246e7 S |
61 | video_ext = determine_ext(video_url) |
62 | formats.append({ | |
63 | 'url': video_url, | |
64 | 'format_id': video_ext, | |
65 | 'quality': quality(video_ext), | |
66 | }) | |
67 | self._sort_formats(formats) | |
7eb21356 | 68 | |
69 | return { | |
70 | 'id': video_id, | |
7eb21356 | 71 | 'title': title, |
72 | 'description': description, | |
73 | 'thumbnail': thumbnail, | |
74 | 'duration': duration, | |
75 | 'view_count': view_count, | |
ae7246e7 S |
76 | 'comment_count': comment_count, |
77 | 'formats': formats, | |
9b330db7 | 78 | 'age_limit': 18, |
7eb21356 | 79 | } |