]>
Commit | Line | Data |
---|---|---|
faca6745 | 1 | import re |
2 | ||
58493923 | 3 | from ..utils import parse_duration, unescapeHTML |
faca6745 | 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, | |
58493923 | 19 | 'age_limit': 18, |
20 | 'tags': 'count:14' | |
faca6745 | 21 | } |
22 | }, | |
23 | { | |
24 | 'url': 'https://rule34video.com/videos/3065296/lara-in-trouble-ep-7-wildeerstudio/', | |
25 | 'md5': '6bb5169f9f6b38cd70882bf2e64f6b86', | |
26 | 'info_dict': { | |
27 | 'id': '3065296', | |
28 | 'ext': 'mp4', | |
29 | 'title': 'Lara in Trouble Ep. 7 [WildeerStudio]', | |
30 | 'thumbnail': 'https://rule34video.com/contents/videos_screenshots/3065000/3065296/preview.jpg', | |
31 | 'duration': 938.0, | |
58493923 | 32 | 'age_limit': 18, |
33 | 'tags': 'count:50' | |
faca6745 | 34 | } |
35 | }, | |
36 | ] | |
37 | ||
38 | def _real_extract(self, url): | |
39 | video_id = self._match_id(url) | |
40 | webpage = self._download_webpage(url, video_id) | |
41 | ||
42 | formats = [] | |
43 | ||
44 | for mobj in re.finditer(r'<a[^>]+href="(?P<video_url>[^"]+download=true[^"]+)".*>(?P<ext>[^\s]+) (?P<quality>[^<]+)p</a>', webpage): | |
45 | url, ext, quality = mobj.groups() | |
46 | formats.append({ | |
47 | 'url': url, | |
48 | 'ext': ext.lower(), | |
49 | 'quality': quality, | |
50 | }) | |
51 | ||
04f3fd2c | 52 | title = self._html_extract_title(webpage) |
faca6745 | 53 | thumbnail = self._html_search_regex(r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None) |
54 | duration = self._html_search_regex(r'"icon-clock"></i>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None) | |
55 | ||
faca6745 | 56 | return { |
57 | 'id': video_id, | |
58 | 'formats': formats, | |
59 | 'title': title, | |
60 | 'thumbnail': thumbnail, | |
61 | 'duration': parse_duration(duration), | |
58493923 | 62 | 'age_limit': 18, |
63 | 'tags': list(map(unescapeHTML, re.findall( | |
64 | r'<a class="tag_item"[^>]+\bhref="https://rule34video\.com/tags/\d+/"[^>]*>(?P<tag>[^>]*)</a>', webpage))), | |
faca6745 | 65 | } |