]>
Commit | Line | Data |
---|---|---|
bbd5f2de | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
6 | ||
7 | ||
8 | class SexuIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?sexu\.com/(?P<id>\d+)' | |
10 | _TEST = { | |
11 | 'url': 'http://sexu.com/961791/', | |
12 | 'md5': 'ff615aca9691053c94f8f10d96cd7884', | |
13 | 'info_dict': { | |
14 | 'id': '961791', | |
15 | 'ext': 'mp4', | |
437f68d8 | 16 | 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b', |
c58e7406 | 17 | 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403', |
bbd5f2de | 18 | 'categories': list, # NSFW |
19 | 'thumbnail': 're:https?://.*\.jpg$', | |
20 | 'age_limit': 18, | |
21 | } | |
22 | } | |
23 | ||
24 | def _real_extract(self, url): | |
3fa5bb38 | 25 | video_id = self._match_id(url) |
bbd5f2de | 26 | webpage = self._download_webpage(url, video_id) |
27 | ||
3fa5bb38 | 28 | quality_arr = self._search_regex( |
c58e7406 | 29 | r'"sources":\s*\[([^\]]+)\]', webpage, 'format string') |
bbd5f2de | 30 | formats = [{ |
31 | 'url': fmt[0].replace('\\', ''), | |
32 | 'format_id': fmt[1], | |
33 | 'height': int(fmt[1][:3]), | |
34 | } for fmt in re.findall(r'"file":"([^"]+)","label":"([^"]+)"', quality_arr)] | |
35 | self._sort_formats(formats) | |
36 | ||
37 | title = self._html_search_regex( | |
3fa5bb38 | 38 | r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title') |
bbd5f2de | 39 | |
3fa5bb38 PH |
40 | description = self._html_search_meta( |
41 | 'description', webpage, 'description') | |
bbd5f2de | 42 | |
43 | thumbnail = self._html_search_regex( | |
c58e7406 | 44 | r'"image":\s*"([^"]+)"', |
bbd5f2de | 45 | webpage, 'thumbnail', fatal=False) |
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 | } |