[copy_manga] support chapters group

This commit is contained in:
2025-02-14 17:53:38 +08:00
parent f716c8a039
commit 2d49a30d25
2 changed files with 89 additions and 42 deletions

View File

@@ -4,9 +4,9 @@ class CopyManga extends ComicSource {
key = "copy_manga" key = "copy_manga"
version = "1.0.5" version = "1.1.0"
minAppVersion = "1.0.0" minAppVersion = "1.2.1"
url = "https://cdn.jsdelivr.net/gh/venera-app/venera-configs@main/copy_manga.js" url = "https://cdn.jsdelivr.net/gh/venera-app/venera-configs@main/copy_manga.js"
@@ -496,9 +496,10 @@ class CopyManga extends ComicSource {
comic = { comic = {
loadInfo: async (id) => { loadInfo: async (id) => {
let getChapters = async (id) => { let getChapters = async (id, groups) => {
let fetchSingle = async (id, path) => {
let res = await Network.get( let res = await Network.get(
`https://api.copymanga.tv/api/v3/comic/${id}/group/default/chapters?limit=500&offset=0&platform=3`, `https://api.copymanga.tv/api/v3/comic/${id}/group/${path}/chapters?limit=500&offset=0&platform=3`,
this.headers this.headers
); );
if (res.status !== 200) { if (res.status !== 200) {
@@ -516,7 +517,7 @@ class CopyManga extends ComicSource {
let offset = 500; let offset = 500;
while (offset < maxChapter) { while (offset < maxChapter) {
res = await Network.get( res = await Network.get(
`https://api.copymanga.tv/api/v3/comic/chongjingchengweimofashaonv/group/default/chapters?limit=500&offset=${offset}&platform=3`, `https://api.copymanga.tv/api/v3/comic/chongjingchengweimofashaonv/group/${path}/chapters?limit=500&offset=${offset}&platform=3`,
this.headers this.headers
); );
if (res.status !== 200) { if (res.status !== 200) {
@@ -532,6 +533,35 @@ class CopyManga extends ComicSource {
} }
} }
return eps; return eps;
};
let keys = Object.keys(groups);
let result = {};
let futures = [];
for (let group of keys) {
let path = groups[group]["path_word"];
futures.push((async () => {
result[group] = await fetchSingle(id, path);
})());
}
await Promise.all(futures);
if (this.isAppVersionAfter("1.3.0")) {
// 支持多分组
let sortedResult = new Map();
for (let key of keys) {
let name = groups[key]["name"];
sortedResult.set(name, result[key]);
}
return sortedResult;
} else {
// 合并所有分组
let merged = new Map();
for (let key of keys) {
for (let [k, v] of result[key]) {
merged.set(k, v);
}
}
return merged;
}
} }
let getFavoriteStatus = async (id) => { let getFavoriteStatus = async (id) => {
@@ -547,7 +577,6 @@ class CopyManga extends ComicSource {
`https://api.copymanga.tv/api/v3/comic2/${id}?platform=3`, `https://api.copymanga.tv/api/v3/comic2/${id}?platform=3`,
this.headers this.headers
), ),
getChapters.bind(this)(id),
getFavoriteStatus.bind(this)(id) getFavoriteStatus.bind(this)(id)
]) ])
@@ -555,7 +584,8 @@ class CopyManga extends ComicSource {
throw `Invalid status code: ${res.status}`; throw `Invalid status code: ${res.status}`;
} }
let comicData = JSON.parse(results[0].body).results.comic; let data = JSON.parse(results[0].body).results;
let comicData = data.comic;
let title = comicData.name; let title = comicData.name;
let cover = comicData.cover; let cover = comicData.cover;
@@ -569,7 +599,7 @@ class CopyManga extends ComicSource {
let tags = comicData.theme.map(e => e?.name).filter(name => name !== undefined && name !== null); let tags = comicData.theme.map(e => e?.name).filter(name => name !== undefined && name !== null);
let updateTime = comicData.datetime_updated ? comicData.datetime_updated : ""; let updateTime = comicData.datetime_updated ? comicData.datetime_updated : "";
let description = comicData.brief; let description = comicData.brief;
let chapters = await getChapters(id, data.groups);
return { return {
title: title, title: title,
@@ -580,8 +610,8 @@ class CopyManga extends ComicSource {
"更新": [updateTime], "更新": [updateTime],
"标签": tags "标签": tags
}, },
chapters: results[1], chapters: chapters,
isFavorite: results[2], isFavorite: results[1],
subId: comicData.uuid subId: comicData.uuid
} }
}, },
@@ -756,4 +786,21 @@ class CopyManga extends ComicSource {
default: 'baseAPI' default: 'baseAPI'
} }
} }
/**
* Check if the current app version is after the target version
* @param target {string} target version
* @returns {boolean} true if the current app version is after the target version
*/
isAppVersionAfter(target) {
let current = APP.version
let targetArr = target.split('.')
let currentArr = current.split('.')
for (let i = 0; i < 3; i++) {
if (parseInt(currentArr[i]) < parseInt(targetArr[i])) {
return false
}
}
return true
}
} }

View File

@@ -3,7 +3,7 @@
"name": "拷贝漫画", "name": "拷贝漫画",
"fileName": "copy_manga.js", "fileName": "copy_manga.js",
"key": "copy_manga", "key": "copy_manga",
"version": "1.0.5" "version": "1.1.0"
}, },
{ {
"name": "Komiic", "name": "Komiic",