Skip to content

Commit

Permalink
[toyhouse] fix Content Warning bypass (#5820)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 4, 2024
1 parent e03b99b commit 162756b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions gallery_dl/extractor/toyhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,27 @@ def _pagination(self, path):
cnt += 1
yield self._parse_post(post)

if cnt == 0 and params["page"] == 1:
token, pos = text.extract(
page, '<input name="_token" type="hidden" value="', '"')
if not token:
return
data = {
"_token": token,
"user" : text.extract(page, 'value="', '"', pos)[0],
}
self.request(self.root + "/~account/warnings/accept",
method="POST", data=data, allow_redirects=False)
continue
if not cnt and params["page"] == 1:
if self._accept_content_warning(page):
continue
return

if cnt < 18:
return
params["page"] += 1

def _accept_content_warning(self, page):
pos = page.find(' name="_token"') + 1
token, pos = text.extract(page, ' value="', '"', pos)
user , pos = text.extract(page, ' value="', '"', pos)
if not token or not user:
return False

data = {"_token": token, "user": user}
self.request(self.root + "/~account/warnings/accept",
method="POST", data=data, allow_redirects=False)
return True


class ToyhouseArtExtractor(ToyhouseExtractor):
"""Extractor for artworks of a toyhouse user"""
Expand Down

0 comments on commit 162756b

Please sign in to comment.