]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/xvideos.py
[naver] Modernize
[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
6from ..utils import (
7 compat_urllib_parse,
8)
9
10
11class XVideosIE(InfoExtractor):
12 _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
6f5ac90c 13 _TEST = {
d7975ea2
PH
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,
6f5ac90c
PH
20 }
21 }
cbf46c73
PH
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
d7975ea2
PH
32 video_url = compat_urllib_parse.unquote(
33 self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
cbf46c73
PH
34
35 # Extract title
d7975ea2
PH
36 video_title = self._html_search_regex(
37 r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
cbf46c73
PH
38
39 # Extract video thumbnail
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,
46 'uploader': None,
47 'upload_date': None,
48 'title': video_title,
49 'ext': 'flv',
50 'thumbnail': video_thumbnail,
51 'description': None,
8ed6b344 52 'age_limit': 18,
cbf46c73 53 }