diff --git a/src/function/isResponseAvailability.mjs b/src/function/isResponseAvailability.mjs index 3a8375c..2d8c362 100644 --- a/src/function/isResponseAvailability.mjs +++ b/src/function/isResponseAvailability.mjs @@ -1,4 +1,4 @@ -import { log } from "@nsnanocat/util"; +import { Console } from "@nsnanocat/util"; /** * Determine Response Availability @@ -7,10 +7,10 @@ import { log } from "@nsnanocat/util"; * @return {Boolean} is Available */ export default function isResponseAvailability(response = {}) { - log("☑️ Determine Response Availability", ""); - //log(`statusCode: ${response.statusCode}`, `headers: ${JSON.stringify(response.headers, null, 2)}`, ""); + Console.log("☑️ Determine Response Availability"); + //Console.debug(`statusCode: ${response.statusCode}`, `headers: ${JSON.stringify(response.headers, null, 2)}`); const FORMAT = (response?.headers?.["Content-Type"] ?? response?.headers?.["content-type"])?.split(";")?.[0]; - log("🚧 Determine Response Availability", `FORMAT: ${FORMAT}`, ""); + Console.debug(`FORMAT: ${FORMAT}`); let isAvailable = true; switch (response?.statusCode) { case 200: @@ -102,6 +102,6 @@ export default function isResponseAvailability(response = {}) { isAvailable = false; break; } - log("✅ Determine Response Availability", `isAvailable:${isAvailable}`, ""); + Console.log("✅ Determine Response Availability", `isAvailable:${isAvailable}`); return isAvailable; } diff --git a/src/function/setENV.mjs b/src/function/setENV.mjs index 7bc09dc..619fd53 100644 --- a/src/function/setENV.mjs +++ b/src/function/setENV.mjs @@ -1,4 +1,4 @@ -import { Lodash as _, getStorage, log } from "@nsnanocat/util"; +import { Console, getStorage, Lodash as _ } from "@nsnanocat/util"; /** * Set Environment Variables @@ -10,17 +10,18 @@ import { Lodash as _, getStorage, log } from "@nsnanocat/util"; * @return {Object} { Settings, Caches, Configs } */ export default function setENV(name, platforms, database) { - log("☑️ Set Environment Variables", ""); + Console.log("☑️ Set Environment Variables"); const { Settings, Caches, Configs } = getStorage(name, platforms, database); /***************** Settings *****************/ if (!Array.isArray(Settings?.Locales)) Settings.Locales = (Settings.Locales) ? [Settings.Locales] : []; // 只有一个选项时,无逗号分隔 - log(`✅ Set Environment Variables, Settings: ${typeof Settings}, Settings内容: ${JSON.stringify(Settings)}`, ""); + Console.debug(`Settings: ${typeof Settings}, Settings内容: ${JSON.stringify(Settings)}`); /***************** Caches *****************/ if (!Array.isArray(Caches?.ss)) Caches.ss = []; if (!Array.isArray(Caches?.ep)) Caches.ep = []; - //log(`✅ Set Environment Variables, Caches: ${typeof Caches}, Caches内容: ${JSON.stringify(Caches)}`, ""); + //Console.debug(`Caches: ${typeof Caches}, Caches内容: ${JSON.stringify(Caches)}`); Caches.ss = new Map(Caches?.ss ?? []); // Array转Map Caches.ep = new Map(Caches?.ep ?? []); // Array转Map /***************** Configs *****************/ + Console.log("✅ Set Environment Variables"); return { Settings, Caches, Configs }; }; diff --git a/src/request.dev.js b/src/request.dev.js index bf4a0e0..d868414 100644 --- a/src/request.dev.js +++ b/src/request.dev.js @@ -1,4 +1,4 @@ -import { $app, Lodash as _, Storage, fetch, notification, log, logError, wait, done, gRPC } from "@nsnanocat/util"; +import { $app, Console, done, fetch, gRPC, Lodash as _, notification, Storage, wait } from "@nsnanocat/util"; import { URL } from "@nsnanocat/url"; import database from "./function/database.mjs"; import setENV from "./function/setENV.mjs"; @@ -13,13 +13,13 @@ let $response = undefined; /***************** Processing *****************/ // 解构URL const url = new URL($request.url); -log(`⚠ url: ${url.toJSON()}`, ""); +Console.info(`url: ${url.toJSON()}`); // 获取连接参数 const PATHs = url.pathname.split("/").filter(Boolean); -log(`⚠ PATHs: ${PATHs}`, ""); +Console.info(`PATHs: ${PATHs}`); // 解析格式 const FORMAT = ($request.headers?.["Content-Type"] ?? $request.headers?.["content-type"])?.split(";")?.[0]; -log(`⚠ FORMAT: ${FORMAT}`, ""); +Console.info(`FORMAT: ${FORMAT}`); !(async () => { /** * 设置 @@ -60,7 +60,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/vnd.apple.mpegurl": case "audio/mpegurl": //body = M3U8.parse($request.body); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$request.body = M3U8.stringify(body); break; case "text/xml": @@ -70,19 +70,19 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/plist": case "application/x-plist": //body = XML.parse($request.body); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$request.body = XML.stringify(body); break; case "text/vtt": case "application/vtt": //body = VTT.parse($request.body); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$request.body = VTT.stringify(body); break; case "text/json": case "application/json": //body = JSON.parse($request.body ?? "{}"); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$request.body = JSON.stringify(body); break; case "application/protobuf": @@ -91,9 +91,9 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/grpc": case "application/grpc+proto": case "application/octet-stream": { - //log(`🚧 $request.body: ${JSON.stringify($request.body)}`, ""); + //Console.debug(`$request.body: ${JSON.stringify($request.body)}`); let rawBody = $app === "Quantumult X" ? new Uint8Array($request.bodyBytes ?? []) : ($request.body ?? new Uint8Array()); - //log(`🚧 isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`, ""); + //Console.debug(`isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`); switch (FORMAT) { case "application/protobuf": case "application/x-protobuf": @@ -113,7 +113,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); switch (PATHs?.[1]) { case "View": // 播放页 body = ViewReq.fromBinary(rawBody); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); rawBody = ViewReq.toBinary(body); // 判断线路 infoGroup.seasonId = Number.parseInt(body?.extraContent?.season_id, 10) || infoGroup.seasonId; @@ -128,7 +128,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); switch (PATHs?.[1]) { case "PlayViewUnite": // 播放地址 body = PlayViewUniteReq.fromBinary(rawBody); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); body.vod.forceHost = Settings?.ForceHost ?? 1; rawBody = PlayViewUniteReq.toBinary(body); // 判断线路 @@ -152,7 +152,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); switch (PATHs?.[1]) { case "PlayView": // 播放地址 body = PlayViewReq.fromBinary(rawBody); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); body.forceHost = Settings?.ForceHost ?? 1; rawBody = PlayViewReq.toBinary(body); // 判断线路 @@ -182,19 +182,19 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); switch (PATHs?.[1]) { case "SearchAll": // 全部结果(综合) body = SearchAllRequest.fromBinary(rawBody); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); ({ keyword: infoGroup.keyword, locale: infoGroup.locale } = checkKeyword(body?.keyword)); body.keyword = infoGroup.keyword; - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); rawBody = SearchAllRequest.toBinary(body); break; case "SearchByType": { // 分类结果(番剧、用户、影视、专栏) body = SearchByTypeRequest.fromBinary(rawBody); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); ({ keyword: infoGroup.keyword, locale: infoGroup.locale } = checkKeyword(body?.keyword)); body.keyword = infoGroup.keyword; - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); rawBody = SearchByTypeRequest.toBinary(body); break; } @@ -352,8 +352,8 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); } //url.searchParams.set("type", infoGroup.type); $request.url = url.toString(); - log("🚧 调试信息", `$request.url: ${$request.url}`, ""); - log(`🚧 信息组, infoGroup: ${JSON.stringify(infoGroup)}`, ""); + Console.debug(`$request.url: ${$request.url}`); + Console.debug(`infoGroup: ${JSON.stringify(infoGroup)}`); // 请求策略 switch (url.pathname) { case "/bilibili.app.viewunite.v1.View/View": // 番剧页面-内容-app @@ -368,7 +368,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; case "UGC": default: - log("⚠ 不是 PGC, 跳过", ""); + Console.info("不是 PGC, 跳过"); break; } switch ($app) { @@ -399,7 +399,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; case "UGC": default: - log("⚠ 不是 PGC, 跳过", ""); + Console.info("不是 PGC, 跳过"); break; } break; @@ -412,11 +412,11 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } })() - .catch(e => logError(e)) + .catch(e => Console.error(e)) .finally(() => { switch (typeof $response) { case "object": // 有构造回复数据,返回构造的回复数据 - //log("🚧 finally", `echo $response: ${JSON.stringify($response, null, 2)}`, ""); + //Console.debug("finally", `echo $response: ${JSON.stringify($response, null, 2)}`); if ($response.headers?.["Content-Encoding"]) $response.headers["Content-Encoding"] = "identity"; if ($response.headers?.["content-encoding"]) $response.headers["content-encoding"] = "identity"; switch ($app) { @@ -433,11 +433,11 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); } break; case "undefined": // 无构造回复数据,发送修改的请求数据 - //log("🚧 finally", `$request: ${JSON.stringify($request, null, 2)}`, ""); + //Console.debug("finally", `$request: ${JSON.stringify($request, null, 2)}`); done($request); break; default: - logError(`不合法的 $response 类型: ${typeof $response}`, ""); + Console.error(`不合法的 $response 类型: ${typeof $response}`); done(); break; } @@ -454,12 +454,12 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); * @return {Promise} modified request */ async function availableFetch(request = {}, proxies = {}, locales = [], availableLocales = []) { - log("☑️ availableFetch", `availableLocales: ${availableLocales}`, ""); + Console.log("☑️ availableFetch", `availableLocales: ${availableLocales}`); availableLocales = availableLocales.filter(locale => locales.includes(locale)); let locale = ""; locale = availableLocales[Math.floor(Math.random() * availableLocales.length)]; request.policy = proxies[locale]; - log("✅ availableFetch", `locale: ${locale}`, ""); + Console.log("✅ availableFetch", `locale: ${locale}`); return request; } /** @@ -471,7 +471,7 @@ async function availableFetch(request = {}, proxies = {}, locales = [], availabl * @return {Promise<{request, response}>} modified { request, response } */ async function mutiFetch(request = {}, proxies = {}, locales = []) { - log("☑️ mutiFetch", `locales: ${locales}`, ""); + Console.log("☑️ mutiFetch", `locales: ${locales}`); const responses = {}; await Promise.allSettled( locales.map(async locale => { @@ -481,15 +481,15 @@ async function mutiFetch(request = {}, proxies = {}, locales = []) { }), ); for (const locale in responses) { - //log("🚧 mutiFetch", `locale: ${locale}`); + //Console.debug("mutiFetch", `locale: ${locale}`); if (!isResponseAvailability(responses[locale])) delete responses[locale]; } const availableLocales = Object.keys(responses); - log("☑️ mutiFetch", `availableLocales: ${availableLocales}`, ""); + Console.log("☑️ mutiFetch", `availableLocales: ${availableLocales}`); const locale = availableLocales[Math.floor(Math.random() * availableLocales.length)]; request.policy = proxies[locale]; const response = responses[locale]; - log("✅ mutiFetch", `locale: ${locale}`, ""); + Console.log("✅ mutiFetch", `locale: ${locale}`); return { request, response }; } @@ -501,9 +501,9 @@ async function mutiFetch(request = {}, proxies = {}, locales = []) { * @return {Object} { keyword, locale } */ function checkKeyword(keyword = "", delimiter = " ") { - log("⚠ Check Search Keyword", `Original Keyword: ${keyword}`, ""); + Console.log("☑️ Check Search Keyword", `Original Keyword: ${keyword}`); const keywords = keyword?.split(delimiter); - log("🚧 Check Search Keyword", `keywords: ${keywords}`, ""); + Console.debug("Check Search Keyword", `keywords: ${keywords}`); let locale = undefined; switch ([...keywords].pop()) { case "CN": @@ -590,6 +590,6 @@ function checkKeyword(keyword = "", delimiter = " ") { keyword = keywords.join(delimiter); break; } - log("🎉 Check Search Keyword", `Keyword: ${keyword}, Locale: ${locale}`, ""); + Console.log("✅ Check Search Keyword", `Keyword: ${keyword}, Locale: ${locale}`); return { keyword, locale }; } diff --git a/src/request.js b/src/request.js index c9355e6..0f44919 100644 --- a/src/request.js +++ b/src/request.js @@ -1,4 +1,4 @@ -import { $app, Lodash as _, Storage, fetch, notification, log, logError, wait, done, gRPC } from "@nsnanocat/util"; +import { $app, Console, done, fetch, gRPC, Lodash as _, notification, Storage, wait } from "@nsnanocat/util"; import { URL } from "@nsnanocat/url"; import database from "./function/database.mjs"; import setENV from "./function/setENV.mjs"; @@ -10,16 +10,17 @@ import { PlayViewReq } from "./protobuf/bilibili/pgc/gateway/player/v2/playurl.j import { SearchAllRequest, SearchByTypeRequest } from "./protobuf/bilibili/polymer/app/search/v1/search.js"; // 构造回复数据 let $response = undefined; +Console.debug = () => {}; /***************** Processing *****************/ // 解构URL const url = new URL($request.url); -log(`⚠ url: ${url.toJSON()}`, ""); +Console.info(`url: ${url.toJSON()}`); // 获取连接参数 const PATHs = url.pathname.split("/").filter(Boolean); -log(`⚠ PATHs: ${PATHs}`, ""); +Console.info(`PATHs: ${PATHs}`); // 解析格式 const FORMAT = ($request.headers?.["Content-Type"] ?? $request.headers?.["content-type"])?.split(";")?.[0]; -log(`⚠ FORMAT: ${FORMAT}`, ""); +Console.info(`FORMAT: ${FORMAT}`); !(async () => { /** * 设置 @@ -79,9 +80,9 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/grpc": case "application/grpc+proto": case "application/octet-stream": { - //log(`🚧 $request.body: ${JSON.stringify($request.body)}`, ""); + //Console.debug(`$request.body: ${JSON.stringify($request.body)}`); let rawBody = $app === "Quantumult X" ? new Uint8Array($request.bodyBytes ?? []) : ($request.body ?? new Uint8Array()); - //log(`🚧 isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`, ""); + //Console.debug(`isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`); switch (FORMAT) { case "application/protobuf": case "application/x-protobuf": @@ -326,7 +327,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } $request.url = url.toString(); - log(`🚧 信息组, infoGroup: ${JSON.stringify(infoGroup)}`, ""); + Console.debug(`infoGroup: ${JSON.stringify(infoGroup)}`); // 请求策略 switch (url.pathname) { case "/bilibili.app.viewunite.v1.View/View": // 番剧页面-内容-app @@ -341,7 +342,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; case "UGC": default: - log("⚠ 不是 PGC, 跳过", ""); + Console.info("不是 PGC, 跳过"); break; } switch ($app) { @@ -372,7 +373,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; case "UGC": default: - log("⚠ 不是 PGC, 跳过", ""); + Console.info("不是 PGC, 跳过"); break; } break; @@ -385,7 +386,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } })() - .catch(e => logError(e)) + .catch(e => Console.error(e)) .finally(() => { switch (typeof $response) { case "object": // 有构造回复数据,返回构造的回复数据 @@ -408,7 +409,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); done($request); break; default: - logError(`不合法的 $response 类型: ${typeof $response}`, ""); + Console.error(`不合法的 $response 类型: ${typeof $response}`); done(); break; } @@ -425,12 +426,12 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); * @return {Promise} modified request */ async function availableFetch(request = {}, proxies = {}, locales = [], availableLocales = []) { - log("☑️ availableFetch", `availableLocales: ${availableLocales}`, ""); + Console.log("☑️ availableFetch", `availableLocales: ${availableLocales}`); availableLocales = availableLocales.filter(locale => locales.includes(locale)); let locale = ""; locale = availableLocales[Math.floor(Math.random() * availableLocales.length)]; request.policy = proxies[locale]; - log("✅ availableFetch", `locale: ${locale}`, ""); + Console.log("✅ availableFetch", `locale: ${locale}`); return request; } /** @@ -442,7 +443,7 @@ async function availableFetch(request = {}, proxies = {}, locales = [], availabl * @return {Promise<{request, response}>} modified { request, response } */ async function mutiFetch(request = {}, proxies = {}, locales = []) { - log("☑️ mutiFetch", `locales: ${locales}`, ""); + Console.log("☑️ mutiFetch", `locales: ${locales}`); const responses = {}; await Promise.allSettled( locales.map(async locale => { @@ -455,11 +456,11 @@ async function mutiFetch(request = {}, proxies = {}, locales = []) { if (!isResponseAvailability(responses[locale])) delete responses[locale]; } const availableLocales = Object.keys(responses); - log("☑️ mutiFetch", `availableLocales: ${availableLocales}`, ""); + Console.log("☑️ mutiFetch", `availableLocales: ${availableLocales}`); const locale = availableLocales[Math.floor(Math.random() * availableLocales.length)]; request.policy = proxies[locale]; const response = responses[locale]; - log("✅ mutiFetch", `locale: ${locale}`, ""); + Console.log("✅ mutiFetch", `locale: ${locale}`); return { request, response }; } @@ -471,9 +472,9 @@ async function mutiFetch(request = {}, proxies = {}, locales = []) { * @return {Object} { keyword, locale } */ function checkKeyword(keyword = "", delimiter = " ") { - log("⚠ Check Search Keyword", `Original Keyword: ${keyword}`, ""); + Console.log("☑️ Check Search Keyword", `Original Keyword: ${keyword}`); const keywords = keyword?.split(delimiter); - log("🚧 Check Search Keyword", `keywords: ${keywords}`, ""); + Console.debug("Check Search Keyword", `keywords: ${keywords}`); let locale = undefined; switch ([...keywords].pop()) { case "CN": @@ -560,6 +561,6 @@ function checkKeyword(keyword = "", delimiter = " ") { keyword = keywords.join(delimiter); break; } - log("🎉 Check Search Keyword", `Keyword: ${keyword}, Locale: ${locale}`, ""); + Console.log("✅ Check Search Keyword", `Keyword: ${keyword}, Locale: ${locale}`); return { keyword, locale }; } diff --git a/src/response.dev.js b/src/response.dev.js index e0f26e9..47659e9 100644 --- a/src/response.dev.js +++ b/src/response.dev.js @@ -1,4 +1,4 @@ -import { $app, Lodash as _, Storage, fetch, notification, log, logError, wait, done, gRPC } from "@nsnanocat/util"; +import { $app, Console, done, fetch, gRPC, Lodash as _, notification, Storage, wait } from "@nsnanocat/util"; import { URL } from "@nsnanocat/url"; import database from "./function/database.mjs"; import setENV from "./function/setENV.mjs"; @@ -8,13 +8,13 @@ import { ViewPgcAny } from "./protobuf/bilibili/app/viewunite/pgcanymodel.js"; /***************** Processing *****************/ // 解构URL const url = new URL($request.url); -log(`⚠ url: ${url.toJSON()}`, ""); +Console.info(`url: ${url.toJSON()}`); // 获取连接参数 const PATHs = url.pathname.split("/").filter(Boolean); -log(`⚠ PATHs: ${PATHs}`, ""); +Console.info(`PATHs: ${PATHs}`); // 解析格式 const FORMAT = ($response.headers?.["Content-Type"] ?? $response.headers?.["content-type"])?.split(";")?.[0]; -log(`⚠ FORMAT: ${FORMAT}`, ""); +Console.info(`FORMAT: ${FORMAT}`); !(async () => { /** * 设置 @@ -48,7 +48,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/vnd.apple.mpegurl": case "audio/mpegurl": //body = M3U8.parse($response.body); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$response.body = M3U8.stringify(body); break; case "text/xml": @@ -58,13 +58,13 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/plist": case "application/x-plist": //body = XML.parse($response.body); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$response.body = XML.stringify(body); break; case "text/vtt": case "application/vtt": //body = VTT.parse($response.body); - //log(`🚧 body: ${JSON.stringify(body)}`, ""); + //Console.debug(`body: ${JSON.stringify(body)}`); //$response.body = VTT.stringify(body); break; case "text/json": @@ -168,9 +168,9 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/grpc": case "application/grpc+proto": case "application/octet-stream": { - //log(`🚧 $response.body: ${JSON.stringify($response.body)}`, ""); + //Console.debug(`$response.body: ${JSON.stringify($response.body)}`); let rawBody = $app === "Quantumult X" ? new Uint8Array($response.bodyBytes ?? []) : ($response.body ?? new Uint8Array()); - //log(`🚧 isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`, ""); + //Console.debug(`isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`); switch (FORMAT) { case "application/protobuf": case "application/x-protobuf": @@ -190,7 +190,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); switch (PATHs?.[1]) { case "View": // 播放页 body = ViewReply.fromBinary(rawBody); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); infoGroup.seasonTitle = body?.arc?.title ?? body?.supplement?.ogv_data?.title ?? infoGroup.seasonTitle; infoGroup.seasonId = Number.parseInt(body?.report?.season_id, 10) || body?.supplement?.ogv_data?.season_id || infoGroup.seasonId; infoGroup.mId = Number.parseInt(body?.report?.up_mid, 10) || body?.owner?.mid || infoGroup.mId; @@ -200,7 +200,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "type.googleapis.com/bilibili.app.viewunite.pgcanymodel.ViewPgcAny": { infoGroup.type = "PGC"; const PgcBody = ViewPgcAny.fromBinary(body.supplement.value); - log(`🚧 PgcBody: ${JSON.stringify(PgcBody)}`, ""); + Console.debug(`PgcBody: ${JSON.stringify(PgcBody)}`); infoGroup.seasonTitle = PgcBody?.ogvData?.title || infoGroup.seasonTitle; infoGroup.seasonId = PgcBody?.ogvData?.seasonId || infoGroup.seasonId; _.set(PgcBody, "ogvData.rights.allowDownload", 1); @@ -208,7 +208,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); _.set(PgcBody, "ogvData.rights.allowBp", 1); _.set(PgcBody, "ogvData.rights.areaLimit", 0); _.set(PgcBody, "ogvData.rights.banAreaShow", 1); - log(`🚧 PgcBody: ${JSON.stringify(PgcBody)}`, ""); + Console.debug(`PgcBody: ${JSON.stringify(PgcBody)}`); body.supplement.value = ViewPgcAny.toBinary(PgcBody); break; } @@ -220,7 +220,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); } infoGroup.locales = detectLocales(infoGroup); setCache(infoGroup, [], Caches); - log(`🚧 body: ${JSON.stringify(body)}`, ""); + Console.debug(`body: ${JSON.stringify(body)}`); rawBody = ViewReply.toBinary(body); break; } @@ -277,9 +277,9 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } } - log(`🚧 信息组, infoGroup: ${JSON.stringify(infoGroup)}`, ""); + Console.debug(`infoGroup: ${JSON.stringify(infoGroup)}`); })() - .catch(e => logError(e)) + .catch(e => Console.error(e)) .finally(() => done($response)); /***************** Function *****************/ @@ -290,7 +290,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); * @return {Array} Episodes Datas */ function getEpisodes(modules = []) { - log("⚠ Get Episodes", ""); + Console.log("☑️ Get Episodes"); const episodes = modules.flatMap(module => { switch (module?.style) { case "positive": // 选集 @@ -306,13 +306,13 @@ function getEpisodes(modules = []) { }); /* let epids = episodes.map(episode => { - log(`episode.id: ${episode?.id}`); - log(`episode: ${JSON.stringify(episode)}`); + Console.debug(`episode.id: ${episode?.id}`); + Console.debug(`episode: ${JSON.stringify(episode)}`); return episode?.id }); */ - log("🎉 Get Episodes", ""); - //log(`🚧 Get Episodes`, `modules.episodes: ${JSON.stringify(episodes)}`, ""); + Console.log("✅ Get Episodes"); + //Console.debug(`Get Episodes`, `modules.episodes: ${JSON.stringify(episodes)}`); return episodes; } @@ -323,7 +323,7 @@ function getEpisodes(modules = []) { * @return {Array} Modules Datas */ function setModules(modules = []) { - log("⚠ Set Episodes", ""); + Console.log("☑️ Set Episodes"); modules = modules.map(module => { switch (module?.style) { case "positive": // 选集 @@ -338,8 +338,8 @@ function setModules(modules = []) { } return module; }); - log("🎉 Set Episodes", ""); - //log(`🚧 Set Episodes`, `modules: ${JSON.stringify(modules)}`, ""); + Console.log("✅ Set Episodes"); + //Console.debug(`Set Episodes`, `modules: ${JSON.stringify(modules)}`); return modules; } @@ -350,7 +350,7 @@ function setModules(modules = []) { * @return {Array} Modules Datas */ function setEpisodes(episodes = []) { - log("⚠ Set Episodes", ""); + Console.log("☑️ Set Episodes"); episodes = episodes.map(episode => { if (episode?.badge_info?.text === "受限") { episode.badge_info.text = ""; @@ -365,8 +365,8 @@ function setEpisodes(episodes = []) { } return episode; }); - log("🎉 Set Episodes", ""); - //log(`🚧 Set Episodes`, `episodes: ${JSON.stringify(episodes)}`, ""); + Console.log("✅ Set Episodes"); + //Console.debug(`Set Episodes`, `episodes: ${JSON.stringify(episodes)}`); return episodes; } @@ -377,7 +377,7 @@ function setEpisodes(episodes = []) { * @return {String} locales */ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined, epId: undefined, mId: undefined, evaluate: undefined }) { - log("☑️ Detect Locales", `seasonTitle: ${infoGroup.seasonTitle}, seasonId: ${infoGroup.seasonId}, epId: ${infoGroup.epId}, mId: ${infoGroup.mId}`, ""); + Console.log("☑️ Detect Locales", `seasonTitle: ${infoGroup.seasonTitle}`, `seasonId: ${infoGroup.seasonId}`, `epId: ${infoGroup.epId}`, `mId: ${infoGroup.mId}`); switch (infoGroup.seasonTitle) { case undefined: case null: @@ -387,15 +387,15 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined infoGroup.locales = detectSeasonTitle(infoGroup.seasonTitle); break; } - log(`✅ Detect Locales, locales: ${infoGroup.locales}`, ""); + Console.log("✅ Detect Locales", `locales: ${infoGroup.locales}`); return infoGroup.locales; /***************** Functions *****************/ function detectSeasonTitle(seasonTitle) { - log("☑️ Detect Season Title", ""); + Console.log("☑️ Detect Season Title"); let locales = []; - log([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]); - //log([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]?.pop()); - //log([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]?.pop()?.[1]); + Console.debug([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]); + //Console.debug([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]?.pop()); + //Console.debug([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]?.pop()?.[1]); switch ([...seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]?.pop()?.[1]) { case "僅限港澳台地區": case "限僅港澳台地區": @@ -424,12 +424,12 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined locales = detectMId(infoGroup.mId); break; } - log(`✅ Detect Season Title, locales: ${locales}`, ""); + Console.log("✅ Detect Season Title", `locales: ${locales}`); return locales; } function detectMId(mId) { - log("☑️ Detect mId", ""); + Console.log("☑️ Detect mId"); let locales = []; switch (mId) { case 928123: // 哔哩哔哩番剧 @@ -453,12 +453,12 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined locales = detectTraditional(infoGroup.seasonTitle, infoGroup.evaluate); break; } - log(`✅ Detect mId, locales: ${locales}`, ""); + Console.log("✅ Detect mId", `locales: ${locales}`); return locales; } function detectTraditional(seasonTitle, evaluate) { - log("☑️ Detect Traditional", ""); + Console.log("☑️ Detect Traditional"); let locales = []; if (isTraditional(seasonTitle) > 0) { // Traditional Chinese @@ -470,7 +470,7 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined // Simplified Chinese locales = ["CHN"]; } - log(`✅ Detect Traditional, locales: ${locales}`, ""); + Console.log("✅ Detect Traditional", `locales: ${locales}`); return locales; /***************** Functions *****************/ /** @@ -480,15 +480,15 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined * @return {Number} Traditional Chinese Count */ function isTraditional(strings = [""]) { - log("☑️ is the Strings Traditional Chinese?", ""); + Console.log("☑️ is the Strings Traditional Chinese?"); const reg = /[䊷䋙䝼䰾䲁丟並乾亂亞佇馀併來侖侶俁係俔俠倀倆倈倉個們倫偉側偵偽傑傖傘備傭傯傳傴債傷傾僂僅僉僑僕僞僥僨價儀儂億儈儉儐儔儕儘償優儲儷儺儻儼兌兒兗內兩冊冪凈凍凜凱別刪剄則剋剎剗剛剝剮剴創劃劇劉劊劌劍劑勁動務勛勝勞勢勩勱勵勸勻匭匯匱區協卻厙厠厭厲厴參叄叢吒吳吶呂咼員唄唚問啓啞啟啢喎喚喪喬單喲嗆嗇嗊嗎嗚嗩嗶嘆嘍嘔嘖嘗嘜嘩嘮嘯嘰嘵嘸嘽噓噝噠噥噦噯噲噴噸噹嚀嚇嚌嚕嚙嚦嚨嚲嚳嚴嚶囀囁囂囅囈囑囪圇國圍園圓圖團垵埡埰執堅堊堖堝堯報場塊塋塏塒塗塢塤塵塹墊墜墮墳墻墾壇壈壋壓壘壙壚壞壟壠壢壩壯壺壼壽夠夢夾奐奧奩奪奬奮奼妝姍姦娛婁婦婭媧媯媼媽嫗嫵嫻嫿嬀嬈嬋嬌嬙嬡嬤嬪嬰嬸孌孫學孿宮寢實寧審寫寬寵寶將專尋對導尷屆屍屓屜屢層屨屬岡峴島峽崍崗崢崬嵐嶁嶄嶇嶔嶗嶠嶢嶧嶮嶴嶸嶺嶼巋巒巔巰帥師帳帶幀幃幗幘幟幣幫幬幹幺幾庫廁廂廄廈廚廝廟廠廡廢廣廩廬廳弒弳張強彈彌彎彙彞彥後徑從徠復徵徹恆恥悅悞悵悶惡惱惲惻愛愜愨愴愷愾慄態慍慘慚慟慣慤慪慫慮慳慶憂憊憐憑憒憚憤憫憮憲憶懇應懌懍懟懣懨懲懶懷懸懺懼懾戀戇戔戧戩戰戱戲戶拋拾挩挾捨捫掃掄掗掙掛採揀揚換揮損搖搗搵搶摑摜摟摯摳摶摻撈撏撐撓撝撟撣撥撫撲撳撻撾撿擁擄擇擊擋擓擔據擠擬擯擰擱擲擴擷擺擻擼擾攄攆攏攔攖攙攛攜攝攢攣攤攪攬敗敘敵數斂斃斕斬斷時晉晝暈暉暘暢暫曄曆曇曉曏曖曠曨曬書會朧東杴桿梔梘條梟梲棄棖棗棟棧棲棶椏楊楓楨業極榪榮榲榿構槍槤槧槨槳樁樂樅樓標樞樣樸樹樺橈橋機橢橫檁檉檔檜檟檢檣檮檯檳檸檻櫃櫓櫚櫛櫝櫞櫟櫥櫧櫨櫪櫫櫬櫱櫳櫸櫻欄權欏欒欖欞欽歐歟歡歲歷歸歿殘殞殤殨殫殮殯殲殺殻殼毀毆毿氂氈氌氣氫氬氳決沒沖況洶浹涇涼淚淥淪淵淶淺渙減渦測渾湊湞湯溈準溝溫滄滅滌滎滬滯滲滷滸滻滾滿漁漚漢漣漬漲漵漸漿潁潑潔潙潛潤潯潰潷潿澀澆澇澗澠澤澦澩澮澱濁濃濕濘濟濤濫濰濱濺濼濾瀅瀆瀉瀏瀕瀘瀝瀟瀠瀦瀧瀨瀲瀾灃灄灑灕灘灝灠灣灤灧災為烏烴無煉煒煙煢煥煩煬熅熒熗熱熲熾燁燈燉燒燙燜營燦燭燴燼燾爍爐爛爭爲爺爾牆牘牽犖犢犧狀狹狽猙猶猻獁獄獅獎獨獪獫獮獰獲獵獷獸獺獻獼玀現琺琿瑋瑒瑣瑤瑩瑪瑲璉璣璦璫環璽瓊瓏瓔瓚甌產産畝畢異畵當疇疊痙痾瘂瘋瘍瘓瘞瘡瘧瘮瘲瘺瘻療癆癇癉癘癟癢癤癥癧癩癬癭癮癰癱癲發皚皰皸皺盜盞盡監盤盧眥眾睏睜睞瞘瞜瞞瞶瞼矓矚矯硜硤硨硯碩碭碸確碼磑磚磣磧磯磽礆礎礙礦礪礫礬礱祿禍禎禕禡禦禪禮禰禱禿秈稅稈稟種稱穀穌積穎穠穡穢穩穫穭窩窪窮窯窵窶窺竄竅竇竈竊竪競筆筍筧筴箋箏節範築篋篔篤篩篳簀簍簞簡簣簫簹簽簾籃籌籙籜籟籠籩籪籬籮粵糝糞糧糲糴糶糹糾紀紂約紅紆紇紈紉紋納紐紓純紕紖紗紘紙級紛紜紝紡紬細紱紲紳紵紹紺紼紿絀終組絅絆絎結絕絛絝絞絡絢給絨絰統絲絳絶絹綁綃綆綈綉綌綏經綜綞綠綢綣綫綬維綯綰綱網綳綴綸綹綺綻綽綾綿緄緇緊緋緑緒緓緔緗緘緙線緝緞締緡緣緦編緩緬緯緱緲練緶緹緻縈縉縊縋縐縑縕縗縛縝縞縟縣縧縫縭縮縱縲縳縵縶縷縹總績繃繅繆繒織繕繚繞繡繢繩繪繫繭繮繯繰繳繸繹繼繽繾纈纊續纍纏纓纖纘纜缽罈罌罰罵罷羅羆羈羋羥義習翹耬耮聖聞聯聰聲聳聵聶職聹聽聾肅脅脈脛脫脹腎腖腡腦腫腳腸膃膚膠膩膽膾膿臉臍臏臘臚臟臠臢臨臺與興舉舊艙艤艦艫艱艷芻苎苧茲荊莊莖莢莧華萇萊萬萵葉葒著葤葦葯葷蒓蒔蒞蒼蓀蓋蓮蓯蓴蓽蔔蔞蔣蔥蔦蔭蕁蕆蕎蕒蕓蕕蕘蕢蕩蕪蕭蕷薀薈薊薌薔薘薟薦薩薴薺藍藎藝藥藪藴藶藹藺蘄蘆蘇蘊蘋蘚蘞蘢蘭蘺蘿虆處虛虜號虧虯蛺蛻蜆蝕蝟蝦蝸螄螞螢螻螿蟄蟈蟎蟣蟬蟯蟲蟶蟻蠅蠆蠐蠑蠟蠣蠨蠱蠶蠻衆術衕衚衛衝衹袞裊裏補裝裡製複褌褘褲褳褸褻襇襏襖襝襠襤襪襯襲見覎規覓視覘覡覥覦親覬覯覲覷覺覽覿觀觴觶觸訁訂訃計訊訌討訐訒訓訕訖託記訛訝訟訢訣訥訩訪設許訴訶診註詁詆詎詐詒詔評詖詗詘詛詞詠詡詢詣試詩詫詬詭詮詰話該詳詵詼詿誄誅誆誇誌認誑誒誕誘誚語誠誡誣誤誥誦誨說説誰課誶誹誼誾調諂諄談諉請諍諏諑諒論諗諛諜諝諞諢諤諦諧諫諭諮諱諳諶諷諸諺諼諾謀謁謂謄謅謊謎謐謔謖謗謙謚講謝謠謡謨謫謬謭謳謹謾證譎譏譖識譙譚譜譫譯議譴護譸譽譾讀變讎讒讓讕讖讜讞豈豎豐豬豶貓貝貞貟負財貢貧貨販貪貫責貯貰貲貳貴貶買貸貺費貼貽貿賀賁賂賃賄賅資賈賊賑賒賓賕賙賚賜賞賠賡賢賣賤賦賧質賫賬賭賴賵賺賻購賽賾贄贅贇贈贊贋贍贏贐贓贔贖贗贛贜赬趕趙趨趲跡踐踴蹌蹕蹣蹤蹺躂躉躊躋躍躑躒躓躕躚躡躥躦躪軀車軋軌軍軑軒軔軛軟軤軫軲軸軹軺軻軼軾較輅輇輈載輊輒輓輔輕輛輜輝輞輟輥輦輩輪輬輯輳輸輻輾輿轀轂轄轅轆轉轍轎轔轟轡轢轤辦辭辮辯農逕這連進運過達違遙遜遞遠適遲遷選遺遼邁還邇邊邏邐郟郵鄆鄉鄒鄔鄖鄧鄭鄰鄲鄴鄶鄺酇酈醖醜醞醫醬醱釀釁釃釅釋釐釒釓釔釕釗釘釙針釣釤釧釩釵釷釹釺鈀鈁鈃鈄鈈鈉鈍鈎鈐鈑鈒鈔鈕鈞鈣鈥鈦鈧鈮鈰鈳鈴鈷鈸鈹鈺鈽鈾鈿鉀鉅鉈鉉鉋鉍鉑鉕鉗鉚鉛鉞鉢鉤鉦鉬鉭鉶鉸鉺鉻鉿銀銃銅銍銑銓銖銘銚銛銜銠銣銥銦銨銩銪銫銬銱銳銷銹銻銼鋁鋃鋅鋇鋌鋏鋒鋙鋝鋟鋣鋤鋥鋦鋨鋩鋪鋭鋮鋯鋰鋱鋶鋸鋼錁錄錆錇錈錏錐錒錕錘錙錚錛錟錠錡錢錦錨錩錫錮錯録錳錶錸鍀鍁鍃鍆鍇鍈鍋鍍鍔鍘鍚鍛鍠鍤鍥鍩鍬鍰鍵鍶鍺鎂鎄鎇鎊鎔鎖鎘鎛鎡鎢鎣鎦鎧鎩鎪鎬鎮鎰鎲鎳鎵鎸鎿鏃鏇鏈鏌鏍鏐鏑鏗鏘鏜鏝鏞鏟鏡鏢鏤鏨鏰鏵鏷鏹鏽鐃鐋鐐鐒鐓鐔鐘鐙鐝鐠鐦鐧鐨鐫鐮鐲鐳鐵鐶鐸鐺鐿鑄鑊鑌鑒鑔鑕鑞鑠鑣鑥鑭鑰鑱鑲鑷鑹鑼鑽鑾鑿钁長門閂閃閆閈閉開閌閎閏閑間閔閘閡閣閥閨閩閫閬閭閱閲閶閹閻閼閽閾閿闃闆闈闊闋闌闍闐闒闓闔闕闖關闞闠闡闤闥阪陘陝陣陰陳陸陽隉隊階隕際隨險隱隴隸隻雋雖雙雛雜雞離難雲電霢霧霽靂靄靈靚靜靦靨鞀鞏鞝鞽韁韃韉韋韌韍韓韙韜韞韻響頁頂頃項順頇須頊頌頎頏預頑頒頓頗領頜頡頤頦頭頮頰頲頴頷頸頹頻頽顆題額顎顏顒顓顔願顙顛類顢顥顧顫顬顯顰顱顳顴風颭颮颯颱颳颶颸颺颻颼飀飄飆飈飛飠飢飣飥飩飪飫飭飯飲飴飼飽飾飿餃餄餅餉養餌餎餏餑餒餓餕餖餚餛餜餞餡館餱餳餶餷餺餼餾餿饁饃饅饈饉饊饋饌饑饒饗饜饞饢馬馭馮馱馳馴馹駁駐駑駒駔駕駘駙駛駝駟駡駢駭駰駱駸駿騁騂騅騌騍騎騏騖騙騤騫騭騮騰騶騷騸騾驀驁驂驃驄驅驊驌驍驏驕驗驚驛驟驢驤驥驦驪驫骯髏髒體髕髖髮鬆鬍鬚鬢鬥鬧鬩鬮鬱魎魘魚魛魢魨魯魴魷魺鮁鮃鮊鮋鮍鮎鮐鮑鮒鮓鮚鮜鮝鮞鮦鮪鮫鮭鮮鮳鮶鮺鯀鯁鯇鯉鯊鯒鯔鯕鯖鯗鯛鯝鯡鯢鯤鯧鯨鯪鯫鯴鯷鯽鯿鰁鰂鰃鰈鰉鰍鰏鰐鰒鰓鰜鰟鰠鰣鰥鰨鰩鰭鰮鰱鰲鰳鰵鰷鰹鰺鰻鰼鰾鱂鱅鱈鱉鱒鱔鱖鱗鱘鱝鱟鱠鱣鱤鱧鱨鱭鱯鱷鱸鱺鳥鳧鳩鳬鳲鳳鳴鳶鳾鴆鴇鴉鴒鴕鴛鴝鴞鴟鴣鴦鴨鴯鴰鴴鴷鴻鴿鵁鵂鵃鵐鵑鵒鵓鵜鵝鵠鵡鵪鵬鵮鵯鵲鵷鵾鶄鶇鶉鶊鶓鶖鶘鶚鶡鶥鶩鶪鶬鶯鶲鶴鶹鶺鶻鶼鶿鷀鷁鷂鷄鷈鷊鷓鷖鷗鷙鷚鷥鷦鷫鷯鷲鷳鷸鷹鷺鷽鷿鸇鸌鸏鸕鸘鸚鸛鸝鸞鹵鹹鹺鹽麗麥麩麵麽黃黌點黨黲黶黷黽黿鼉鼴齊齋齎齏齒齔齕齗齙齜齟齠齡齦齪齬齲齶齷龍龎龐龔龕龜]/; const isTraditional = [...strings].map(string => !!string?.match(reg)); - //console.log("isTraditional: " + isTraditional) + //console.debug("isTraditional: " + isTraditional) const sumEqual = isTraditional.reduce((prev, current, index, arr) => { return prev + current; }); - log("✅ is the Strings Traditional Chinese?", `sumEqual: ${sumEqual}`, ""); + Console.log("✅ is the Strings Traditional Chinese?", `sumEqual: ${sumEqual}`); return sumEqual; } } @@ -503,7 +503,7 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined * @return {Array} is setJSON success? */ function setCache(infoGroup = { seasonTitle: undefined, seasonId: undefined, epId: undefined, mId: undefined, evaluate: undefined }, episodes = [], cache = {}) { - log("☑️ Set Cache", `seasonTitle: ${infoGroup.seasonTitle}, seasonId: ${infoGroup.seasonId}, epId: ${infoGroup.epId}, mId: ${infoGroup.mId}`, ""); + Console.log("☑️ Set Cache", `seasonTitle: ${infoGroup.seasonTitle}`, `seasonId: ${infoGroup.seasonId}`, `epId: ${infoGroup.epId}`, `mId: ${infoGroup.mId}`); let isSaved = false; if (infoGroup.locales?.length > 0) { if (infoGroup.seasonId) cache.ss.set(infoGroup.seasonId, infoGroup.locales); @@ -513,7 +513,7 @@ function setCache(infoGroup = { seasonTitle: undefined, seasonId: undefined, epI cache.ep = Array.from(cache.ep).slice(-1000); // Map转Array.限制缓存大小 isSaved = Storage.setItem("@BiliBili.Global.Caches", cache); } - log(`✅ Set Cache, locales: ${infoGroup.locales}, isSaved: ${isSaved}`, ""); - //log(`🚧 Set Cache`, `cache: ${JSON.stringify(cache)}`, ""); + Console.log("✅ Set Cache", `locales: ${infoGroup.locales}`, `isSaved: ${isSaved}`); + //Console.debug(`Set Cache`, `cache: ${JSON.stringify(cache)}`); return isSaved; } diff --git a/src/response.js b/src/response.js index 3e5261d..8912a7f 100644 --- a/src/response.js +++ b/src/response.js @@ -1,20 +1,21 @@ -import { $app, Lodash as _, Storage, fetch, notification, log, logError, wait, done, gRPC } from "@nsnanocat/util"; +import { $app, Console, done, fetch, gRPC, Lodash as _, notification, Storage, wait } from "@nsnanocat/util"; import { URL } from "@nsnanocat/url"; import database from "./function/database.mjs"; import setENV from "./function/setENV.mjs"; import { WireType, UnknownFieldHandler, reflectionMergePartial, MESSAGE_TYPE, MessageType, BinaryReader, isJsonObject, typeofJsonValue, jsonWriteOptions } from "@protobuf-ts/runtime"; import { ViewReply } from "./protobuf/bilibili/app/viewunite/v1/viewunite.js"; import { ViewPgcAny } from "./protobuf/bilibili/app/viewunite/pgcanymodel.js"; +Console.debug = () => {}; /***************** Processing *****************/ // 解构URL const url = new URL($request.url); -log(`⚠ url: ${url.toJSON()}`, ""); +Console.info(`url: ${url.toJSON()}`); // 获取连接参数 const PATHs = url.pathname.split("/").filter(Boolean); -log(`⚠ PATHs: ${PATHs}`, ""); +Console.info(`PATHs: ${PATHs}`); // 解析格式 const FORMAT = ($response.headers?.["Content-Type"] ?? $response.headers?.["content-type"])?.split(";")?.[0]; -log(`⚠ FORMAT: ${FORMAT}`, ""); +Console.info(`FORMAT: ${FORMAT}`); !(async () => { /** * 设置 @@ -159,9 +160,9 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "application/grpc": case "application/grpc+proto": case "application/octet-stream": { - //log(`🚧 $response.body: ${JSON.stringify($response.body)}`, ""); + //Console.debug(`$response.body: ${JSON.stringify($response.body)}`); let rawBody = $app === "Quantumult X" ? new Uint8Array($response.bodyBytes ?? []) : ($response.body ?? new Uint8Array()); - //log(`🚧 isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`, ""); + //Console.debug(`isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`); switch (FORMAT) { case "application/protobuf": case "application/x-protobuf": @@ -264,9 +265,9 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } } - log(`🚧 信息组, infoGroup: ${JSON.stringify(infoGroup)}`, ""); + Console.debug(`infoGroup: ${JSON.stringify(infoGroup)}`); })() - .catch(e => logError(e)) + .catch(e => Console.error(e)) .finally(() => done($response)); /***************** Function *****************/ @@ -277,7 +278,7 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); * @return {Array} Episodes Datas */ function getEpisodes(modules = []) { - log("⚠ Get Episodes", ""); + Console.log("☑️ Get Episodes"); const episodes = modules.flatMap(module => { switch (module?.style) { case "positive": // 选集 @@ -290,8 +291,8 @@ function getEpisodes(modules = []) { return []; } }); - log("🎉 Get Episodes", ""); - //log(`🚧 Get Episodes`, `modules.episodes: ${JSON.stringify(episodes)}`, ""); + Console.log("✅ Get Episodes"); + //Console.debug(`Get Episodes`, `modules.episodes: ${JSON.stringify(episodes)}`); return episodes; } @@ -302,7 +303,7 @@ function getEpisodes(modules = []) { * @return {Array} Modules Datas */ function setModules(modules = []) { - log("⚠ Set Episodes", ""); + Console.log("☑️ Set Episodes"); modules = modules.map(module => { switch (module?.style) { case "positive": // 选集 @@ -317,8 +318,8 @@ function setModules(modules = []) { } return module; }); - log("🎉 Set Episodes", ""); - //log(`🚧 Set Episodes`, `modules: ${JSON.stringify(modules)}`, ""); + Console.log("✅ Set Episodes"); + //Console.debug(`Set Episodes`, `modules: ${JSON.stringify(modules)}`); return modules; } @@ -329,7 +330,7 @@ function setModules(modules = []) { * @return {Array} Modules Datas */ function setEpisodes(episodes = []) { - log("⚠ Set Episodes", ""); + Console.log("☑️ Set Episodes"); episodes = episodes.map(episode => { if (episode?.badge_info?.text === "受限") { episode.badge_info.text = ""; @@ -344,8 +345,8 @@ function setEpisodes(episodes = []) { } return episode; }); - log("🎉 Set Episodes", ""); - //log(`🚧 Set Episodes`, `episodes: ${JSON.stringify(episodes)}`, ""); + Console.log("✅ Set Episodes"); + //Console.debug(`Set Episodes`, `episodes: ${JSON.stringify(episodes)}`); return episodes; } @@ -356,7 +357,7 @@ function setEpisodes(episodes = []) { * @return {String} locales */ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined, epId: undefined, mId: undefined, evaluate: undefined }) { - log("☑️ Detect Locales", `seasonTitle: ${infoGroup.seasonTitle}, seasonId: ${infoGroup.seasonId}, epId: ${infoGroup.epId}, mId: ${infoGroup.mId}`, ""); + Console.log("☑️ Detect Locales", `seasonTitle: ${infoGroup.seasonTitle}`, `seasonId: ${infoGroup.seasonId}`, `epId: ${infoGroup.epId}`, `mId: ${infoGroup.mId}`); switch (infoGroup.seasonTitle) { case undefined: case null: @@ -366,13 +367,13 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined infoGroup.locales = detectSeasonTitle(infoGroup.seasonTitle); break; } - log(`✅ Detect Locales, locales: ${infoGroup.locales}`, ""); + Console.log("✅ Detect Locales", `locales: ${infoGroup.locales}`); return infoGroup.locales; /***************** Functions *****************/ function detectSeasonTitle(seasonTitle) { - log("☑️ Detect Season Title", ""); + Console.log("☑️ Detect Season Title"); let locales = []; - log([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]); + Console.debug([...infoGroup.seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]); switch ([...seasonTitle?.matchAll(/[(\uFF08]([^(\uFF08)\uFF09]+)[)\uFF09]/g)]?.pop()?.[1]) { case "僅限港澳台地區": case "限僅港澳台地區": @@ -401,12 +402,12 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined locales = detectMId(infoGroup.mId); break; } - log(`✅ Detect Season Title, locales: ${locales}`, ""); + Console.log("✅ Detect Season Title", `locales: ${locales}`); return locales; } function detectMId(mId) { - log("☑️ Detect mId", ""); + Console.log("☑️ Detect mId"); let locales = []; switch (mId) { case 928123: // 哔哩哔哩番剧 @@ -430,12 +431,12 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined locales = detectTraditional(infoGroup.seasonTitle, infoGroup.evaluate); break; } - log(`✅ Detect mId, locales: ${locales}`, ""); + Console.log("✅ Detect mId", `locales: ${locales}`); return locales; } function detectTraditional(seasonTitle, evaluate) { - log("☑️ Detect Traditional", ""); + Console.log("☑️ Detect Traditional"); let locales = []; if (isTraditional(seasonTitle) > 0) { // Traditional Chinese @@ -447,7 +448,7 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined // Simplified Chinese locales = ["CHN"]; } - log(`✅ Detect Traditional, locales: ${locales}`, ""); + Console.log("✅ Detect Traditional", `locales: ${locales}`); return locales; /***************** Functions *****************/ /** @@ -457,14 +458,14 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined * @return {Number} Traditional Chinese Count */ function isTraditional(strings = [""]) { - log("☑️ is the Strings Traditional Chinese?", ""); + Console.log("☑️ is the Strings Traditional Chinese?"); const reg = /[䊷䋙䝼䰾䲁丟並乾亂亞佇馀併來侖侶俁係俔俠倀倆倈倉個們倫偉側偵偽傑傖傘備傭傯傳傴債傷傾僂僅僉僑僕僞僥僨價儀儂億儈儉儐儔儕儘償優儲儷儺儻儼兌兒兗內兩冊冪凈凍凜凱別刪剄則剋剎剗剛剝剮剴創劃劇劉劊劌劍劑勁動務勛勝勞勢勩勱勵勸勻匭匯匱區協卻厙厠厭厲厴參叄叢吒吳吶呂咼員唄唚問啓啞啟啢喎喚喪喬單喲嗆嗇嗊嗎嗚嗩嗶嘆嘍嘔嘖嘗嘜嘩嘮嘯嘰嘵嘸嘽噓噝噠噥噦噯噲噴噸噹嚀嚇嚌嚕嚙嚦嚨嚲嚳嚴嚶囀囁囂囅囈囑囪圇國圍園圓圖團垵埡埰執堅堊堖堝堯報場塊塋塏塒塗塢塤塵塹墊墜墮墳墻墾壇壈壋壓壘壙壚壞壟壠壢壩壯壺壼壽夠夢夾奐奧奩奪奬奮奼妝姍姦娛婁婦婭媧媯媼媽嫗嫵嫻嫿嬀嬈嬋嬌嬙嬡嬤嬪嬰嬸孌孫學孿宮寢實寧審寫寬寵寶將專尋對導尷屆屍屓屜屢層屨屬岡峴島峽崍崗崢崬嵐嶁嶄嶇嶔嶗嶠嶢嶧嶮嶴嶸嶺嶼巋巒巔巰帥師帳帶幀幃幗幘幟幣幫幬幹幺幾庫廁廂廄廈廚廝廟廠廡廢廣廩廬廳弒弳張強彈彌彎彙彞彥後徑從徠復徵徹恆恥悅悞悵悶惡惱惲惻愛愜愨愴愷愾慄態慍慘慚慟慣慤慪慫慮慳慶憂憊憐憑憒憚憤憫憮憲憶懇應懌懍懟懣懨懲懶懷懸懺懼懾戀戇戔戧戩戰戱戲戶拋拾挩挾捨捫掃掄掗掙掛採揀揚換揮損搖搗搵搶摑摜摟摯摳摶摻撈撏撐撓撝撟撣撥撫撲撳撻撾撿擁擄擇擊擋擓擔據擠擬擯擰擱擲擴擷擺擻擼擾攄攆攏攔攖攙攛攜攝攢攣攤攪攬敗敘敵數斂斃斕斬斷時晉晝暈暉暘暢暫曄曆曇曉曏曖曠曨曬書會朧東杴桿梔梘條梟梲棄棖棗棟棧棲棶椏楊楓楨業極榪榮榲榿構槍槤槧槨槳樁樂樅樓標樞樣樸樹樺橈橋機橢橫檁檉檔檜檟檢檣檮檯檳檸檻櫃櫓櫚櫛櫝櫞櫟櫥櫧櫨櫪櫫櫬櫱櫳櫸櫻欄權欏欒欖欞欽歐歟歡歲歷歸歿殘殞殤殨殫殮殯殲殺殻殼毀毆毿氂氈氌氣氫氬氳決沒沖況洶浹涇涼淚淥淪淵淶淺渙減渦測渾湊湞湯溈準溝溫滄滅滌滎滬滯滲滷滸滻滾滿漁漚漢漣漬漲漵漸漿潁潑潔潙潛潤潯潰潷潿澀澆澇澗澠澤澦澩澮澱濁濃濕濘濟濤濫濰濱濺濼濾瀅瀆瀉瀏瀕瀘瀝瀟瀠瀦瀧瀨瀲瀾灃灄灑灕灘灝灠灣灤灧災為烏烴無煉煒煙煢煥煩煬熅熒熗熱熲熾燁燈燉燒燙燜營燦燭燴燼燾爍爐爛爭爲爺爾牆牘牽犖犢犧狀狹狽猙猶猻獁獄獅獎獨獪獫獮獰獲獵獷獸獺獻獼玀現琺琿瑋瑒瑣瑤瑩瑪瑲璉璣璦璫環璽瓊瓏瓔瓚甌產産畝畢異畵當疇疊痙痾瘂瘋瘍瘓瘞瘡瘧瘮瘲瘺瘻療癆癇癉癘癟癢癤癥癧癩癬癭癮癰癱癲發皚皰皸皺盜盞盡監盤盧眥眾睏睜睞瞘瞜瞞瞶瞼矓矚矯硜硤硨硯碩碭碸確碼磑磚磣磧磯磽礆礎礙礦礪礫礬礱祿禍禎禕禡禦禪禮禰禱禿秈稅稈稟種稱穀穌積穎穠穡穢穩穫穭窩窪窮窯窵窶窺竄竅竇竈竊竪競筆筍筧筴箋箏節範築篋篔篤篩篳簀簍簞簡簣簫簹簽簾籃籌籙籜籟籠籩籪籬籮粵糝糞糧糲糴糶糹糾紀紂約紅紆紇紈紉紋納紐紓純紕紖紗紘紙級紛紜紝紡紬細紱紲紳紵紹紺紼紿絀終組絅絆絎結絕絛絝絞絡絢給絨絰統絲絳絶絹綁綃綆綈綉綌綏經綜綞綠綢綣綫綬維綯綰綱網綳綴綸綹綺綻綽綾綿緄緇緊緋緑緒緓緔緗緘緙線緝緞締緡緣緦編緩緬緯緱緲練緶緹緻縈縉縊縋縐縑縕縗縛縝縞縟縣縧縫縭縮縱縲縳縵縶縷縹總績繃繅繆繒織繕繚繞繡繢繩繪繫繭繮繯繰繳繸繹繼繽繾纈纊續纍纏纓纖纘纜缽罈罌罰罵罷羅羆羈羋羥義習翹耬耮聖聞聯聰聲聳聵聶職聹聽聾肅脅脈脛脫脹腎腖腡腦腫腳腸膃膚膠膩膽膾膿臉臍臏臘臚臟臠臢臨臺與興舉舊艙艤艦艫艱艷芻苎苧茲荊莊莖莢莧華萇萊萬萵葉葒著葤葦葯葷蒓蒔蒞蒼蓀蓋蓮蓯蓴蓽蔔蔞蔣蔥蔦蔭蕁蕆蕎蕒蕓蕕蕘蕢蕩蕪蕭蕷薀薈薊薌薔薘薟薦薩薴薺藍藎藝藥藪藴藶藹藺蘄蘆蘇蘊蘋蘚蘞蘢蘭蘺蘿虆處虛虜號虧虯蛺蛻蜆蝕蝟蝦蝸螄螞螢螻螿蟄蟈蟎蟣蟬蟯蟲蟶蟻蠅蠆蠐蠑蠟蠣蠨蠱蠶蠻衆術衕衚衛衝衹袞裊裏補裝裡製複褌褘褲褳褸褻襇襏襖襝襠襤襪襯襲見覎規覓視覘覡覥覦親覬覯覲覷覺覽覿觀觴觶觸訁訂訃計訊訌討訐訒訓訕訖託記訛訝訟訢訣訥訩訪設許訴訶診註詁詆詎詐詒詔評詖詗詘詛詞詠詡詢詣試詩詫詬詭詮詰話該詳詵詼詿誄誅誆誇誌認誑誒誕誘誚語誠誡誣誤誥誦誨說説誰課誶誹誼誾調諂諄談諉請諍諏諑諒論諗諛諜諝諞諢諤諦諧諫諭諮諱諳諶諷諸諺諼諾謀謁謂謄謅謊謎謐謔謖謗謙謚講謝謠謡謨謫謬謭謳謹謾證譎譏譖識譙譚譜譫譯議譴護譸譽譾讀變讎讒讓讕讖讜讞豈豎豐豬豶貓貝貞貟負財貢貧貨販貪貫責貯貰貲貳貴貶買貸貺費貼貽貿賀賁賂賃賄賅資賈賊賑賒賓賕賙賚賜賞賠賡賢賣賤賦賧質賫賬賭賴賵賺賻購賽賾贄贅贇贈贊贋贍贏贐贓贔贖贗贛贜赬趕趙趨趲跡踐踴蹌蹕蹣蹤蹺躂躉躊躋躍躑躒躓躕躚躡躥躦躪軀車軋軌軍軑軒軔軛軟軤軫軲軸軹軺軻軼軾較輅輇輈載輊輒輓輔輕輛輜輝輞輟輥輦輩輪輬輯輳輸輻輾輿轀轂轄轅轆轉轍轎轔轟轡轢轤辦辭辮辯農逕這連進運過達違遙遜遞遠適遲遷選遺遼邁還邇邊邏邐郟郵鄆鄉鄒鄔鄖鄧鄭鄰鄲鄴鄶鄺酇酈醖醜醞醫醬醱釀釁釃釅釋釐釒釓釔釕釗釘釙針釣釤釧釩釵釷釹釺鈀鈁鈃鈄鈈鈉鈍鈎鈐鈑鈒鈔鈕鈞鈣鈥鈦鈧鈮鈰鈳鈴鈷鈸鈹鈺鈽鈾鈿鉀鉅鉈鉉鉋鉍鉑鉕鉗鉚鉛鉞鉢鉤鉦鉬鉭鉶鉸鉺鉻鉿銀銃銅銍銑銓銖銘銚銛銜銠銣銥銦銨銩銪銫銬銱銳銷銹銻銼鋁鋃鋅鋇鋌鋏鋒鋙鋝鋟鋣鋤鋥鋦鋨鋩鋪鋭鋮鋯鋰鋱鋶鋸鋼錁錄錆錇錈錏錐錒錕錘錙錚錛錟錠錡錢錦錨錩錫錮錯録錳錶錸鍀鍁鍃鍆鍇鍈鍋鍍鍔鍘鍚鍛鍠鍤鍥鍩鍬鍰鍵鍶鍺鎂鎄鎇鎊鎔鎖鎘鎛鎡鎢鎣鎦鎧鎩鎪鎬鎮鎰鎲鎳鎵鎸鎿鏃鏇鏈鏌鏍鏐鏑鏗鏘鏜鏝鏞鏟鏡鏢鏤鏨鏰鏵鏷鏹鏽鐃鐋鐐鐒鐓鐔鐘鐙鐝鐠鐦鐧鐨鐫鐮鐲鐳鐵鐶鐸鐺鐿鑄鑊鑌鑒鑔鑕鑞鑠鑣鑥鑭鑰鑱鑲鑷鑹鑼鑽鑾鑿钁長門閂閃閆閈閉開閌閎閏閑間閔閘閡閣閥閨閩閫閬閭閱閲閶閹閻閼閽閾閿闃闆闈闊闋闌闍闐闒闓闔闕闖關闞闠闡闤闥阪陘陝陣陰陳陸陽隉隊階隕際隨險隱隴隸隻雋雖雙雛雜雞離難雲電霢霧霽靂靄靈靚靜靦靨鞀鞏鞝鞽韁韃韉韋韌韍韓韙韜韞韻響頁頂頃項順頇須頊頌頎頏預頑頒頓頗領頜頡頤頦頭頮頰頲頴頷頸頹頻頽顆題額顎顏顒顓顔願顙顛類顢顥顧顫顬顯顰顱顳顴風颭颮颯颱颳颶颸颺颻颼飀飄飆飈飛飠飢飣飥飩飪飫飭飯飲飴飼飽飾飿餃餄餅餉養餌餎餏餑餒餓餕餖餚餛餜餞餡館餱餳餶餷餺餼餾餿饁饃饅饈饉饊饋饌饑饒饗饜饞饢馬馭馮馱馳馴馹駁駐駑駒駔駕駘駙駛駝駟駡駢駭駰駱駸駿騁騂騅騌騍騎騏騖騙騤騫騭騮騰騶騷騸騾驀驁驂驃驄驅驊驌驍驏驕驗驚驛驟驢驤驥驦驪驫骯髏髒體髕髖髮鬆鬍鬚鬢鬥鬧鬩鬮鬱魎魘魚魛魢魨魯魴魷魺鮁鮃鮊鮋鮍鮎鮐鮑鮒鮓鮚鮜鮝鮞鮦鮪鮫鮭鮮鮳鮶鮺鯀鯁鯇鯉鯊鯒鯔鯕鯖鯗鯛鯝鯡鯢鯤鯧鯨鯪鯫鯴鯷鯽鯿鰁鰂鰃鰈鰉鰍鰏鰐鰒鰓鰜鰟鰠鰣鰥鰨鰩鰭鰮鰱鰲鰳鰵鰷鰹鰺鰻鰼鰾鱂鱅鱈鱉鱒鱔鱖鱗鱘鱝鱟鱠鱣鱤鱧鱨鱭鱯鱷鱸鱺鳥鳧鳩鳬鳲鳳鳴鳶鳾鴆鴇鴉鴒鴕鴛鴝鴞鴟鴣鴦鴨鴯鴰鴴鴷鴻鴿鵁鵂鵃鵐鵑鵒鵓鵜鵝鵠鵡鵪鵬鵮鵯鵲鵷鵾鶄鶇鶉鶊鶓鶖鶘鶚鶡鶥鶩鶪鶬鶯鶲鶴鶹鶺鶻鶼鶿鷀鷁鷂鷄鷈鷊鷓鷖鷗鷙鷚鷥鷦鷫鷯鷲鷳鷸鷹鷺鷽鷿鸇鸌鸏鸕鸘鸚鸛鸝鸞鹵鹹鹺鹽麗麥麩麵麽黃黌點黨黲黶黷黽黿鼉鼴齊齋齎齏齒齔齕齗齙齜齟齠齡齦齪齬齲齶齷龍龎龐龔龕龜]/; const isTraditional = [...strings].map(string => !!string?.match(reg)); const sumEqual = isTraditional.reduce((prev, current, index, arr) => { return prev + current; }); - log("✅ is the Strings Traditional Chinese?", `sumEqual: ${sumEqual}`, ""); + Console.log("✅ is the Strings Traditional Chinese?", `sumEqual: ${sumEqual}`); return sumEqual; } } @@ -479,7 +480,7 @@ function detectLocales(infoGroup = { seasonTitle: undefined, seasonId: undefined * @return {Array} is setJSON success? */ function setCache(infoGroup = { seasonTitle: undefined, seasonId: undefined, epId: undefined, mId: undefined, evaluate: undefined }, episodes = [], cache = {}) { - log("☑️ Set Cache", `seasonTitle: ${infoGroup.seasonTitle}, seasonId: ${infoGroup.seasonId}, epId: ${infoGroup.epId}, mId: ${infoGroup.mId}`, ""); + Console.log("☑️ Set Cache", `seasonTitle: ${infoGroup.seasonTitle}`, `seasonId: ${infoGroup.seasonId}`, `epId: ${infoGroup.epId}`, `mId: ${infoGroup.mId}`); let isSaved = false; if (infoGroup.locales?.length > 0) { if (infoGroup.seasonId) cache.ss.set(infoGroup.seasonId, infoGroup.locales); @@ -489,6 +490,6 @@ function setCache(infoGroup = { seasonTitle: undefined, seasonId: undefined, epI cache.ep = Array.from(cache.ep).slice(-1000); // Map转Array.限制缓存大小 isSaved = Storage.setItem("@BiliBili.Global.Caches", cache); } - log(`✅ Set Cache, locales: ${infoGroup.locales}, isSaved: ${isSaved}`, ""); + Console.log("✅ Set Cache", `locales: ${infoGroup.locales}`, `isSaved: ${isSaved}`); return isSaved; }