]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xvideos.py
Update changelog.
[youtubedl] / youtube_dl / extractor / xvideos.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 compat_urllib_parse,
6 )
7
8
9 class XVideosIE(InfoExtractor):
10 _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
11
12 def _real_extract(self, url):
13 mobj = re.match(self._VALID_URL, url)
14 video_id = mobj.group(1)
15
16 webpage = self._download_webpage(url, video_id)
17
18 self.report_extraction(video_id)
19
20 # Extract video URL
21 video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
22 webpage, u'video URL'))
23
24 # Extract title
25 video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
26 webpage, u'title')
27
28 # Extract video thumbnail
29 video_thumbnail = self._search_regex(r'http://(?:img.*?\.)xvideos.com/videos/thumbs/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/([a-fA-F0-9.]+jpg)',
30 webpage, u'thumbnail', fatal=False)
31
32 info = {
33 'id': video_id,
34 'url': video_url,
35 'uploader': None,
36 'upload_date': None,
37 'title': video_title,
38 'ext': 'flv',
39 'thumbnail': video_thumbnail,
40 'description': None,
41 }
42
43 return [info]