1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-21 18:22:30 +01:00

[ao3] detect member-only and adult works (#6013)

This commit is contained in:
Mike Fährmann 2024-09-21 13:20:42 +02:00
parent 3348b05df0
commit 91eb04b0d0
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -116,7 +116,17 @@ class Ao3WorkExtractor(Ao3Extractor):
work_id = self.groups[0]
url = "{}/works/{}".format(self.root, work_id)
extr = text.extract_from(self.request(url).text)
response = self.request(url, notfound="work")
if response.url.endswith("/users/login?restricted=true"):
raise exception.AuthorizationError(
"Login required to access member-only works")
page = response.text
if len(page) < 20000 and \
'<h2 class="landmark heading">Adult Content Warning</' in page:
raise exception.StopExtraction("Adult Content")
extr = text.extract_from(page)
chapters = {}
cindex = extr(' id="chapter_index"', "</ul>")