]>
Commit | Line | Data |
---|---|---|
d7975ea2 PH |
1 | from __future__ import unicode_literals |
2 | ||
cbf46c73 PH |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
6 | from ..utils import ( | |
7 | compat_urllib_parse, | |
3217377b S |
8 | ExtractorError, |
9 | clean_html, | |
cbf46c73 PH |
10 | ) |
11 | ||
12 | ||
13 | class XVideosIE(InfoExtractor): | |
14 | _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)' | |
6f5ac90c | 15 | _TEST = { |
a6ffb92f S |
16 | 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl', |
17 | 'md5': '4b46ae6ea5e6e9086e714d883313c0c9', | |
d7975ea2 | 18 | 'info_dict': { |
a6ffb92f S |
19 | 'id': '4588838', |
20 | 'ext': 'flv', | |
21 | 'title': 'Biker Takes his Girl', | |
22 | 'age_limit': 18, | |
6f5ac90c PH |
23 | } |
24 | } | |
cbf46c73 PH |
25 | |
26 | def _real_extract(self, url): | |
27 | mobj = re.match(self._VALID_URL, url) | |
28 | video_id = mobj.group(1) | |
29 | ||
30 | webpage = self._download_webpage(url, video_id) | |
31 | ||
32 | self.report_extraction(video_id) | |
33 | ||
3217377b S |
34 | mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage) |
35 | if mobj: | |
36 | raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True) | |
37 | ||
cbf46c73 | 38 | # Extract video URL |
d7975ea2 PH |
39 | video_url = compat_urllib_parse.unquote( |
40 | self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL')) | |
cbf46c73 PH |
41 | |
42 | # Extract title | |
d7975ea2 PH |
43 | video_title = self._html_search_regex( |
44 | r'<title>(.*?)\s+-\s+XVID', webpage, 'title') | |
cbf46c73 PH |
45 | |
46 | # Extract video thumbnail | |
d7975ea2 PH |
47 | video_thumbnail = self._search_regex( |
48 | r'url_bigthumb=(.+?)&', webpage, 'thumbnail', fatal=False) | |
cbf46c73 | 49 | |
d7975ea2 | 50 | return { |
cbf46c73 PH |
51 | 'id': video_id, |
52 | 'url': video_url, | |
53 | 'uploader': None, | |
54 | 'upload_date': None, | |
55 | 'title': video_title, | |
56 | 'ext': 'flv', | |
57 | 'thumbnail': video_thumbnail, | |
58 | 'description': None, | |
8ed6b344 | 59 | 'age_limit': 18, |
cbf46c73 | 60 | } |