1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_urllib_parse_unquote
16 class XVideosIE(InfoExtractor
):
20 (?:www\.)?xvideos\.com/video|
21 flashservice\.xvideos\.com/embedframe/|
22 static-hw\.xvideos\.com/swf/xv-player\.swf\?.*?\bid_video=
27 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
28 'md5': '14cea69fcb84db54293b1e971466c2e1',
32 'title': 'Biker Takes his Girl',
37 'url': 'https://flashservice.xvideos.com/embedframe/4588838',
38 'only_matching': True,
40 'url': 'http://static-hw.xvideos.com/swf/xv-player.swf?id_video=4588838',
41 'only_matching': True,
44 def _real_extract(self
, url
):
45 video_id
= self
._match
_id
(url
)
47 webpage
= self
._download
_webpage
(
48 'http://www.xvideos.com/video%s/' % video_id
, video_id
)
50 mobj
= re
.search(r
'<h1 class="inlineError">(.+?)</h1>', webpage
)
52 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, clean_html(mobj
.group(1))), expected
=True)
54 title
= self
._html
_search
_regex
(
55 (r
'<title>(?P<title>.+?)\s+-\s+XVID',
56 r
'setVideoTitle\s*\(\s*(["\'])(?P
<title
>(?
:(?
!\
1).)+)\
1'),
57 webpage, 'title
', default=None,
58 group='title
') or self._og_search_title(webpage)
60 thumbnail = self._search_regex(
61 r'url_bigthumb
=(.+?
)&
', webpage, 'thumbnail
', fatal=False)
62 duration = int_or_none(self._og_search_property(
63 'duration
', webpage, default=None)) or parse_duration(
65 r'<span
[^
>]+class=["\']duration["\'][^
>]*>.*?
(\d
[^
<]+)',
66 webpage, 'duration
', fatal=False))
70 video_url = compat_urllib_parse_unquote(self._search_regex(
71 r'flv_url
=(.+?
)&', webpage, 'video URL
', default=''))
78 for kind, _, format_url in re.findall(
79 r'setVideo([^
(]+)\
((["\'])(http.+?)\2\)', webpage):
80 format_id = kind.lower()
81 if format_id == 'hls':
82 formats.extend(self._extract_m3u8_formats(
83 format_url, video_id, 'mp4',
84 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
85 elif format_id in ('urllow', 'urlhigh'):
88 'format_id': '%s-%s' % (determine_ext(format_url, 'mp4'), format_id[3:]),
89 'quality': -2 if format_id.endswith('low') else None,
92 self._sort_formats(formats)
99 'thumbnail': thumbnail,