From 9932b0b0c512feaee48410668519341aa22404eb Mon Sep 17 00:00:00 2001 From: Virgil Clyne Date: Fri, 1 Nov 2024 13:35:46 +0800 Subject: [PATCH] feat(response): bilibili.app.viewunite.v1.View/View Update response.dev.js Update protobuf --- src/protobuf | 2 +- src/response.dev.js | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/protobuf b/src/protobuf index 7d6c168..2c60d29 160000 --- a/src/protobuf +++ b/src/protobuf @@ -1 +1 @@ -Subproject commit 7d6c168cb923c8ba4d60a43f5a06accd39596efe +Subproject commit 2c60d29d825a7510b101f9eee8ce7f7147de424a diff --git a/src/response.dev.js b/src/response.dev.js index 6659905..e77221c 100644 --- a/src/response.dev.js +++ b/src/response.dev.js @@ -4,6 +4,7 @@ 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"; /***************** Processing *****************/ // 解构URL const url = new URL($request.url); @@ -108,7 +109,8 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } break; - case "/pgc/view/v2/app/season": { // 番剧页面-内容-app + case "/pgc/view/v2/app/season": { + // 番剧页面-内容-app const data = body.data; infoGroup.seasonTitle = data?.season_title ?? infoGroup.seasonTitle; infoGroup.seasonId = data?.season_id ?? infoGroup.seasonId; @@ -136,7 +138,8 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); break; } case "/pgc/view/web/season": // 番剧-内容-web - case "/pgc/view/pc/season": { // 番剧-内容-pc + case "/pgc/view/pc/season": { + // 番剧-内容-pc const result = body.result; infoGroup.seasonTitle = result.season_title ?? infoGroup.seasonTitle; infoGroup.seasonId = result.season_id ?? infoGroup.seasonId; @@ -194,23 +197,36 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "View": // 播放页 body = ViewReply.fromBinary(rawBody); log(`🚧 body: ${JSON.stringify(body)}`, ""); - rawBody = ViewReply.toBinary(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; //infoGroup.evaluate = result?.evaluate ?? infoGroup.evaluate; if (infoGroup.seasonId || infoGroup.epId) infoGroup.type = "PGC"; switch (body?.supplement?.typeUrl) { - case "type.googleapis.com/bilibili.app.viewunite.pgcanymodel.ViewPgcAny": + case "type.googleapis.com/bilibili.app.viewunite.pgcanymodel.ViewPgcAny": { infoGroup.type = "PGC"; + const PgcBody = ViewPgcAny.fromBinary(body?.supplement?.value); + log(`🚧 PgcBody: ${JSON.stringify(PgcBody)}`, ""); + infoGroup.seasonTitle = PgcBody?.ogvData?.title || infoGroup.seasonTitle; + infoGroup.seasonId = PgcBody?.ogvData?.seasonId || infoGroup.seasonId; + _.set(PgcBody, "ogvData.rights.allowDownload", 1); + _.set(PgcBody, "ogvData.rights.allowReview", 1); + _.set(PgcBody, "ogvData.rights.allowBp", 1); + _.set(PgcBody, "ogvData.rights.areaLimit", 0); + _.set(PgcBody, "ogvData.rights.banAreaShow", 0); + log(`🚧 PgcBody: ${JSON.stringify(PgcBody)}`, ""); + body.supplement.value = ViewPgcAny.toBinary(PgcBody); break; + } case "type.googleapis.com/bilibili.app.viewunite.ugcanymodel.ViewUgcAny": - default: + default: { infoGroup.type = "UGC"; break; + } } infoGroup.locales = detectLocales(infoGroup); setCache(infoGroup, [], Caches); + rawBody = ViewReply.toBinary(body); break; } break;