]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/spankbang.py
[odnoklassniki] Use compat_urllib_parse_unquote
[youtube-dl.git] / youtube_dl / extractor / spankbang.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class SpankBangIE(InfoExtractor):
9     _VALID_URL = r'https?://(?:(?:www|[a-z]{2})\.)?spankbang\.com/(?P<id>[\da-z]+)/video'
10     _TEST = {
11         'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
12         'md5': '1cc433e1d6aa14bc376535b8679302f7',
13         'info_dict': {
14             'id': '3vvn',
15             'ext': 'mp4',
16             'title': 'fantasy solo',
17             'description': 'dillion harper masturbates on a bed',
18             'thumbnail': 're:^https?://.*\.jpg$',
19             'uploader': 'silly2587',
20             'age_limit': 18,
21         }
22     }
23
24     def _real_extract(self, url):
25         video_id = self._match_id(url)
26         webpage = self._download_webpage(url, video_id)
27
28         stream_key = self._html_search_regex(
29             r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
30             webpage, 'stream key')
31
32         formats = [{
33             'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
34             'ext': 'mp4',
35             'format_id': '%sp' % height,
36             'height': int(height),
37         } for height in re.findall(r'<span[^>]+q_(\d+)p', webpage)]
38         self._sort_formats(formats)
39
40         title = self._html_search_regex(
41             r'(?s)<h1>(.+?)</h1>', webpage, 'title')
42         description = self._search_regex(
43             r'class="desc"[^>]*>([^<]+)',
44             webpage, 'description', default=None)
45         thumbnail = self._og_search_thumbnail(webpage)
46         uploader = self._search_regex(
47             r'class="user"[^>]*>([^<]+)',
48             webpage, 'uploader', fatal=False)
49
50         age_limit = self._rta_search(webpage)
51
52         return {
53             'id': video_id,
54             'title': title,
55             'description': description,
56             'thumbnail': thumbnail,
57             'uploader': uploader,
58             'formats': formats,
59             'age_limit': age_limit,
60         }