1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

[mangadex] apply 'lang' only to chapter results (#6372)

This commit is contained in:
Mike Fährmann 2024-10-26 17:49:37 +02:00
parent 7e43c9292d
commit cc07c81063
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 26 additions and 16 deletions

View File

@ -221,7 +221,7 @@ class MangadexAPI():
return self._call("/list/" + uuid)["data"]
def list_feed(self, uuid):
return self._pagination("/list/" + uuid + "/feed")
return self._pagination_chapters("/list/" + uuid + "/feed")
@memcache(keyarg=1)
def manga(self, uuid):
@ -230,7 +230,7 @@ class MangadexAPI():
def manga_author(self, uuid_author):
params = {"authorOrArtist": uuid_author}
return self._pagination("/manga", params)
return self._pagination_manga("/manga", params)
def manga_feed(self, uuid):
order = "desc" if self.extractor.config("chapter-reverse") else "asc"
@ -238,11 +238,11 @@ class MangadexAPI():
"order[volume]" : order,
"order[chapter]": order,
}
return self._pagination("/manga/" + uuid + "/feed", params)
return self._pagination_chapters("/manga/" + uuid + "/feed", params)
def user_follows_manga_feed(self):
params = {"order[publishAt]": "desc"}
return self._pagination("/user/follows/manga/feed", params)
return self._pagination_chapters("/user/follows/manga/feed", params)
def authenticate(self):
self.headers["Authorization"] = \
@ -289,22 +289,31 @@ class MangadexAPI():
raise exception.StopExtraction(
"%s %s (%s)", response.status_code, response.reason, msg)
def _pagination(self, endpoint, params=None):
def _pagination_chapters(self, endpoint, params=None):
if params is None:
params = {}
lang = self.extractor.config("lang")
if isinstance(lang, str) and "," in lang:
lang = lang.split(",")
params["translatedLanguage[]"] = lang
params["includes[]"] = ("scanlation_group",)
return self._pagination(endpoint, params)
def _pagination_manga(self, endpoint, params=None):
if params is None:
params = {}
return self._pagination(endpoint, params)
def _pagination(self, endpoint, params):
config = self.extractor.config
ratings = config("ratings")
if ratings is None:
ratings = ("safe", "suggestive", "erotica", "pornographic")
lang = config("lang")
if isinstance(lang, str) and "," in lang:
lang = lang.split(",")
params["contentRating[]"] = ratings
params["translatedLanguage[]"] = lang
params["includes[]"] = ("scanlation_group",)
params["offset"] = 0
api_params = config("api-parameters")

View File

@ -6,5 +6,5 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
__version__ = "1.27.7"
__version__ = "1.28.0-dev"
__variant__ = None

View File

@ -81,8 +81,8 @@ __tests__ = (
"#count" : 2,
"manga" : "Souten no Koumori",
"lang" : r"re:fr|it",
"language": r"re:French|Italian",
"lang" : {"fr", "it"},
"language": {"French", "Italian"},
},
{
@ -134,8 +134,8 @@ __tests__ = (
"#category": ("", "mangadex", "list-feed"),
"#class" : mangadex.MangadexListExtractor,
"#urls" : (
"https://mangadex.org/chapter/c765d6d5-5712-4360-be0b-0c8e0914fc94",
"https://mangadex.org/chapter/fa8a695d-260f-4dcc-95a3-1f30e66d6571",
"https://mangadex.org/chapter/c765d6d5-5712-4360-be0b-0c8e0914fc94",
"https://mangadex.org/chapter/788766b9-41c6-422e-97ba-552f03ba9655",
),
},
@ -157,6 +157,7 @@ __tests__ = (
"#url" : "https://mangadex.org/author/254efca2-0ac0-432c-a3a3-55b7e207e87d/flipflops",
"#class" : mangadex.MangadexAuthorExtractor,
"#pattern" : mangadex.MangadexMangaExtractor.pattern,
"#options" : {"lang": "en"},
"#count" : ">= 15",
},