1 from __future__ import unicode_literals
5 from .common import InfoExtractor
17 class SpankBangIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/(?:video|play|embed)\b'
20 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
21 'md5': '1cc433e1d6aa14bc376535b8679302f7',
25 'title': 'fantasy solo',
26 'description': 'dillion harper masturbates on a bed',
27 'thumbnail': r're:^https?://.*\.jpg$',
28 'uploader': 'silly2587',
33 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
34 'only_matching': True,
37 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
38 'only_matching': True,
41 'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
42 'only_matching': True,
45 'url': 'https://spankbang.com/1vwqx/video/jade+kush+solo+4k',
46 'only_matching': True,
48 'url': 'https://m.spankbang.com/3vvn/play/fantasy+solo/480p/',
49 'only_matching': True,
51 'url': 'https://m.spankbang.com/3vvn/play',
52 'only_matching': True,
54 'url': 'https://spankbang.com/2y3td/embed/',
55 'only_matching': True,
58 def _real_extract(self, url):
59 video_id = self._match_id(url)
60 webpage = self._download_webpage(
61 url.replace('/%s/embed' % video_id, '/%s/video' % video_id),
62 video_id, headers={'Cookie': 'country=US'})
64 if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
66 'Video %s is not available' % video_id, expected=True)
70 def extract_format(format_id, format_url):
71 f_url = url_or_none(format_url)
74 f = parse_resolution(format_id)
77 'format_id': format_id,
81 STREAM_URL_PREFIX = 'stream_url_'
83 for mobj in re.finditer(
84 r'%s(?P<id>[^\s=]+)\s*=\s*(["\'])(?P<url>(?:(?!\2).)+)\2'
85 % STREAM_URL_PREFIX, webpage):
86 extract_format(mobj.group('id', 'url'))
89 stream_key = self._search_regex(
90 r'data-streamkey\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
91 webpage, 'stream key', group='value')
93 sb_csrf_session = self._get_cookies(
94 'https://spankbang.com')['sb_csrf_session'].value
96 stream = self._download_json(
97 'https://spankbang.com/api/videos/stream', video_id,
98 'Downloading stream JSON', data=urlencode_postdata({
101 'sb_csrf_session': sb_csrf_session,
104 'X-CSRFToken': sb_csrf_session,
107 for format_id, format_url in stream.items():
108 if format_id.startswith(STREAM_URL_PREFIX):
109 if format_url and isinstance(format_url, list):
110 format_url = format_url[0]
112 format_id[len(STREAM_URL_PREFIX):], format_url)
114 self._sort_formats(formats)
116 title = self._html_search_regex(
117 r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
118 description = self._search_regex(
119 r'<div[^>]+\bclass=["\']bottom[^>]+>\s*<p>[^<]*</p>\s*<p>([^<]+)',
120 webpage, 'description', fatal=False)
121 thumbnail = self._og_search_thumbnail(webpage)
122 uploader = self._search_regex(
123 r'class="user"[^>]*><img[^>]+>([^<]+)',
124 webpage, 'uploader', default=None)
125 duration = parse_duration(self._search_regex(
126 r'<div[^>]+\bclass=["\']right_side[^>]+>\s*<span>([^<]+)',
127 webpage, 'duration', fatal=False))
128 view_count = str_to_int(self._search_regex(
129 r'([\d,.]+)\s+plays', webpage, 'view count', fatal=False))
131 age_limit = self._rta_search(webpage)
136 'description': description,
137 'thumbnail': thumbnail,
138 'uploader': uploader,
139 'duration': duration,
140 'view_count': view_count,
142 'age_limit': age_limit,
146 class SpankBangPlaylistIE(InfoExtractor):
147 _VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/playlist/[^/]+'
149 'url': 'https://spankbang.com/ug0k/playlist/big+ass+titties',
152 'title': 'Big Ass Titties',
154 'playlist_mincount': 50,
157 def _real_extract(self, url):
158 playlist_id = self._match_id(url)
160 webpage = self._download_webpage(
161 url, playlist_id, headers={'Cookie': 'country=US; mobile=on'})
163 entries = [self.url_result(
164 'https://spankbang.com/%s/video' % video_id,
165 ie=SpankBangIE.ie_key(), video_id=video_id)
166 for video_id in orderedSet(re.findall(
167 r'<a[^>]+\bhref=["\']/?([\da-z]+)/play/', webpage))]
169 title = self._html_search_regex(
170 r'<h1>([^<]+)\s+playlist</h1>', webpage, 'playlist title',
173 return self.playlist_result(entries, playlist_id, title)