Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SpankBangPlaylist] Add new extractor #19145

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
37 changes: 37 additions & 0 deletions youtube_dl/extractor/spankbang.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
parse_duration,
parse_resolution,
str_to_int,
urljoin,
)


Expand Down Expand Up @@ -94,3 +95,39 @@ def _real_extract(self, url):
'formats': formats,
'age_limit': age_limit,
}


class SpankBangPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?:www|m|[a-z]{2})\.)?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',
},
'playlist_mincount': 2,
}

def _extract_entries(self, webpage, p_id):
video_items = re.findall(r'<div[^>]+class=[\'"].*?video-item[^>]*>\s*(.+?)>', webpage)

entries = []
for div in video_items:
page_url = self._search_regex(
r'href="/?(' + p_id + '-[\da-z]+/playlist/[^"]+)', div, 'page url', default=None)

if page_url:
page = self._download_webpage(urljoin('http://spankbang.com', page_url), p_id)
canonical_url = self._search_regex(
r'link rel="canonical" href="(.+?)"', page, 'canonical url')
entries.append(self.url_result(canonical_url, SpankBangIE.ie_key()))
return entries

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

entries = self._extract_entries(webpage, playlist_id)
title = self._search_regex(r'<h1>(.+)</h1>', webpage, 'playlist_title', fatal=False)

return self.playlist_result(entries, playlist_id, title)