]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xnxx.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / xnxx.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8 compat_urllib_parse,
9 )
10
11
12 class XNXXIE(InfoExtractor):
13 _VALID_URL = r'^https?://(?:video|www)\.xnxx\.com/video(?P<id>[0-9]+)/(.*)'
14 _TEST = {
15 'url': 'http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_',
16 'md5': '0831677e2b4761795f68d417e0b7b445',
17 'info_dict': {
18 'id': '1135332',
19 'ext': 'flv',
20 'title': 'lida » Naked Funny Actress (5)',
21 'age_limit': 18,
22 }
23 }
24
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
27 video_id = mobj.group('id')
28
29 # Get webpage content
30 webpage = self._download_webpage(url, video_id)
31
32 video_url = self._search_regex(r'flv_url=(.*?)&amp;',
33 webpage, 'video URL')
34 video_url = compat_urllib_parse.unquote(video_url)
35
36 video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XNXX.COM',
37 webpage, 'title')
38
39 video_thumbnail = self._search_regex(r'url_bigthumb=(.*?)&amp;',
40 webpage, 'thumbnail', fatal=False)
41
42 return {
43 'id': video_id,
44 'url': video_url,
45 'title': video_title,
46 'ext': 'flv',
47 'thumbnail': video_thumbnail,
48 'age_limit': 18,
49 }