[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:
@@ -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
|
||||
|
||||
@@ -287,6 +287,12 @@
|
||||
"metadata": false
|
||||
}
|
||||
},
|
||||
"erome":
|
||||
{
|
||||
"user": {
|
||||
"reposts": false
|
||||
}
|
||||
},
|
||||
"exhentai":
|
||||
{
|
||||
"username": "",
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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",
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user