]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spankbang.py
e040ada29b24542582f72f08f31b843d928af251
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
18 class SpankBangIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/(?:video|play|embed)\b'
21 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
22 'md5': '1cc433e1d6aa14bc376535b8679302f7',
26 'title': 'fantasy solo',
27 'description': 'dillion harper masturbates on a bed',
28 'thumbnail': r
're:^https?://.*\.jpg$',
29 'uploader': 'silly2587',
30 'timestamp': 1422571989,
31 'upload_date': '20150129',
36 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
37 'only_matching': True,
40 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
41 'only_matching': True,
44 'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
45 'only_matching': True,
48 'url': 'https://spankbang.com/1vwqx/video/jade+kush+solo+4k',
49 'only_matching': True,
51 'url': 'https://m.spankbang.com/3vvn/play/fantasy+solo/480p/',
52 'only_matching': True,
54 'url': 'https://m.spankbang.com/3vvn/play',
55 'only_matching': True,
57 'url': 'https://spankbang.com/2y3td/embed/',
58 'only_matching': True,
61 def _real_extract(self
, url
):
62 video_id
= self
._match
_id
(url
)
63 webpage
= self
._download
_webpage
(
64 url
.replace('/%s/embed' % video_id
, '/%s/video' % video_id
),
65 video_id
, headers
={'Cookie': 'country=US'})
67 if re
.search(r
'<[^>]+\bid=["\']video_removed
', webpage):
69 'Video
%s is not available
' % video_id, expected=True)
73 def extract_format(format_id, format_url):
74 f_url = url_or_none(format_url)
77 f = parse_resolution(format_id)
80 'format_id
': format_id,
84 STREAM_URL_PREFIX = 'stream_url_
'
86 for mobj in re.finditer(
87 r'%s(?P
<id>[^\s
=]+)\s
*=\s
*(["\'])(?P<url>(?:(?!\2).)+)\2'
88 % STREAM_URL_PREFIX, webpage):
89 extract_format(mobj.group('id', 'url'))
92 stream_key = self._search_regex(
93 r'data-streamkey\s*=\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1',
94 webpage, 'stream key
', group='value
')
96 sb_csrf_session = self._get_cookies(
97 'https
://spankbang
.com
')['sb_csrf_session
'].value
99 stream = self._download_json(
100 'https
://spankbang
.com
/api
/videos
/stream
', video_id,
101 'Downloading stream JSON
', data=urlencode_postdata({
104 'sb_csrf_session
': sb_csrf_session,
107 'X
-CSRFToken
': sb_csrf_session,
110 for format_id, format_url in stream.items():
111 if format_id.startswith(STREAM_URL_PREFIX):
112 if format_url and isinstance(format_url, list):
113 format_url = format_url[0]
115 format_id[len(STREAM_URL_PREFIX):], format_url)
117 self._sort_formats(formats)
119 info = self._search_json_ld(webpage, video_id, default={})
121 title = self._html_search_regex(
122 r'(?s
)<h1
[^
>]*>(.+?
)</h1
>', webpage, 'title
', default=None)
123 description = self._search_regex(
124 r'<div
[^
>]+\bclass
=["\']bottom[^>]+>\s*<p>[^<]*</p>\s*<p>([^<]+)',
125 webpage, 'description', default=None)
126 thumbnail = self._og_search_thumbnail(webpage, default=None)
127 uploader = self._html_search_regex(
128 (r'(?s)<li[^>]+class=["\']profile
[^
>]+>(.+?
)</a
>',
129 r'class="user"[^
>]*><img
[^
>]+>([^
<]+)'),
130 webpage, 'uploader
', default=None)
131 duration = parse_duration(self._search_regex(
132 r'<div
[^
>]+\bclass
=["\']right_side[^>]+>\s*<span>([^<]+)',
133 webpage, 'duration', default=None))
134 view_count = str_to_int(self._search_regex(
135 r'([\d,.]+)\s+plays', webpage, 'view count', default=None))
137 age_limit = self._rta_search(webpage)
141 'title': title or video_id,
142 'description': description,
143 'thumbnail': thumbnail,
144 'uploader': uploader,
145 'duration': duration,
146 'view_count': view_count,
148 'age_limit': age_limit,
153 class SpankBangPlaylistIE(InfoExtractor):
154 _VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/playlist/[^/]+'
156 'url': 'https://spankbang.com/ug0k/playlist/big+ass+titties',
159 'title': 'Big Ass Titties',
161 'playlist_mincount': 50,
164 def _real_extract(self, url):
165 playlist_id = self._match_id(url)
167 webpage = self._download_webpage(
168 url, playlist_id, headers={'Cookie': 'country=US; mobile=on'})
170 entries = [self.url_result(
171 'https://spankbang.com/%s/video' % video_id,
172 ie=SpankBangIE.ie_key(), video_id=video_id)
173 for video_id in orderedSet(re.findall(
174 r'<a[^>]+\bhref=["\']/?
([\da
-z
]+)/play
/', webpage))]
176 title = self._html_search_regex(
177 r'<h1
>([^
<]+)\s
+playlist
</h1
>', webpage, 'playlist title
',
180 return self.playlist_result(entries, playlist_id, title)