Merge remote-tracking branch 'hojel/slutload'
[youtube-dl] / youtube_dl / extractor / slutload.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5     ExtractorError,
6 )
7
8 class SlutloadIE(InfoExtractor):
9     _VALID_URL = r'^https?://(?:\w+\.)?slutload\.com/video/[^/]+/(?P<videoid>[^/]+)/?$'
10     _TEST = {
11         u'url': u'http://www.slutload.com/video/virginie-baisee-en-cam/TD73btpBqSxc/',
12         u'file': u'TD73btpBqSxc.mp4',
13         u'md5': u'0cf531ae8006b530bd9df947a6a0df77',
14         u'info_dict': {
15             u"title": u"virginie baisee en cam",
16             u"age_limit": 18,
17         }
18     }
19
20     def _real_extract(self, url):
21         mobj = re.match(self._VALID_URL, url)
22
23         video_id = mobj.group('videoid')
24
25         # Get webpage content
26         webpage = self._download_webpage(url, video_id)
27
28         # Get the video title
29         video_title = self._html_search_regex(r'<h1><strong>([^<]+)</strong>',
30             webpage, u'title').strip()
31
32         # Get the video url
33         result = re.compile(r'<div id="vidPlayer"\s+data-url="([^"]+)"\s+previewer-file="([^"]+)"', re.S).search(webpage)
34         if result is None:
35             raise ExtractorError(u'ERROR: unable to extract video_url')
36
37         video_url, video_thumb = result.group(1,2)
38
39         info = {'id': video_id,
40                 'url': video_url,
41                 'title': video_title,
42                 'thumbnail': video_thumb,
43                 'ext': 'mp4',
44                 'age_limit': 18}
45
46         return [info]