]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/sexu.py
[extractor/iq] Increase phantomjs timeout
[yt-dlp.git] / yt_dlp / extractor / sexu.py
1 from .common import InfoExtractor
2
3
4 class SexuIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:www\.)?sexu\.com/(?P<id>\d+)'
6 _TEST = {
7 'url': 'http://sexu.com/961791/',
8 'md5': 'ff615aca9691053c94f8f10d96cd7884',
9 'info_dict': {
10 'id': '961791',
11 'ext': 'mp4',
12 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b',
13 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403',
14 'categories': list, # NSFW
15 'thumbnail': r're:https?://.*\.jpg$',
16 'age_limit': 18,
17 }
18 }
19
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
23
24 jwvideo = self._parse_json(
25 self._search_regex(r'\.setup\(\s*({.+?})\s*\);', webpage, 'jwvideo'),
26 video_id)
27
28 sources = jwvideo['sources']
29
30 formats = [{
31 'url': source['file'].replace('\\', ''),
32 'format_id': source.get('label'),
33 'height': int(self._search_regex(
34 r'^(\d+)[pP]', source.get('label', ''), 'height',
35 default=None)),
36 } for source in sources if source.get('file')]
37 self._sort_formats(formats)
38
39 title = self._html_search_regex(
40 r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title')
41
42 description = self._html_search_meta(
43 'description', webpage, 'description')
44
45 thumbnail = jwvideo.get('image')
46
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(','))
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 }