From 6e919a36952a91fde78400cc018836be6819ce9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 15 Jan 2025 14:35:37 +0100 Subject: [PATCH] [e621] support e621.cc and e621.anthro.fr frontend URLs (#6809) --- docs/supportedsites.md | 2 +- gallery_dl/extractor/e621.py | 19 ++++++++++++++++++- scripts/supportedsites.py | 3 +++ test/results/E621.py | 25 +++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 test/results/E621.py diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 92fa691c..e55e868a 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -1184,7 +1184,7 @@ Consider all listed sites to potentially be NSFW. e621 https://e621.net/ - Favorites, Pools, Popular Images, Posts, Tag Searches + Favorites, Pools, Popular Images, Posts, Tag Searches, Frontends Supported diff --git a/gallery_dl/extractor/e621.py b/gallery_dl/extractor/e621.py index 33e6ba8e..eddcb125 100644 --- a/gallery_dl/extractor/e621.py +++ b/gallery_dl/extractor/e621.py @@ -8,7 +8,7 @@ """Extractors for https://e621.net/ and other e621 instances""" -from .common import Message +from .common import Extractor, Message from . import danbooru from ..cache import memcache from .. import text, util @@ -156,3 +156,20 @@ class E621FavoriteExtractor(E621Extractor): def posts(self): return self._pagination("/favorites.json", self.query) + + +class E621FrontendExtractor(Extractor): + """Extractor for alternative e621 frontends""" + basecategory = "E621" + category = "e621" + subcategory = "frontend" + pattern = r"(?:https?://)?e621\.(?:cc/\?tags|anthro\.fr/\?q)=([^&#]*)" + example = "https://e621.cc/?tags=TAG" + + def initialize(self): + pass + + def items(self): + url = "https://e621.net/posts?tags=" + self.groups[0] + data = {"_extractor": E621TagExtractor} + yield Message.Queue, url, data diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 3ef7e9e0..6ca00263 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -578,6 +578,9 @@ def build_extractor_list(): default["wikifeetx"] = default["wikifeet"] domains["wikifeetx"] = "https://www.wikifeetx.com/" + # add extra e621 extractors + categories["E621"]["e621"].extend(default.pop("e621", ())) + return categories, domains diff --git a/test/results/E621.py b/test/results/E621.py new file mode 100644 index 00000000..dc86c4fb --- /dev/null +++ b/test/results/E621.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +from gallery_dl.extractor import e621 + + +__tests__ = ( +{ + "#url" : "https://e621.cc/?tags=rating:safe", + "#category": ("E621", "e621", "frontend"), + "#class" : e621.E621FrontendExtractor, + "#urls" : "https://e621.net/posts?tags=rating:safe", +}, + +{ + "#url" : "https://e621.anthro.fr/?q=rating:safe", + "#category": ("E621", "e621", "frontend"), + "#class" : e621.E621FrontendExtractor, + "#urls" : "https://e621.net/posts?tags=rating:safe", +}, + +)