]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/slutload.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / slutload.py
1 from .common import InfoExtractor
2
3
4 class SlutloadIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:\w+\.)?slutload\.com/(?:video/[^/]+|embed_player|watch)/(?P<id>[^/]+)'
6 _TESTS = [{
7 'url': 'http://www.slutload.com/video/virginie-baisee-en-cam/TD73btpBqSxc/',
8 'md5': '868309628ba00fd488cf516a113fd717',
9 'info_dict': {
10 'id': 'TD73btpBqSxc',
11 'ext': 'mp4',
12 'title': 'virginie baisee en cam',
13 'age_limit': 18,
14 'thumbnail': r're:https?://.*?\.jpg',
15 },
16 }, {
17 # mobile site
18 'url': 'http://mobile.slutload.com/video/masturbation-solo/fviFLmc6kzJ/',
19 'only_matching': True,
20 }, {
21 'url': 'http://www.slutload.com/embed_player/TD73btpBqSxc/',
22 'only_matching': True,
23 }, {
24 'url': 'http://www.slutload.com/watch/TD73btpBqSxc/Virginie-Baisee-En-Cam.html',
25 'only_matching': True,
26 }]
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30
31 embed_page = self._download_webpage(
32 f'http://www.slutload.com/embed_player/{video_id}', video_id,
33 'Downloading embed page', fatal=False)
34
35 if embed_page:
36 def extract(what):
37 return self._html_search_regex(
38 rf'data-video-{what}=(["\'])(?P<url>(?:(?!\1).)+)\1',
39 embed_page, f'video {what}', default=None, group='url')
40
41 video_url = extract('url')
42 if video_url:
43 title = self._html_search_regex(
44 r'<title>([^<]+)', embed_page, 'title', default=video_id)
45 return {
46 'id': video_id,
47 'url': video_url,
48 'title': title,
49 'thumbnail': extract('preview'),
50 'age_limit': 18,
51 }
52
53 webpage = self._download_webpage(
54 f'http://www.slutload.com/video/_/{video_id}/', video_id)
55 title = self._html_search_regex(
56 r'<h1><strong>([^<]+)</strong>', webpage, 'title').strip()
57 info = self._parse_html5_media_entries(url, webpage, video_id)[0]
58 info.update({
59 'id': video_id,
60 'title': title,
61 'age_limit': 18,
62 })
63 return info