]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xvideos.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / xvideos.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..compat import (
7 compat_urllib_parse,
8 )
9 from ..utils import (
10 clean_html,
11 ExtractorError,
12 )
13
14
15 class XVideosIE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?xvideos\.com/video(?P<id>[0-9]+)(?:.*)'
17 _TEST = {
18 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
19 'md5': '4b46ae6ea5e6e9086e714d883313c0c9',
20 'info_dict': {
21 'id': '4588838',
22 'ext': 'flv',
23 'title': 'Biker Takes his Girl',
24 'age_limit': 18,
25 }
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
31
32 mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
33 if mobj:
34 raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
35
36 video_url = compat_urllib_parse.unquote(
37 self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
38 video_title = self._html_search_regex(
39 r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
40 video_thumbnail = self._search_regex(
41 r'url_bigthumb=(.+?)&amp', webpage, 'thumbnail', fatal=False)
42
43 return {
44 'id': video_id,
45 'url': video_url,
46 'title': video_title,
47 'ext': 'flv',
48 'thumbnail': video_thumbnail,
49 'age_limit': 18,
50 }