Skip to content

Commit

Permalink
[spankbang:playlist] Add extractor (closes #19145)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw authored and meunierd committed Feb 13, 2020
1 parent 721e191 commit 4296932
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 4 additions & 1 deletion youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,10 @@
SouthParkEsIE,
SouthParkNlIE
)
from .spankbang import SpankBangIE
from .spankbang import (
SpankBangIE,
SpankBangPlaylistIE,
)
from .spankwire import SpankwireIE
from .spiegel import SpiegelIE, SpiegelArticleIE
from .spiegeltv import SpiegeltvIE
Expand Down
33 changes: 32 additions & 1 deletion youtube_dl/extractor/spankbang.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from .common import InfoExtractor
from ..utils import (
ExtractorError,
orderedSet,
parse_duration,
parse_resolution,
str_to_int,
)


class SpankBangIE(InfoExtractor):
_VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/(?:video|play|embed)'
_VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/(?:video|play|embed)\b'
_TESTS = [{
'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
'md5': '1cc433e1d6aa14bc376535b8679302f7',
Expand Down Expand Up @@ -103,3 +104,33 @@ def _real_extract(self, url):
'formats': formats,
'age_limit': age_limit,
}


class SpankBangPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:[^/]+\.)?spankbang\.com/(?P<id>[\da-z]+)/playlist/[^/]+'
_TEST = {
'url': 'https://spankbang.com/ug0k/playlist/big+ass+titties',
'info_dict': {
'id': 'ug0k',
'title': 'Big Ass Titties',
},
'playlist_mincount': 50,
}

def _real_extract(self, url):
playlist_id = self._match_id(url)

webpage = self._download_webpage(
url, playlist_id, headers={'Cookie': 'country=US; mobile=on'})

entries = [self.url_result(
'https://spankbang.com/%s/video' % video_id,
ie=SpankBangIE.ie_key(), video_id=video_id)
for video_id in orderedSet(re.findall(
r'<a[^>]+\bhref=["\']/?([\da-z]+)/play/', webpage))]

title = self._html_search_regex(
r'<h1>([^<]+)\s+playlist</h1>', webpage, 'playlist title',
fatal=False)

return self.playlist_result(entries, playlist_id, title)

0 comments on commit 4296932

Please sign in to comment.