mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[mangadex] update parameter handling for API requests
- move common parameters into '_pagination()' - add 'ratings' (#1908) and 'api-parameters' options
This commit is contained in:
parent
cd66c3c415
commit
d93b5474c3
@ -1403,6 +1403,19 @@ Description
|
||||
The server to use for API requests.
|
||||
|
||||
|
||||
extractor.mangadex.api-parameters
|
||||
---------------------------------
|
||||
Type
|
||||
``object``
|
||||
Example
|
||||
``{"order[updatedAt]": "desc"}``
|
||||
Description
|
||||
Additional query parameters to send when fetching manga chapters.
|
||||
|
||||
(See `/manga/{id}/feed <https://api.mangadex.org/docs.html#operation/get-manga-id-feed>`_
|
||||
and `/user/follows/manga/feed <https://api.mangadex.org/docs.html#operation/get-user-follows-manga-feed>`_)
|
||||
|
||||
|
||||
extractor.mangadex.lang
|
||||
-----------------------
|
||||
Type
|
||||
@ -1424,6 +1437,16 @@ Description
|
||||
Provide ``artist``, ``author``, and ``group`` metadata fields.
|
||||
|
||||
|
||||
extractor.mangadex.ratings
|
||||
--------------------------
|
||||
Type
|
||||
``list`` of ``strings``
|
||||
Default
|
||||
``["safe", "suggestive", "erotica", "pornographic"]``
|
||||
Description
|
||||
List of acceptable content ratings for returned chapters.
|
||||
|
||||
|
||||
extractor.mastodon.reblogs
|
||||
--------------------------
|
||||
Type
|
||||
|
@ -209,22 +209,15 @@ class MangadexAPI():
|
||||
return self._call("/manga/" + uuid)["data"]
|
||||
|
||||
def manga_feed(self, uuid):
|
||||
config = self.extractor.config
|
||||
order = "desc" if config("chapter-reverse") else "asc"
|
||||
order = "desc" if self.extractor.config("chapter-reverse") else "asc"
|
||||
params = {
|
||||
"order[volume]" : order,
|
||||
"order[chapter]" : order,
|
||||
"translatedLanguage[]": config("lang"),
|
||||
"contentRating[]" : [
|
||||
"safe", "suggestive", "erotica", "pornographic"],
|
||||
"order[volume]" : order,
|
||||
"order[chapter]": order,
|
||||
}
|
||||
return self._pagination("/manga/" + uuid + "/feed", params)
|
||||
|
||||
def user_follows_manga_feed(self):
|
||||
params = {
|
||||
"order[publishAt]" : "desc",
|
||||
"translatedLanguage[]": self.extractor.config("lang"),
|
||||
}
|
||||
params = {"order[publishAt]": "desc"}
|
||||
return self._pagination("/user/follows/manga/feed", params)
|
||||
|
||||
def authenticate(self):
|
||||
@ -275,8 +268,20 @@ class MangadexAPI():
|
||||
def _pagination(self, endpoint, params=None):
|
||||
if params is None:
|
||||
params = {}
|
||||
|
||||
config = self.extractor.config
|
||||
ratings = config("ratings")
|
||||
if ratings is None:
|
||||
ratings = ("safe", "suggestive", "erotica", "pornographic")
|
||||
|
||||
params["contentRating[]"] = ratings
|
||||
params["translatedLanguage[]"] = config("lang")
|
||||
params["offset"] = 0
|
||||
|
||||
api_params = config("api-parameters")
|
||||
if api_params:
|
||||
params.update(api_params)
|
||||
|
||||
while True:
|
||||
data = self._call(endpoint, params)
|
||||
yield from data["data"]
|
||||
|
Loading…
Reference in New Issue
Block a user