Skip to content

Commit

Permalink
feat(response): bilibili.app.viewunite.v1.View/View
Browse files Browse the repository at this point in the history
Update response.dev.js
Update protobuf
  • Loading branch information
VirgilClyne committed Nov 1, 2024
1 parent a3007c7 commit 9932b0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions src/response.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9932b0b

Please sign in to comment.