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

[ao3] fix bookmark extraction, support 'series' bookmarks (#6013)

This commit is contained in:
Mike Fährmann 2024-09-21 13:54:42 +02:00
parent 5c062f95c1
commit 8bf081d295
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 19 additions and 1 deletions

View File

@ -282,3 +282,21 @@ class Ao3UserBookmarkExtractor(Ao3Extractor):
pattern = (BASE_PATTERN + r"(/users/([^/?#]+)/(?:pseuds/([^/?#]+)/)?"
r"bookmarks(?:/?\?.+)?)")
example = "https://archiveofourown.org/users/USER/bookmarks"
def items(self):
self.login()
base = self.root + "/"
data_work = {"_extractor": Ao3WorkExtractor}
data_series = {"_extractor": Ao3SeriesExtractor}
for item in self._pagination(
self.groups[0], '<span class="count"><a href="/'):
path = item.rpartition("/")[0]
url = base + path
if item.startswith("works/"):
yield Message.Queue, url, data_work
elif item.startswith("series/"):
yield Message.Queue, url, data_series
else:
self.log.warning("Unsupported bookmark type '%s'", path)

View File

@ -236,7 +236,7 @@ __tests__ = (
"#url" : "https://archiveofourown.org/users/Fyrelass/bookmarks",
"#category": ("", "ao3", "user-bookmark"),
"#class" : ao3.Ao3UserBookmarkExtractor,
"#pattern" : ao3.Ao3WorkExtractor.pattern,
"#pattern" : r"https://archiveofourown\.org/(work|serie)s/\d+",
"#range" : "1-50",
"#count" : 50,
},