]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/spankbang.py
[vidlii] Add extractor (closes #14472, closes #14512, closes #14779)
[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 from ..utils import ExtractorError
7
8
9 class SpankBangIE(InfoExtractor):
10     _VALID_URL = r'https?://(?:(?:www|m|[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 -  Babe,Masturbation,Solo,Toy  - dillion harper masturbates on a bed free adult movies sexy clips.',
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         # mobile page
33         'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
34         'only_matching': True,
35     }]
36
37     def _real_extract(self, url):
38         video_id = self._match_id(url)
39         webpage = self._download_webpage(url, video_id)
40
41         if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
42             raise ExtractorError(
43                 'Video %s is not available' % video_id, expected=True)
44
45         stream_key = self._html_search_regex(
46             r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
47             webpage, 'stream key')
48
49         formats = [{
50             'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
51             'ext': 'mp4',
52             'format_id': '%sp' % height,
53             'height': int(height),
54         } for height in re.findall(r'<(?:span|li|p)[^>]+[qb]_(\d+)p', webpage)]
55         self._check_formats(formats, video_id)
56         self._sort_formats(formats)
57
58         title = self._html_search_regex(
59             r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
60         description = self._og_search_description(webpage)
61         thumbnail = self._og_search_thumbnail(webpage)
62         uploader = self._search_regex(
63             r'class="user"[^>]*><img[^>]+>([^<]+)',
64             webpage, 'uploader', default=None)
65
66         age_limit = self._rta_search(webpage)
67
68         return {
69             'id': video_id,
70             'title': title,
71             'description': description,
72             'thumbnail': thumbnail,
73             'uploader': uploader,
74             'formats': formats,
75             'age_limit': age_limit,
76         }