]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/sexu.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / sexu.py
CommitLineData
bbd5f2de 1from .common import InfoExtractor
2
3
4class SexuIE(InfoExtractor):
df773c3d 5 _WORKING = False
bbd5f2de 6 _VALID_URL = r'https?://(?:www\.)?sexu\.com/(?P<id>\d+)'
7 _TEST = {
8 'url': 'http://sexu.com/961791/',
9 'md5': 'ff615aca9691053c94f8f10d96cd7884',
10 'info_dict': {
11 'id': '961791',
12 'ext': 'mp4',
437f68d8 13 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b',
c58e7406 14 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403',
bbd5f2de 15 'categories': list, # NSFW
ec85ded8 16 'thumbnail': r're:https?://.*\.jpg$',
bbd5f2de 17 'age_limit': 18,
add96eb9 18 },
bbd5f2de 19 }
20
21 def _real_extract(self, url):
3fa5bb38 22 video_id = self._match_id(url)
bbd5f2de 23 webpage = self._download_webpage(url, video_id)
24
e7bd1737
S
25 jwvideo = self._parse_json(
26 self._search_regex(r'\.setup\(\s*({.+?})\s*\);', webpage, 'jwvideo'),
27 video_id)
28
29 sources = jwvideo['sources']
30
bbd5f2de 31 formats = [{
e7bd1737
S
32 'url': source['file'].replace('\\', ''),
33 'format_id': source.get('label'),
f5521ea2
S
34 'height': int(self._search_regex(
35 r'^(\d+)[pP]', source.get('label', ''), 'height',
36 default=None)),
e7bd1737 37 } for source in sources if source.get('file')]
bbd5f2de 38
39 title = self._html_search_regex(
3fa5bb38 40 r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title')
bbd5f2de 41
3fa5bb38
PH
42 description = self._html_search_meta(
43 'description', webpage, 'description')
bbd5f2de 44
e7bd1737 45 thumbnail = jwvideo.get('image')
bbd5f2de 46
3fa5bb38
PH
47 categories_str = self._html_search_meta(
48 'keywords', webpage, 'categories')
bbd5f2de 49 categories = (
50 None if categories_str is None
51 else categories_str.split(','))
52
53 return {
54 'id': video_id,
55 'title': title,
56 'description': description,
57 'thumbnail': thumbnail,
58 'categories': categories,
59 'formats': formats,
60 'age_limit': 18,
61 }