diff --git a/copy_manga.js b/copy_manga.js index 15ee780..93bd595 100644 --- a/copy_manga.js +++ b/copy_manga.js @@ -4,7 +4,7 @@ class CopyManga extends ComicSource { key = "copy_manga" - version = "1.0.3" + version = "1.0.4" minAppVersion = "1.0.0" @@ -32,7 +32,8 @@ class CopyManga extends ComicSource { "authorization": `Token${token}`, "platform": "3", } - this.author_path_word_dict = {} + // 用于储存 { 作者名 : 英文参数 } + this.author_path_word_dict = {} } /// account @@ -131,28 +132,85 @@ class CopyManga extends ComicSource { } ] + static category_param_dict = { + "全部": "", + "愛情": "aiqing", + "歡樂向": "huanlexiang", + "冒險": "maoxian", + "奇幻": "qihuan", + "百合": "baihe", + "校园": "xiaoyuan", + "科幻": "kehuan", + "東方": "dongfang", + "耽美": "danmei", + "生活": "shenghuo", + "格鬥": "gedou", + "轻小说": "qingxiaoshuo", + "悬疑": "xuanyi", + "其他": "qita", + "神鬼": "shengui", + "职场": "zhichang", + "TL": "teenslove", + "萌系": "mengxi", + "治愈": "zhiyu", + "長條": "changtiao", + "四格": "sige", + "节操": "jiecao", + "舰娘": "jianniang", + "竞技": "jingji", + "搞笑": "gaoxiao", + "伪娘": "weiniang", + "热血": "rexue", + "励志": "lizhi", + "性转换": "xingzhuanhuan", + "彩色": "COLOR", + "後宮": "hougong", + "美食": "meishi", + "侦探": "zhentan", + "AA": "aa", + "音乐舞蹈": "yinyuewudao", + "魔幻": "mohuan", + "战争": "zhanzheng", + "历史": "lishi", + "异世界": "yishijie", + "惊悚": "jingsong", + "机战": "jizhan", + "都市": "dushi", + "穿越": "chuanyue", + "恐怖": "kongbu", + "C100": "comiket100", + "重生": "chongsheng", + "C99": "comiket99", + "C101": "comiket101", + "C97": "comiket97", + "C96": "comiket96", + "生存": "shengcun", + "宅系": "zhaixi", + "武侠": "wuxia", + "C98": "C98", + "C95": "comiket95", + "FATE": "fate", + "转生": "zhuansheng", + "無修正": "Uncensored", + "仙侠": "xianxia", + "LoveLive": "loveLive" + } + category = { title: "拷贝漫画", parts: [ + { + name: "拷贝漫画", + type: "fixed", + categories: ["排行"], + categoryParams: ["ranking"], + itemType: "category" + }, { name: "主题", type: "fixed", - categories: [ "全部", - "愛情", "歡樂向", "冒險", "奇幻", "百合", "校园", "科幻", "東方", "耽美", "生活", - "格鬥", "轻小说", "悬疑", "其他", "神鬼", "职场", "TL", "萌系", "治愈", "長條", - "四格", "节操", "舰娘", "竞技", "搞笑", "伪娘", "热血", "励志", "性转换", "彩色", - "後宮", "美食", "侦探", "AA", "音乐舞蹈", "魔幻", "战争", "历史", "异世界", "惊悚", - "机战", "都市", "穿越", "恐怖", "C100", "重生", "C99", "C101", "C97", "C96", "生存", - "宅系", "武侠", "C98", "C95", "FATE", "转生", "無修正", "仙侠", "LoveLive" - ], - categoryParams: [ "", - "aiqing", "huanlexiang", "maoxian", "qihuan", "baihe", "xiaoyuan", "kehuan", "dongfang", "danmei", "shenghuo", - "gedou", "qingxiaoshuo", "xuanyi", "qita", "shengui", "zhichang", "teenslove", "mengxi", "zhiyu", "changtiao", - "sige", "jiecao", "jianniang", "jingji", "gaoxiao", "weiniang", "rexue", "lizhi", "xingzhuanhuan", "COLOR", - "hougong", "meishi", "zhentan", "aa", "yinyuewudao", "mohuan", "zhanzheng", "lishi", "yishijie", "jingsong", - "jizhan", "dushi", "chuanyue", "kongbu", "comiket100", "chongsheng", "comiket99", "comiket101", "comiket97", "comiket96", "shengcun", - "zhaixi", "wuxia", "C98", "comiket95", "fate", "zhuansheng", "Uncensored", "xianxia", "loveLive" - ], + categories: Object.keys(CopyManga.category_param_dict), + categoryParams: Object.values(CopyManga.category_param_dict), itemType: "category" } ] @@ -160,20 +218,23 @@ class CopyManga extends ComicSource { categoryComics = { load: async (category, param, options, page) => { - // 如果传入了category,则匹配其对应的param - if (category && !param) { - const categories = this.category.parts[0].categories; - const categoryParams = this.category.parts[0].categoryParams; - const index = categories.indexOf(category); - if (index !== -1) { - param = categoryParams[index]; - } else { - param = ""; + let category_url; + // 分类-排行 + if (category === "排行" || param === "ranking"){ + category_url = `https://api.copymanga.tv/api/v3/ranks?limit=21&offset=${(page - 1) * 21}&_update=true&type=1&audience_type=${options[0]}&date_type=${options[1]}` + }else{ + // 分类-主题 + if (category !== undefined && category !== null) { + // 若传入category,则转化为对应param + param = CopyManga.category_param_dict[category] || ""; } + options = options.map(e => e.replace("*", "-")) + category_url = `https://api.copymanga.tv/api/v3/comics?limit=21&offset=${(page - 1) * 21}&ordering=${options[1]}&theme=${param}&top=${options[0]}&platform=3` } - options = options.map(e => e.replace("*", "-")) + + let res = await Network.get( - `https://api.copymanga.tv/api/v3/comics?limit=21&offset=${(page - 1) * 21}&ordering=${options[1]}&theme=${param}&top=${options[0]}&platform=3`, + category_url, this.headers ) if (res.status !== 200) { @@ -183,6 +244,16 @@ class CopyManga extends ComicSource { let data = JSON.parse(res.body) function parseComic(comic) { + //判断是否是漫画排名格式 + let sort = null + let popular = 0 + let rise_sort = 0; + if (comic["sort"] !== null && comic["sort"] !== undefined){ + sort = comic["sort"] + rise_sort = comic["rise_sort"] + popular = comic["popular"] + } + if (comic["comic"] !== null && comic["comic"] !== undefined) { comic = comic["comic"] } @@ -191,18 +262,34 @@ class CopyManga extends ComicSource { tags = comic["theme"].map(t => t["name"]) } let author = null - + let author_num = 0 if (Array.isArray(comic["author"]) && comic["author"].length > 0) { author = comic["author"][0]["name"] + author_num = comic["author"].length } - return { - id: comic["path_word"], - title: comic["name"], - subTitle: author, - cover: comic["cover"], - tags: tags, - description: comic["datetime_updated"] + //如果是漫画排名,则描述为 排名(+升降箭头)+作者+人气 + if(sort !== null){ + return { + id: comic["path_word"], + title: comic["name"], + subTitle: author, + cover: comic["cover"], + tags: tags, + description:`${sort} ${rise_sort > 0 ? '▲' : rise_sort < 0 ? '▽' : '-'}\n` + + `${author_num > 1 ? `${author} 等${author_num}位` : author}\n` + + `🔥${(popular / 10000).toFixed(1)}W` + } + //正常情况的描述为更新时间 + }else{ + return { + id: comic["path_word"], + title: comic["name"], + subTitle: author, + cover: comic["cover"], + tags: tags, + description: comic["datetime_updated"] + } } } @@ -221,7 +308,7 @@ class CopyManga extends ComicSource { "finish-已完结" ], notShowWhen: null, - showWhen: null + showWhen: Object.keys(CopyManga.category_param_dict) }, { options: [ @@ -231,7 +318,25 @@ class CopyManga extends ComicSource { "popular-热度正序", ], notShowWhen: null, - showWhen: null + showWhen: Object.keys(CopyManga.category_param_dict) + }, + { + options: [ + "male-男频", + "female-女频" + ], + notShowWhen: null, + showWhen: ["排行"] + }, + { + options: [ + "day-上升最快", + "week-最近7天", + "month-最近30天", + "total-總榜單" + ], + notShowWhen: null, + showWhen: ["排行"] } ] } diff --git a/index.json b/index.json index f6bc586..e8fb09e 100644 --- a/index.json +++ b/index.json @@ -3,7 +3,7 @@ "name": "拷贝漫画", "fileName": "copy_manga.js", "key": "copy_manga", - "version": "1.0.3" + "version": "1.0.4" }, { "name": "Komiic",