]>
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): | |
15 | _VALID_URL = r'https?://(?:www\.)?sunporno\.com/videos/(?P<id>\d+)' | |
16 | _TEST = { | |
17 | 'url': 'http://www.sunporno.com/videos/807778/', | |
18 | 'md5': '6457d3c165fd6de062b99ef6c2ff4c86', | |
19 | 'info_dict': { | |
20 | 'id': '807778', | |
21 | 'ext': 'flv', | |
22 | 'title': 'md5:0a400058e8105d39e35c35e7c5184164', | |
23 | 'description': 'md5:a31241990e1bd3a64e72ae99afb325fb', | |
ae7246e7 | 24 | 'thumbnail': 're:^https?://.*\.jpg$', |
7eb21356 | 25 | 'duration': 302, |
9b330db7 | 26 | 'age_limit': 18, |
7eb21356 | 27 | } |
28 | } | |
29 | ||
30 | def _real_extract(self, url): | |
31424c12 | 31 | video_id = self._match_id(url) |
7eb21356 | 32 | |
33 | webpage = self._download_webpage(url, video_id) | |
34 | ||
31424c12 S |
35 | title = self._html_search_regex( |
36 | r'<title>([^<]+)</title>', webpage, 'title') | |
37 | description = self._html_search_meta( | |
38 | 'description', webpage, 'description') | |
7eb21356 | 39 | thumbnail = self._html_search_regex( |
ae7246e7 | 40 | r'poster="([^"]+)"', webpage, 'thumbnail', fatal=False) |
7eb21356 | 41 | |
42 | duration = parse_duration(self._search_regex( | |
31424c12 S |
43 | r'itemprop="duration">\s*(\d+:\d+)\s*<', |
44 | webpage, 'duration', fatal=False)) | |
7eb21356 | 45 | |
46 | view_count = int_or_none(self._html_search_regex( | |
31424c12 S |
47 | r'class="views">\s*(\d+)\s*<', |
48 | webpage, 'view count', fatal=False)) | |
ae7246e7 | 49 | comment_count = int_or_none(self._html_search_regex( |
31424c12 S |
50 | r'(\d+)</b> Comments?', |
51 | webpage, 'comment count', fatal=False)) | |
ae7246e7 S |
52 | |
53 | formats = [] | |
54 | quality = qualities(['mp4', 'flv']) | |
55 | for video_url in re.findall(r'<source src="([^"]+)"', webpage): | |
56 | video_ext = determine_ext(video_url) | |
57 | formats.append({ | |
58 | 'url': video_url, | |
59 | 'format_id': video_ext, | |
60 | 'quality': quality(video_ext), | |
61 | }) | |
62 | self._sort_formats(formats) | |
7eb21356 | 63 | |
64 | return { | |
65 | 'id': video_id, | |
7eb21356 | 66 | 'title': title, |
67 | 'description': description, | |
68 | 'thumbnail': thumbnail, | |
69 | 'duration': duration, | |
70 | 'view_count': view_count, | |
ae7246e7 S |
71 | 'comment_count': comment_count, |
72 | 'formats': formats, | |
9b330db7 | 73 | 'age_limit': 18, |
7eb21356 | 74 | } |