Merge branch 'pr-bbcnews' of https://github.com/atomicdryad/youtube-dl into atomicdry...
[youtube-dl] / youtube_dl / extractor / xnxx.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urllib_parse_unquote
6
7
8 class XNXXIE(InfoExtractor):
9     _VALID_URL = r'^https?://(?:video|www)\.xnxx\.com/video(?P<id>[0-9]+)/(.*)'
10     _TEST = {
11         'url': 'http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_',
12         'md5': '0831677e2b4761795f68d417e0b7b445',
13         'info_dict': {
14             'id': '1135332',
15             'ext': 'flv',
16             'title': 'lida ยป Naked Funny Actress  (5)',
17             'age_limit': 18,
18         }
19     }
20
21     def _real_extract(self, url):
22         video_id = self._match_id(url)
23         webpage = self._download_webpage(url, video_id)
24
25         video_url = self._search_regex(r'flv_url=(.*?)&amp;',
26                                        webpage, 'video URL')
27         video_url = compat_urllib_parse_unquote(video_url)
28
29         video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XNXX.COM',
30                                               webpage, 'title')
31
32         video_thumbnail = self._search_regex(r'url_bigthumb=(.*?)&amp;',
33                                              webpage, 'thumbnail', fatal=False)
34
35         return {
36             'id': video_id,
37             'url': video_url,
38             'title': video_title,
39             'ext': 'flv',
40             'thumbnail': video_thumbnail,
41             'age_limit': 18,
42         }