]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/spankbang.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
19 class SpankBangIE(InfoExtractor
):
22 (?:[^/]+\.)?spankbang\.com/
24 (?P<id>[\da-z]+)/(?:video|play|embed)\b|
25 [\da-z]+-(?P<id_2>[\da-z]+)/playlist/[^/?#&]+
29 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
30 'md5': '1cc433e1d6aa14bc376535b8679302f7',
34 'title': 'fantasy solo',
35 'description': 'dillion harper masturbates on a bed',
36 'thumbnail': r
're:^https?://.*\.jpg$',
37 'uploader': 'silly2587',
38 'timestamp': 1422571989,
39 'upload_date': '20150129',
44 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
45 'only_matching': True,
48 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
49 'only_matching': True,
52 'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
53 'only_matching': True,
56 'url': 'https://spankbang.com/1vwqx/video/jade+kush+solo+4k',
57 'only_matching': True,
59 'url': 'https://m.spankbang.com/3vvn/play/fantasy+solo/480p/',
60 'only_matching': True,
62 'url': 'https://m.spankbang.com/3vvn/play',
63 'only_matching': True,
65 'url': 'https://spankbang.com/2y3td/embed/',
66 'only_matching': True,
68 'url': 'https://spankbang.com/2v7ik-7ecbgu/playlist/latina+booty',
69 'only_matching': True,
72 def _real_extract(self
, url
):
73 mobj
= re
.match(self
._VALID
_URL
, url
)
74 video_id
= mobj
.group('id') or mobj
.group('id_2')
75 webpage
= self
._download
_webpage
(
76 url
.replace('/%s/embed' % video_id
, '/%s/video' % video_id
),
77 video_id
, headers
={'Cookie': 'country=US'}
)
79 if re
.search(r
'<[^>]+\b(?:id|class)=["\']video_removed
', webpage):
81 'Video
%s is not available
' % video_id, expected=True)
85 def extract_format(format_id, format_url):
86 f_url = url_or_none(format_url)
89 f = parse_resolution(format_id)
90 ext = determine_ext(f_url)
91 if format_id.startswith('m3u8
') or ext == 'm3u8
':
92 formats.extend(self._extract_m3u8_formats(
93 f_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
94 m3u8_id='hls
', fatal=False))
95 elif format_id.startswith('mpd
') or ext == 'mpd
':
96 formats.extend(self._extract_mpd_formats(
97 f_url, video_id, mpd_id='dash
', fatal=False))
98 elif ext == 'mp4
' or f.get('width
') or f.get('height
'):
101 'format_id
': format_id,
105 STREAM_URL_PREFIX = 'stream_url_
'
107 for mobj in re.finditer(
108 r'%s(?P
<id>[^\s
=]+)\s
*=\s
*(["\'])(?P<url>(?:(?!\2).)+)\2'
109 % STREAM_URL_PREFIX, webpage):
110 extract_format(mobj.group('id', 'url'))
113 stream_key = self._search_regex(
114 r'data-streamkey\s*=\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1',
115 webpage, 'stream key
', group='value
')
117 stream = self._download_json(
118 'https
://spankbang
.com
/api
/videos
/stream
', video_id,
119 'Downloading stream JSON
', data=urlencode_postdata({
124 'X
-Requested
-With
': 'XMLHttpRequest
',
127 for format_id, format_url in stream.items():
128 if format_url and isinstance(format_url, list):
129 format_url = format_url[0]
130 extract_format(format_id, format_url)
132 self._sort_formats(formats)
134 info = self._search_json_ld(webpage, video_id, default={})
136 title = self._html_search_regex(
137 r'(?s
)<h1
[^
>]*>(.+?
)</h1
>', webpage, 'title
', default=None)
138 description = self._search_regex(
139 r'<div
[^
>]+\bclass
=["\']bottom[^>]+>\s*<p>[^<]*</p>\s*<p>([^<]+)',
140 webpage, 'description', default=None)
141 thumbnail = self._og_search_thumbnail(webpage, default=None)
142 uploader = self._html_search_regex(
143 (r'(?s)<li[^>]+class=["\']profile
[^
>]+>(.+?
)</a
>',
144 r'class="user"[^
>]*><img
[^
>]+>([^
<]+)'),
145 webpage, 'uploader
', default=None)
146 duration = parse_duration(self._search_regex(
147 r'<div
[^
>]+\bclass
=["\']right_side[^>]+>\s*<span>([^<]+)',
148 webpage, 'duration', default=None))
149 view_count = str_to_int(self._search_regex(
150 r'([\d,.]+)\s+plays', webpage, 'view count', default=None))
152 age_limit = self._rta_search(webpage)
156 'title': title or video_id,
157 'description': description,
158 'thumbnail': thumbnail,
159 'uploader': uploader,
160 'duration': duration,
161 'view_count': view_count,
163 'age_limit': age_limit,
168 class SpankBangPlaylistIE(InfoExtractor):
169 _VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/playlist/(?P<display_id>[^/]+)'
171 'url': 'https://spankbang.com/ug0k/playlist/big+ass+titties',
174 'title': 'Big Ass Titties',
176 'playlist_mincount': 40,
179 def _real_extract(self, url):
180 mobj = re.match(self._VALID_URL, url)
181 playlist_id = mobj.group('id')
182 display_id = mobj.group('display_id')
184 webpage = self._download_webpage(
185 url, playlist_id, headers={'Cookie': 'country=US; mobile=on'})
187 entries = [self.url_result(
188 urljoin(url, mobj.group('path')),
189 ie=SpankBangIE.ie_key(), video_id=mobj.group('id'))
190 for mobj in re.finditer(
191 r'<a[^>]+\bhref=(["\'])(?P
<path
>/?
[\da
-z
]+-(?P
<id>[\da
-z
]+)/playlist
/%s(?
:(?
!\
1).)*)\
1'
192 % re.escape(display_id), webpage)]
194 title = self._html_search_regex(
195 r'<h1
>([^
<]+)\s
+playlist\s
*<', webpage, 'playlist title
',
198 return self.playlist_result(entries, playlist_id, title)