[mangapark] add 'source' option (#3969)
This commit is contained in:
@@ -2110,6 +2110,24 @@ Description
|
|||||||
List of acceptable content ratings for returned chapters.
|
List of acceptable content ratings for returned chapters.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.mangapark.source
|
||||||
|
--------------------------
|
||||||
|
Type
|
||||||
|
* ``string``
|
||||||
|
* ``integer``
|
||||||
|
Example
|
||||||
|
* ``"koala:en"``
|
||||||
|
* ``15150116``
|
||||||
|
Description
|
||||||
|
Select chapter source and language for a manga.
|
||||||
|
|
||||||
|
| The general syntax is ``"<source name>:<ISO 639-1 language code>"``.
|
||||||
|
| Both are optional, meaning ``"koala"``, ``"koala:"``, ``":en"``,
|
||||||
|
or even just ``":"`` are possible as well.
|
||||||
|
|
||||||
|
Specifying the numeric ``ID`` of a source is also supported.
|
||||||
|
|
||||||
|
|
||||||
extractor.[mastodon].access-token
|
extractor.[mastodon].access-token
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"""Extractors for https://mangapark.net/"""
|
"""Extractors for https://mangapark.net/"""
|
||||||
|
|
||||||
from .common import ChapterExtractor, Extractor, Message
|
from .common import ChapterExtractor, Extractor, Message
|
||||||
from .. import text, util
|
from .. import text, util, exception
|
||||||
import re
|
import re
|
||||||
|
|
||||||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?mangapark\.(?:net|com|org|io|me)"
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?mangapark\.(?:net|com|org|io|me)"
|
||||||
@@ -99,7 +99,8 @@ class MangaparkChapterExtractor(MangaparkBase, ChapterExtractor):
|
|||||||
"title" : chapter["title"] or title or "",
|
"title" : chapter["title"] or title or "",
|
||||||
"lang" : chapter["lang"],
|
"lang" : chapter["lang"],
|
||||||
"language" : util.code_to_language(chapter["lang"]),
|
"language" : util.code_to_language(chapter["lang"]),
|
||||||
"source" : chapter["srcTitle"],
|
"source" : source["srcTitle"],
|
||||||
|
"source_id" : source["id"],
|
||||||
"date" : text.parse_timestamp(chapter["dateCreate"] // 1000),
|
"date" : text.parse_timestamp(chapter["dateCreate"] // 1000),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +128,21 @@ class MangaparkMangaExtractor(MangaparkBase, Extractor):
|
|||||||
"language": "English",
|
"language": "English",
|
||||||
"manga_id": 114972,
|
"manga_id": 114972,
|
||||||
"source": "re:Horse|Koala",
|
"source": "re:Horse|Koala",
|
||||||
|
"source_id": int,
|
||||||
"title": str,
|
"title": str,
|
||||||
"volume": int,
|
"volume": int,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
# 'source' option
|
||||||
|
("https://mangapark.net/title/114972-aria", {
|
||||||
|
"options": (("source", "koala"),),
|
||||||
|
"count": 70,
|
||||||
|
"pattern": MangaparkChapterExtractor.pattern,
|
||||||
|
"keyword": {
|
||||||
|
"source": "Koala",
|
||||||
|
"source_id": 15150116,
|
||||||
|
},
|
||||||
|
}),
|
||||||
("https://mangapark.com/title/114972-"),
|
("https://mangapark.com/title/114972-"),
|
||||||
("https://mangapark.com/title/114972"),
|
("https://mangapark.com/title/114972"),
|
||||||
("https://mangapark.com/title/114972-aria"),
|
("https://mangapark.com/title/114972-aria"),
|
||||||
@@ -168,9 +180,12 @@ class MangaparkMangaExtractor(MangaparkBase, Extractor):
|
|||||||
|
|
||||||
def chapters(self):
|
def chapters(self):
|
||||||
source = self.config("source")
|
source = self.config("source")
|
||||||
if source:
|
if not source:
|
||||||
return self.chapters_source(source)
|
return self.chapters_all()
|
||||||
return self.chapters_all()
|
|
||||||
|
source_id = self._select_source(source)
|
||||||
|
self.log.debug("Requesting chapters for source_id %s", source_id)
|
||||||
|
return self.chapters_source(source_id)
|
||||||
|
|
||||||
def chapters_all(self):
|
def chapters_all(self):
|
||||||
pnum = 0
|
pnum = 0
|
||||||
@@ -202,10 +217,35 @@ class MangaparkMangaExtractor(MangaparkBase, Extractor):
|
|||||||
variables = {
|
variables = {
|
||||||
"sourceId": source_id,
|
"sourceId": source_id,
|
||||||
}
|
}
|
||||||
|
chapters = self._request_graphql(
|
||||||
yield from self._request_graphql(
|
|
||||||
"get_content_source_chapterList", variables)
|
"get_content_source_chapterList", variables)
|
||||||
|
|
||||||
|
if self.config("chapter-reverse"):
|
||||||
|
chapters.reverse()
|
||||||
|
return chapters
|
||||||
|
|
||||||
|
def _select_source(self, source):
|
||||||
|
if isinstance(source, int):
|
||||||
|
return source
|
||||||
|
|
||||||
|
group, _, lang = source.partition(":")
|
||||||
|
group = group.lower()
|
||||||
|
|
||||||
|
variables = {
|
||||||
|
"comicId" : self.manga_id,
|
||||||
|
"dbStatuss" : ["normal"],
|
||||||
|
"haveChapter": True,
|
||||||
|
}
|
||||||
|
for item in self._request_graphql(
|
||||||
|
"get_content_comic_sources", variables):
|
||||||
|
data = item["data"]
|
||||||
|
if (not group or data["srcTitle"].lower() == group) and (
|
||||||
|
not lang or data["lang"] == lang):
|
||||||
|
return data["id"]
|
||||||
|
|
||||||
|
raise exception.StopExtraction(
|
||||||
|
"'%s' does not match any available source", source)
|
||||||
|
|
||||||
def _request_graphql(self, opname, variables):
|
def _request_graphql(self, opname, variables):
|
||||||
url = self.root + "/apo/"
|
url = self.root + "/apo/"
|
||||||
data = {
|
data = {
|
||||||
@@ -377,4 +417,54 @@ is_adm is_mod is_vip is_upr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
|
|
||||||
|
"get_content_comic_sources": """
|
||||||
|
query get_content_comic_sources($comicId: Int!, $dbStatuss: [String] = [], $userId: Int, $haveChapter: Boolean, $sortFor: String) {
|
||||||
|
get_content_comic_sources(
|
||||||
|
comicId: $comicId
|
||||||
|
dbStatuss: $dbStatuss
|
||||||
|
userId: $userId
|
||||||
|
haveChapter: $haveChapter
|
||||||
|
sortFor: $sortFor
|
||||||
|
) {
|
||||||
|
|
||||||
|
id
|
||||||
|
data{
|
||||||
|
|
||||||
|
id
|
||||||
|
|
||||||
|
dbStatus
|
||||||
|
isNormal
|
||||||
|
isHidden
|
||||||
|
isDeleted
|
||||||
|
|
||||||
|
lang name altNames authors artists
|
||||||
|
|
||||||
|
release
|
||||||
|
genres summary{code} extraInfo{code}
|
||||||
|
|
||||||
|
urlCover600
|
||||||
|
urlCover300
|
||||||
|
urlCoverOri
|
||||||
|
|
||||||
|
srcTitle srcColor
|
||||||
|
|
||||||
|
chapterCount
|
||||||
|
chapterNode_last {
|
||||||
|
id
|
||||||
|
data {
|
||||||
|
dateCreate datePublic dateModify
|
||||||
|
volume serial
|
||||||
|
dname title
|
||||||
|
urlPath
|
||||||
|
userNode {
|
||||||
|
id data {uniq name}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user