From a953d3d3160f0656a68e39bf6e97bf016cb0f19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 26 Aug 2025 11:26:52 +0200 Subject: [PATCH] [erome] handle reposts on user profiles (#6582) https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3221322147 - add 'reposts' option - disable reposts by default - process URL query parameters, e.g. 't=posts' or 'page=3' --- docs/configuration.rst | 10 ++++++++++ docs/gallery-dl.conf | 6 ++++++ gallery_dl/extractor/erome.py | 21 +++++++++++++++------ test/results/erome.py | 25 +++++++++++++++++++++++-- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 2ea0bc55..11c40d06 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2557,6 +2557,16 @@ Description batch. The value cannot be less than 1. +extractor.erome.user.reposts +---------------------------- +Type + ``bool`` +Default + ``false`` +Description + Include reposts when extracting albums from a user profile. + + extractor.exhentai.domain ------------------------- Type diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 1890b72d..2deb24ad 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -287,6 +287,12 @@ "metadata": false } }, + "erome": + { + "user": { + "reposts": false + } + }, "exhentai": { "username": "", diff --git a/gallery_dl/extractor/erome.py b/gallery_dl/extractor/erome.py index 7beeac5a..68cfdbc5 100644 --- a/gallery_dl/extractor/erome.py +++ b/gallery_dl/extractor/erome.py @@ -48,10 +48,13 @@ class EromeExtractor(Extractor): self.sleep(5.0, "check") def _pagination(self, url, params): - for params["page"] in itertools.count(1): + find_albums = EromeAlbumExtractor.pattern.findall + + for params["page"] in itertools.count( + text.parse_int(params.get("page"), 1)): page = self.request(url, params=params).text - album_ids = EromeAlbumExtractor.pattern.findall(page)[::2] + album_ids = find_albums(page)[::2] yield from album_ids if len(album_ids) < 36: @@ -114,12 +117,18 @@ class EromeAlbumExtractor(EromeExtractor): class EromeUserExtractor(EromeExtractor): subcategory = "user" - pattern = BASE_PATTERN + r"/(?!a/|search\?)([^/?#]+)" + pattern = BASE_PATTERN + r"/(?!a/|search\?)([^/?#]+)(?:/?\?([^#]+))?" example = "https://www.erome.com/USER" def albums(self): - url = f"{self.root}/{self.groups[0]}" - return self._pagination(url, {}) + user, qs = self.groups + url = f"{self.root}/{user}" + + params = text.parse_query(qs) + if "t" not in params and not self.config("reposts", False): + params["t"] = "posts" + + return self._pagination(url, params) class EromeSearchExtractor(EromeExtractor): @@ -128,7 +137,7 @@ class EromeSearchExtractor(EromeExtractor): example = "https://www.erome.com/search?q=QUERY" def albums(self): - url = self.root + "/search" + url = f"{self.root}/search" params = text.parse_query(self.groups[0]) return self._pagination(url, params) diff --git a/test/results/erome.py b/test/results/erome.py index 251062bc..b83a3574 100644 --- a/test/results/erome.py +++ b/test/results/erome.py @@ -43,8 +43,29 @@ __tests__ = ( "#category": ("", "erome", "user"), "#class" : erome.EromeUserExtractor, "#pattern" : erome.EromeAlbumExtractor.pattern, - "#range" : "1-25", - "#count" : 25, + "#count" : 88, +}, + +{ + "#url" : "https://www.erome.com/yYgWBZw8o8qsMzM?t=reposts", + "#class" : erome.EromeUserExtractor, + "#count" : 0, +}, + +{ + "#url" : "https://www.erome.com/john3884", + "#class" : erome.EromeUserExtractor, + "#count" : 0, +}, + +{ + "#url" : "https://www.erome.com/john3884", + "#class" : erome.EromeUserExtractor, + "#options" : {"reposts": True}, + "#results" : ( + "https://www.erome.com/a/NQgdlWvk", + "https://www.erome.com/a/TdbZ4ogi", + ), }, {