]>
Commit | Line | Data |
---|---|---|
bbd5f2de | 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', | |
437f68d8 | 12 | 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b', |
c58e7406 | 13 | 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403', |
bbd5f2de | 14 | 'categories': list, # NSFW |
ec85ded8 | 15 | 'thumbnail': r're:https?://.*\.jpg$', |
bbd5f2de | 16 | 'age_limit': 18, |
17 | } | |
18 | } | |
19 | ||
20 | def _real_extract(self, url): | |
3fa5bb38 | 21 | video_id = self._match_id(url) |
bbd5f2de | 22 | webpage = self._download_webpage(url, video_id) |
23 | ||
e7bd1737 S |
24 | jwvideo = self._parse_json( |
25 | self._search_regex(r'\.setup\(\s*({.+?})\s*\);', webpage, 'jwvideo'), | |
26 | video_id) | |
27 | ||
28 | sources = jwvideo['sources'] | |
29 | ||
bbd5f2de | 30 | formats = [{ |
e7bd1737 S |
31 | 'url': source['file'].replace('\\', ''), |
32 | 'format_id': source.get('label'), | |
f5521ea2 S |
33 | 'height': int(self._search_regex( |
34 | r'^(\d+)[pP]', source.get('label', ''), 'height', | |
35 | default=None)), | |
e7bd1737 | 36 | } for source in sources if source.get('file')] |
bbd5f2de | 37 | |
38 | title = self._html_search_regex( | |
3fa5bb38 | 39 | r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title') |
bbd5f2de | 40 | |
3fa5bb38 PH |
41 | description = self._html_search_meta( |
42 | 'description', webpage, 'description') | |
bbd5f2de | 43 | |
e7bd1737 | 44 | thumbnail = jwvideo.get('image') |
bbd5f2de | 45 | |
3fa5bb38 PH |
46 | categories_str = self._html_search_meta( |
47 | 'keywords', webpage, 'categories') | |
bbd5f2de | 48 | categories = ( |
49 | None if categories_str is None | |
50 | else categories_str.split(',')) | |
51 | ||
52 | return { | |
53 | 'id': video_id, | |
54 | 'title': title, | |
55 | 'description': description, | |
56 | 'thumbnail': thumbnail, | |
57 | 'categories': categories, | |
58 | 'formats': formats, | |
59 | 'age_limit': 18, | |
60 | } |