Add first-party MangaPill source and distinct volume releases
This commit is contained in:
1 parent
a8df57f165
commit
a08e847932
20 files changed
+364
-34
No files matched your search
@@ -33,8 +33,20 @@ function mangaDexUrl(value, kind) {
|
||||
return url.href;
|
||||
}
|
||||
|
||||
function mangaPillUrl(value, kind) {
|
||||
const url = new URL(value);
|
||||
if (url.protocol !== 'https:' || url.username || url.password || url.port) throw new Error('Invalid MangaPill plugin URL');
|
||||
if (kind === 'chapter' && (url.hostname !== 'mangapill.com' || !/^\/chapters\/\d+-\d+\//.test(url.pathname))) {
|
||||
throw new Error('Unexpected MangaPill chapter URL');
|
||||
}
|
||||
if (kind === 'page' && (url.hostname !== 'cdn.readdetectiveconan.com' || !url.pathname.startsWith('/file/mangap/'))) {
|
||||
throw new Error('Unexpected MangaPill page host');
|
||||
}
|
||||
return url.href;
|
||||
}
|
||||
|
||||
function validate(plugin, operation, output) {
|
||||
if (!['weebcentral', 'mangadex'].includes(plugin) || !output || typeof output !== 'object' || Array.isArray(output)) {
|
||||
if (!['weebcentral', 'mangadex', 'mangapill'].includes(plugin) || !output || typeof output !== 'object' || Array.isArray(output)) {
|
||||
throw new Error('Invalid source plugin output');
|
||||
}
|
||||
if (plugin === 'mangadex') {
|
||||
@@ -51,6 +63,21 @@ function validate(plugin, operation, output) {
|
||||
} else throw new Error('Unknown source plugin operation');
|
||||
return output;
|
||||
}
|
||||
if (plugin === 'mangapill') {
|
||||
if (operation === 'catalog') {
|
||||
if (typeof output.title !== 'string' || !Array.isArray(output.chapters)
|
||||
|| !Number.isInteger(output.chapterLinks) || output.chapterLinks < 0) throw new Error('Invalid MangaPill catalog');
|
||||
for (const chapter of output.chapters) {
|
||||
if (typeof chapter?.id !== 'string' || !/^\d+-\d+$/.test(chapter.id)
|
||||
|| !/^\d+(?:\.\d+)?$/.test(chapter.number)) throw new Error('Invalid MangaPill chapter');
|
||||
mangaPillUrl(chapter.url, 'chapter');
|
||||
}
|
||||
} else if (operation === 'pages') {
|
||||
if (!Array.isArray(output.pages)) throw new Error('Invalid MangaPill pages');
|
||||
for (const page of output.pages) mangaPillUrl(page, 'page');
|
||||
} else throw new Error('Unknown MangaPill operation');
|
||||
return output;
|
||||
}
|
||||
if (operation === 'series') {
|
||||
if (typeof output.title !== 'string' || typeof output.listUrl !== 'string' && output.listUrl !== null) throw new Error('Invalid series parse');
|
||||
if (output.listUrl !== null) sourceUrl(output.listUrl, '/series/');
|
||||
|
||||
Reference in new issue
Block a user