]>
Commit | Line | Data |
---|---|---|
faca6745 | 1 | import re |
2 | ||
3 | from ..utils import parse_duration | |
4 | from .common import InfoExtractor | |
5 | ||
6 | ||
7 | class Rule34VideoIE(InfoExtractor): | |
8 | _VALID_URL = r'https?://(?:www\.)?rule34video\.com/videos/(?P<id>\d+)' | |
9 | _TESTS = [ | |
10 | { | |
11 | 'url': 'https://rule34video.com/videos/3065157/shot-it-mmd-hmv/', | |
12 | 'md5': 'ffccac2c23799dabbd192621ae4d04f3', | |
13 | 'info_dict': { | |
14 | 'id': '3065157', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'Shot It-(mmd hmv)', | |
17 | 'thumbnail': 'https://rule34video.com/contents/videos_screenshots/3065000/3065157/preview.jpg', | |
18 | 'duration': 347.0, | |
19 | 'age_limit': 18 | |
20 | } | |
21 | }, | |
22 | { | |
23 | 'url': 'https://rule34video.com/videos/3065296/lara-in-trouble-ep-7-wildeerstudio/', | |
24 | 'md5': '6bb5169f9f6b38cd70882bf2e64f6b86', | |
25 | 'info_dict': { | |
26 | 'id': '3065296', | |
27 | 'ext': 'mp4', | |
28 | 'title': 'Lara in Trouble Ep. 7 [WildeerStudio]', | |
29 | 'thumbnail': 'https://rule34video.com/contents/videos_screenshots/3065000/3065296/preview.jpg', | |
30 | 'duration': 938.0, | |
31 | 'age_limit': 18 | |
32 | } | |
33 | }, | |
34 | ] | |
35 | ||
36 | def _real_extract(self, url): | |
37 | video_id = self._match_id(url) | |
38 | webpage = self._download_webpage(url, video_id) | |
39 | ||
40 | formats = [] | |
41 | ||
42 | for mobj in re.finditer(r'<a[^>]+href="(?P<video_url>[^"]+download=true[^"]+)".*>(?P<ext>[^\s]+) (?P<quality>[^<]+)p</a>', webpage): | |
43 | url, ext, quality = mobj.groups() | |
44 | formats.append({ | |
45 | 'url': url, | |
46 | 'ext': ext.lower(), | |
47 | 'quality': quality, | |
48 | }) | |
49 | ||
04f3fd2c | 50 | title = self._html_extract_title(webpage) |
faca6745 | 51 | thumbnail = self._html_search_regex(r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None) |
52 | duration = self._html_search_regex(r'"icon-clock"></i>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None) | |
53 | ||
54 | self._sort_formats(formats) | |
55 | ||
56 | return { | |
57 | 'id': video_id, | |
58 | 'formats': formats, | |
59 | 'title': title, | |
60 | 'thumbnail': thumbnail, | |
61 | 'duration': parse_duration(duration), | |
62 | 'age_limit': 18 | |
63 | } |