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