[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'
This commit is contained in:
Mike Fährmann
2025-08-26 11:26:52 +02:00
parent 5a5857bafb
commit a953d3d316
4 changed files with 54 additions and 8 deletions

View File

@@ -2557,6 +2557,16 @@ Description
batch. The value cannot be less than 1. 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 extractor.exhentai.domain
------------------------- -------------------------
Type Type

View File

@@ -287,6 +287,12 @@
"metadata": false "metadata": false
} }
}, },
"erome":
{
"user": {
"reposts": false
}
},
"exhentai": "exhentai":
{ {
"username": "", "username": "",

View File

@@ -48,10 +48,13 @@ class EromeExtractor(Extractor):
self.sleep(5.0, "check") self.sleep(5.0, "check")
def _pagination(self, url, params): 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 page = self.request(url, params=params).text
album_ids = EromeAlbumExtractor.pattern.findall(page)[::2] album_ids = find_albums(page)[::2]
yield from album_ids yield from album_ids
if len(album_ids) < 36: if len(album_ids) < 36:
@@ -114,12 +117,18 @@ class EromeAlbumExtractor(EromeExtractor):
class EromeUserExtractor(EromeExtractor): class EromeUserExtractor(EromeExtractor):
subcategory = "user" subcategory = "user"
pattern = BASE_PATTERN + r"/(?!a/|search\?)([^/?#]+)" pattern = BASE_PATTERN + r"/(?!a/|search\?)([^/?#]+)(?:/?\?([^#]+))?"
example = "https://www.erome.com/USER" example = "https://www.erome.com/USER"
def albums(self): def albums(self):
url = f"{self.root}/{self.groups[0]}" user, qs = self.groups
return self._pagination(url, {}) 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): class EromeSearchExtractor(EromeExtractor):
@@ -128,7 +137,7 @@ class EromeSearchExtractor(EromeExtractor):
example = "https://www.erome.com/search?q=QUERY" example = "https://www.erome.com/search?q=QUERY"
def albums(self): def albums(self):
url = self.root + "/search" url = f"{self.root}/search"
params = text.parse_query(self.groups[0]) params = text.parse_query(self.groups[0])
return self._pagination(url, params) return self._pagination(url, params)

View File

@@ -43,8 +43,29 @@ __tests__ = (
"#category": ("", "erome", "user"), "#category": ("", "erome", "user"),
"#class" : erome.EromeUserExtractor, "#class" : erome.EromeUserExtractor,
"#pattern" : erome.EromeAlbumExtractor.pattern, "#pattern" : erome.EromeAlbumExtractor.pattern,
"#range" : "1-25", "#count" : 88,
"#count" : 25, },
{
"#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",
),
}, },
{ {