]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/xvideos.py
[viki] Pass session token around (#6005)
[yt-dlp.git] / youtube_dl / extractor / xvideos.py
CommitLineData
d7975ea2
PH
1from __future__ import unicode_literals
2
cbf46c73
PH
3import re
4
5from .common import InfoExtractor
1cc79574 6from ..compat import (
cbf46c73 7 compat_urllib_parse,
1cc79574
PH
8)
9from ..utils import (
3217377b 10 clean_html,
1cc79574 11 ExtractorError,
cbf46c73
PH
12)
13
14
15class XVideosIE(InfoExtractor):
1cc79574 16 _VALID_URL = r'https?://(?:www\.)?xvideos\.com/video(?P<id>[0-9]+)(?:.*)'
6f5ac90c 17 _TEST = {
a6ffb92f
S
18 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
19 'md5': '4b46ae6ea5e6e9086e714d883313c0c9',
d7975ea2 20 'info_dict': {
a6ffb92f
S
21 'id': '4588838',
22 'ext': 'flv',
23 'title': 'Biker Takes his Girl',
24 'age_limit': 18,
6f5ac90c
PH
25 }
26 }
cbf46c73
PH
27
28 def _real_extract(self, url):
1cc79574 29 video_id = self._match_id(url)
cbf46c73
PH
30 webpage = self._download_webpage(url, video_id)
31
3217377b
S
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
d7975ea2
PH
36 video_url = compat_urllib_parse.unquote(
37 self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
d7975ea2
PH
38 video_title = self._html_search_regex(
39 r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
d7975ea2
PH
40 video_thumbnail = self._search_regex(
41 r'url_bigthumb=(.+?)&amp', webpage, 'thumbnail', fatal=False)
cbf46c73 42
d7975ea2 43 return {
cbf46c73
PH
44 'id': video_id,
45 'url': video_url,
cbf46c73
PH
46 'title': video_title,
47 'ext': 'flv',
48 'thumbnail': video_thumbnail,
8ed6b344 49 'age_limit': 18,
cbf46c73 50 }