]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spankbang.py
Prepare to release
[youtubedl] / youtube_dl / extractor / spankbang.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import ExtractorError
7
8
9 class SpankBangIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:(?:www|[a-z]{2})\.)?spankbang\.com/(?P<id>[\da-z]+)/video'
11 _TESTS = [{
12 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
13 'md5': '1cc433e1d6aa14bc376535b8679302f7',
14 'info_dict': {
15 'id': '3vvn',
16 'ext': 'mp4',
17 'title': 'fantasy solo',
18 'description': 'Watch fantasy solo free HD porn video - 05 minutes - dillion harper masturbates on a bed free adult movies.',
19 'thumbnail': r're:^https?://.*\.jpg$',
20 'uploader': 'silly2587',
21 'age_limit': 18,
22 }
23 }, {
24 # 480p only
25 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
26 'only_matching': True,
27 }, {
28 # no uploader
29 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
30 'only_matching': True,
31 }]
32
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
35 webpage = self._download_webpage(url, video_id)
36
37 if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
38 raise ExtractorError(
39 'Video %s is not available' % video_id, expected=True)
40
41 stream_key = self._html_search_regex(
42 r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
43 webpage, 'stream key')
44
45 formats = [{
46 'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
47 'ext': 'mp4',
48 'format_id': '%sp' % height,
49 'height': int(height),
50 } for height in re.findall(r'<(?:span|li|p)[^>]+[qb]_(\d+)p', webpage)]
51 self._check_formats(formats, video_id)
52 self._sort_formats(formats)
53
54 title = self._html_search_regex(
55 r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
56 description = self._og_search_description(webpage)
57 thumbnail = self._og_search_thumbnail(webpage)
58 uploader = self._search_regex(
59 r'class="user"[^>]*><img[^>]+>([^<]+)',
60 webpage, 'uploader', default=None)
61
62 age_limit = self._rta_search(webpage)
63
64 return {
65 'id': video_id,
66 'title': title,
67 'description': description,
68 'thumbnail': thumbnail,
69 'uploader': uploader,
70 'formats': formats,
71 'age_limit': age_limit,
72 }