1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_urllib_parse_unquote
16 class XVideosIE(InfoExtractor):
20 (?:[^/]+\.)?xvideos2?\.com/video|
21 (?:www\.)?xvideos\.es/video|
22 flashservice\.xvideos\.com/embedframe/|
23 static-hw\.xvideos\.com/swf/xv-player\.swf\?.*?\bid_video=
28 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
29 'md5': '14cea69fcb84db54293b1e971466c2e1',
33 'title': 'Biker Takes his Girl',
38 'url': 'https://flashservice.xvideos.com/embedframe/4588838',
39 'only_matching': True,
41 'url': 'http://static-hw.xvideos.com/swf/xv-player.swf?id_video=4588838',
42 'only_matching': True,
44 'url': 'http://xvideos.com/video4588838/biker_takes_his_girl',
47 'url': 'https://xvideos.com/video4588838/biker_takes_his_girl',
50 'url': 'https://xvideos.es/video4588838/biker_takes_his_girl',
53 'url': 'https://www.xvideos.es/video4588838/biker_takes_his_girl',
56 'url': 'http://xvideos.es/video4588838/biker_takes_his_girl',
59 'url': 'http://www.xvideos.es/video4588838/biker_takes_his_girl',
62 'url': 'http://fr.xvideos.com/video4588838/biker_takes_his_girl',
65 'url': 'https://fr.xvideos.com/video4588838/biker_takes_his_girl',
68 'url': 'http://it.xvideos.com/video4588838/biker_takes_his_girl',
71 'url': 'https://it.xvideos.com/video4588838/biker_takes_his_girl',
74 'url': 'http://de.xvideos.com/video4588838/biker_takes_his_girl',
77 'url': 'https://de.xvideos.com/video4588838/biker_takes_his_girl',
81 def _real_extract(self, url):
82 video_id = self._match_id(url)
84 webpage = self._download_webpage(
85 'https://www.xvideos.com/video%s/' % video_id, video_id)
87 mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
89 raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
91 title = self._html_search_regex(
92 (r'<title>(?P<title>.+?)\s+-\s+XVID',
93 r'setVideoTitle\s*\(\s*(["\'])(?P<title>(?:(?!\1).)+)\1'),
94 webpage, 'title', default=None,
95 group='title') or self._og_search_title(webpage)
98 for preference, thumbnail in enumerate(('', '169')):
99 thumbnail_url = self._search_regex(
100 r'setThumbUrl%s\(\s*(["\'])(?P<thumbnail>(?:(?!\1).)+)\1' % thumbnail,
101 webpage, 'thumbnail', default=None, group='thumbnail')
104 'url': thumbnail_url,
105 'preference': preference,
108 duration = int_or_none(self._og_search_property(
109 'duration', webpage, default=None)) or parse_duration(
111 r'<span[^>]+class=["\']duration["\'][^>]*>.*?(\d[^<]+)',
112 webpage, 'duration', fatal=False))
116 video_url = compat_urllib_parse_unquote(self._search_regex(
117 r'flv_url=(.+?)&', webpage, 'video URL', default=''))
124 for kind, _, format_url in re.findall(
125 r'setVideo([^(]+)\((["\'])(http.+?)\2\)', webpage):
126 format_id = kind.lower()
127 if format_id == 'hls':
128 formats.extend(self._extract_m3u8_formats(
129 format_url, video_id, 'mp4',
130 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
131 elif format_id in ('urllow', 'urlhigh'):
134 'format_id': '%s-%s' % (determine_ext(format_url, 'mp4'), format_id[3:]),
135 'quality': -2 if format_id.endswith('low') else None,
138 self._sort_formats(formats)
144 'duration': duration,
145 'thumbnails': thumbnails,