From a937b72034d663f4ee7ddeb2898dbc9fa450be91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 28 Sep 2024 20:25:53 +0200 Subject: [PATCH] [ao3] add 'subscriptions' extractor (#6247) --- docs/supportedsites.md | 2 +- gallery_dl/extractor/ao3.py | 45 ++++++++++++++++++++++++------------- test/results/ao3.py | 34 +++++++++++++++------------- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index e08f43a9f6..74112b3df3 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -106,7 +106,7 @@ Consider all listed sites to potentially be NSFW. Archive of Our Own https://archiveofourown.org/ - Search Results, Series, Tag Searches, User Profiles, Bookmarks, Works + Search Results, Series, Subscriptions, Tag Searches, User Profiles, Bookmarks, Works Supported diff --git a/gallery_dl/extractor/ao3.py b/gallery_dl/extractor/ao3.py index 1f570e8331..d3ab846888 100644 --- a/gallery_dl/extractor/ao3.py +++ b/gallery_dl/extractor/ao3.py @@ -29,11 +29,31 @@ def items(self): self.login() base = self.root + "/works/" - data = {"_extractor": Ao3WorkExtractor} + data = {"_extractor": Ao3WorkExtractor, "type": "work"} for work_id in self.works(): yield Message.Queue, base + work_id, data + def items_list(self, type, needle, part=True): + self.login() + + base = self.root + "/" + data_work = {"_extractor": Ao3WorkExtractor, "type": "work"} + data_series = {"_extractor": Ao3SeriesExtractor, "type": "series"} + data_user = {"_extractor": Ao3UserExtractor, "type": "user"} + + for item in self._pagination(self.groups[0], needle): + path = item.rpartition("/")[0] if part else item + url = base + path + if item.startswith("works/"): + yield Message.Queue, url, data_work + elif item.startswith("series/"): + yield Message.Queue, url, data_series + elif item.startswith("users/"): + yield Message.Queue, url, data_user + else: + self.log.warning("Unsupported %s type '%s'", type, path) + def works(self): return self._pagination(self.groups[0]) @@ -284,19 +304,14 @@ class Ao3UserBookmarkExtractor(Ao3Extractor): example = "https://archiveofourown.org/users/USER/bookmarks" def items(self): - self.login() + return self.items_list("bookmark", '\n