]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xnxx.py
68acb84098fc0c2b9349ad6fd540d857fbcb5075
[youtubedl] / youtube_dl / extractor / xnxx.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 compat_urllib_parse,
6
7 ExtractorError,
8 )
9
10
11 class XNXXIE(InfoExtractor):
12 _VALID_URL = r'^(?:https?://)?video\.xnxx\.com/video([0-9]+)/(.*)'
13 VIDEO_URL_RE = r'flv_url=(.*?)&'
14 VIDEO_TITLE_RE = r'<title>(.*?)\s+-\s+XNXX.COM'
15 VIDEO_THUMB_RE = r'url_bigthumb=(.*?)&amp;'
16
17 def _real_extract(self, url):
18 mobj = re.match(self._VALID_URL, url)
19 if mobj is None:
20 raise ExtractorError(u'Invalid URL: %s' % url)
21 video_id = mobj.group(1)
22
23 # Get webpage content
24 webpage = self._download_webpage(url, video_id)
25
26 video_url = self._search_regex(self.VIDEO_URL_RE,
27 webpage, u'video URL')
28 video_url = compat_urllib_parse.unquote(video_url)
29
30 video_title = self._html_search_regex(self.VIDEO_TITLE_RE,
31 webpage, u'title')
32
33 video_thumbnail = self._search_regex(self.VIDEO_THUMB_RE,
34 webpage, u'thumbnail', fatal=False)
35
36 return [{
37 'id': video_id,
38 'url': video_url,
39 'uploader': None,
40 'upload_date': None,
41 'title': video_title,
42 'ext': 'flv',
43 'thumbnail': video_thumbnail,
44 'description': None,
45 }]