]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/xanimu.py
[cleanup] Misc
[yt-dlp.git] / yt_dlp / extractor / xanimu.py
CommitLineData
b382c1fc
J
1import re
2
b382c1fc 3from .common import InfoExtractor
edfc7725 4from ..utils import int_or_none
b382c1fc
J
5
6
7class XanimuIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:www\.)?xanimu\.com/(?P<id>[^/]+)/?'
9 _TESTS = [{
10 'url': 'https://xanimu.com/51944-the-princess-the-frog-hentai/',
11 'md5': '899b88091d753d92dad4cb63bbf357a7',
12 'info_dict': {
13 'id': '51944-the-princess-the-frog-hentai',
14 'ext': 'mp4',
15 'title': 'The Princess + The Frog Hentai',
16 'thumbnail': 'https://xanimu.com/storage/2020/09/the-princess-and-the-frog-hentai.jpg',
17 'description': r're:^Enjoy The Princess \+ The Frog Hentai',
18 'duration': 207.0,
19 'age_limit': 18
20 }
21 }, {
22 'url': 'https://xanimu.com/huge-expansion/',
23 'only_matching': True
24 }]
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
29
30 formats = []
31 for format in ['videoHigh', 'videoLow']:
32 format_url = self._search_json(r'var\s+%s\s*=' % re.escape(format), webpage, format,
33 video_id, default=None, contains_pattern=r'[\'"]([^\'"]+)[\'"]')
34 if format_url:
35 formats.append({
36 'url': format_url,
37 'format_id': format,
38 'quality': -2 if format.endswith('Low') else None,
39 })
40
41 return {
42 'id': video_id,
43 'formats': formats,
44 'title': self._search_regex(r'[\'"]headline[\'"]:\s*[\'"]([^"]+)[\'"]', webpage,
45 'title', default=None) or self._html_extract_title(webpage),
46 'thumbnail': self._html_search_meta('thumbnailUrl', webpage, default=None),
47 'description': self._html_search_meta('description', webpage, default=None),
48 'duration': int_or_none(self._search_regex(r'duration:\s*[\'"]([^\'"]+?)[\'"]',
49 webpage, 'duration', fatal=False)),
50 'age_limit': 18
51 }