1 from __future__ import unicode_literals
5 from .common import InfoExtractor
7 compat_urllib_parse_unquote,
17 class XVideosIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:www\.)?xvideos\.com/video(?P<id>[0-9]+)(?:.*)'
20 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
21 'md5': '4b46ae6ea5e6e9086e714d883313c0c9',
25 'title': 'Biker Takes his Girl',
30 _ANDROID_USER_AGENT = 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19'
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
34 webpage = self._download_webpage(url, video_id)
36 mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
38 raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
40 video_url = compat_urllib_parse_unquote(
41 self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
42 video_title = self._html_search_regex(
43 r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
44 video_thumbnail = self._search_regex(
45 r'url_bigthumb=(.+?)&', webpage, 'thumbnail', fatal=False)
51 android_req = compat_urllib_request.Request(url)
52 android_req.add_header('User-Agent', self._ANDROID_USER_AGENT)
53 android_webpage = self._download_webpage(android_req, video_id, fatal=False)
55 if android_webpage is not None:
56 player_params_str = self._search_regex(
57 'mobileReplacePlayerDivTwoQual\(([^)]+)\)',
58 android_webpage, 'player parameters', default='')
59 player_params = list(map(lambda s: s.strip(' \''), player_params_str.split(',')))
64 } for param in player_params if determine_ext(param) == 'mp4'])
66 self._sort_formats(formats)
73 'thumbnail': video_thumbnail,