]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spankbang.py
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):
110 format_id[len(STREAM_URL_PREFIX):], format_url)
112 self._sort_formats(formats)
114 title = self._html_search_regex(
115 r'(?s
)<h1
[^
>]*>(.+?
)</h1
>', webpage, 'title
')
116 description = self._search_regex(
117 r'<div
[^
>]+\bclass
=["\']bottom[^>]+>\s*<p>[^<]*</p>\s*<p>([^<]+)',
118 webpage, 'description', fatal=False)
119 thumbnail = self._og_search_thumbnail(webpage)
120 uploader = self._search_regex(
121 r'class="user
"[^>]*><img[^>]+>([^<]+)',
122 webpage, 'uploader', default=None)
123 duration = parse_duration(self._search_regex(
124 r'<div[^>]+\bclass=["\']right_side
[^
>]+>\s
*<span
>([^
<]+)',
125 webpage, 'duration
', fatal=False))
126 view_count = str_to_int(self._search_regex(
127 r'([\d
,.]+)\s
+plays
', webpage, 'view count
', fatal=False))
129 age_limit = self._rta_search(webpage)
134 'description
': description,
135 'thumbnail
': thumbnail,
136 'uploader
': uploader,
137 'duration
': duration,
138 'view_count
': view_count,
140 'age_limit
': age_limit,
144 class SpankBangPlaylistIE(InfoExtractor):
145 _VALID_URL = r'https?
://(?
:[^
/]+\
.)?spankbang\
.com
/(?P
<id>[\da
-z
]+)/playlist
/[^
/]+'
147 'url
': 'https
://spankbang
.com
/ug0k
/playlist
/big
+ass
+titties
',
150 'title
': 'Big Ass Titties
',
152 'playlist_mincount
': 50,
155 def _real_extract(self, url):
156 playlist_id = self._match_id(url)
158 webpage = self._download_webpage(
159 url, playlist_id, headers={'Cookie
': 'country
=US
; mobile
=on
'})
161 entries = [self.url_result(
162 'https
://spankbang
.com
/%s/video
' % video_id,
163 ie=SpankBangIE.ie_key(), video_id=video_id)
164 for video_id in orderedSet(re.findall(
165 r'<a
[^
>]+\bhref
=["\']/?([\da-z]+)/play/', webpage))]
167 title = self._html_search_regex(
168 r'<h1>([^<]+)\s+playlist</h1>', webpage, 'playlist title',
171 return self.playlist_result(entries, playlist_id, title)