]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/xnxx.py
release 2017.01.25
[yt-dlp.git] / youtube_dl / extractor / xnxx.py
CommitLineData
dcdb292f 1# coding: utf-8
bdebf51c
JMF
2from __future__ import unicode_literals
3
570fa151 4from .common import InfoExtractor
7dde5f6a 5from ..compat import compat_urllib_parse_unquote
570fa151
PH
6
7
8class XNXXIE(InfoExtractor):
adf1921d 9 _VALID_URL = r'https?://(?:video|www)\.xnxx\.com/video-?(?P<id>[0-9a-z]+)/'
73843ae8 10 _TESTS = [{
97674f04
S
11 'url': 'http://www.xnxx.com/video-55awb78/skyrim_test_video',
12 'md5': 'ef7ecee5af78f8b03dca2cf31341d3a0',
bdebf51c 13 'info_dict': {
97674f04 14 'id': '55awb78',
bdebf51c 15 'ext': 'flv',
97674f04 16 'title': 'Skyrim Test Video',
bdebf51c 17 'age_limit': 18,
73843ae8 18 },
19 }, {
20 'url': 'http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_',
21 'only_matching': True,
adf1921d
S
22 }, {
23 'url': 'http://www.xnxx.com/video-55awb78/',
24 'only_matching': True,
73843ae8 25 }]
570fa151
PH
26
27 def _real_extract(self, url):
1cc79574 28 video_id = self._match_id(url)
570fa151
PH
29 webpage = self._download_webpage(url, video_id)
30
bdebf51c 31 video_url = self._search_regex(r'flv_url=(.*?)&amp;',
9e1a5b84 32 webpage, 'video URL')
7dde5f6a 33 video_url = compat_urllib_parse_unquote(video_url)
570fa151 34
bdebf51c 35 video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XNXX.COM',
9e1a5b84 36 webpage, 'title')
570fa151 37
bdebf51c 38 video_thumbnail = self._search_regex(r'url_bigthumb=(.*?)&amp;',
9e1a5b84 39 webpage, 'thumbnail', fatal=False)
570fa151 40
bdebf51c 41 return {
570fa151
PH
42 'id': video_id,
43 'url': video_url,
570fa151
PH
44 'title': video_title,
45 'ext': 'flv',
46 'thumbnail': video_thumbnail,
8e590a11 47 'age_limit': 18,
bdebf51c 48 }