[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / sexu.py
blob71b1076e6d577495d2d5a94f184a93eb521b7196
1 from .common import InfoExtractor
4 class SexuIE(InfoExtractor):
5 _WORKING = False
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',
13 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b',
14 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403',
15 'categories': list, # NSFW
16 'thumbnail': r're:https?://.*\.jpg$',
17 'age_limit': 18,
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23 webpage = self._download_webpage(url, video_id)
25 jwvideo = self._parse_json(
26 self._search_regex(r'\.setup\(\s*({.+?})\s*\);', webpage, 'jwvideo'),
27 video_id)
29 sources = jwvideo['sources']
31 formats = [{
32 'url': source['file'].replace('\\', ''),
33 'format_id': source.get('label'),
34 'height': int(self._search_regex(
35 r'^(\d+)[pP]', source.get('label', ''), 'height',
36 default=None)),
37 } for source in sources if source.get('file')]
39 title = self._html_search_regex(
40 r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title')
42 description = self._html_search_meta(
43 'description', webpage, 'description')
45 thumbnail = jwvideo.get('image')
47 categories_str = self._html_search_meta(
48 'keywords', webpage, 'categories')
49 categories = (
50 None if categories_str is None
51 else categories_str.split(','))
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,