]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xvideos.py
85e99e1b02b8ab7e7647d6c91dbad08f4827d5f3
[youtubedl] / youtube_dl / extractor / xvideos.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 compat_urllib_parse,
8 )
9
10
11 class XVideosIE(InfoExtractor):
12 _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
13 _TEST = {
14 'url': 'http://www.xvideos.com/video939581/funny_porns_by_s_-1',
15 'file': '939581.flv',
16 'md5': '1d0c835822f0a71a7bf011855db929d0',
17 'info_dict': {
18 "title": "Funny Porns By >>>>S<<<<<< -1",
19 "age_limit": 18,
20 }
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25 video_id = mobj.group(1)
26
27 webpage = self._download_webpage(url, video_id)
28
29 self.report_extraction(video_id)
30
31 # Extract video URL
32 video_url = compat_urllib_parse.unquote(
33 self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
34
35 # Extract title
36 video_title = self._html_search_regex(
37 r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
38
39 # Extract video thumbnail
40 video_thumbnail = self._search_regex(
41 r'url_bigthumb=(.+?)&amp', webpage, 'thumbnail', fatal=False)
42
43 return {
44 'id': video_id,
45 'url': video_url,
46 'uploader': None,
47 'upload_date': None,
48 'title': video_title,
49 'ext': 'flv',
50 'thumbnail': video_thumbnail,
51 'description': None,
52 'age_limit': 18,
53 }