From 0f187e02ff4d8a040e314ea379bfa69880f9d090 Mon Sep 17 00:00:00 2001 From: msojocs Date: Sun, 16 Jun 2024 22:34:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=95=AA=E5=89=A7?= =?UTF-8?q?=E5=87=BA=E5=B7=AE=E5=8A=A8=E6=80=81=E7=95=AA=E5=89=A7=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=A4=B1=E8=B4=A5=20#122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.MD | 3 +- extensions/area_unlimit/hook/common.js | 5 + package.json | 5 + pnpm-lock.yaml | 122 +++++-- res/protos/dynamic.proto | 431 +++++++++++++++++++++++++ res/scripts/injectExt.js | 118 ++++++- tools/fix-other.sh | 8 + 7 files changed, 671 insertions(+), 21 deletions(-) create mode 100644 res/protos/dynamic.proto diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 600fd1c..463e76f 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,4 +1,4 @@ -# 🌈 v1.13.6-1 / 2024-06-15 +# 🌈 v1.13.6-2 / 2024-06- ## 🚀 功能 @@ -7,6 +7,7 @@ ## 🐞 修复 - 番剧出差:修正出差卡片数据处理错误 +- 番剧出差:修正动态番剧播放失败 # 🌈 v1.13.6-1 / 2024-06-15 diff --git a/extensions/area_unlimit/hook/common.js b/extensions/area_unlimit/hook/common.js index 67b017c..cfc28d9 100644 --- a/extensions/area_unlimit/hook/common.js +++ b/extensions/area_unlimit/hook/common.js @@ -1260,8 +1260,13 @@ const URL_HOOK_FETCH = { // 获取动态详情 const bili = new BiliBiliApi(); const detail = await bili.getDynamicDetail(b2d.dynamic_id) + const dynamicDetail = await biliBridgePc.callNative('roaming/queryDynamicDetail', b2d.dynamic_id, UTILS.getAccessToken()) + log.info('dynamic detail phone:', dynamicDetail) + const dynamic = dynamicDetail.item.modules.find(e => e.module_type === 'module_dynamic') + const epid = dynamic.module_dynamic.dyn_archive.uri.match(/ep\d+/)[0] // 构造数据 const res = await UTILS.genVideoDetailByDynamicDetail(detail.data) + res.View.redirect_url = `https://www.bilibili.com/bangumi/play/${epid}` log.info('dynamic detail:', res) data.res.data = { code: 0, diff --git a/package.json b/package.json index 7c1b4ae..9328522 100644 --- a/package.json +++ b/package.json @@ -29,5 +29,10 @@ "app-builder-lib": "24.13.3", "builder-util": "24.13.1", "electron-builder": "^24.13.3" + }, + "dependencies": { + "@grpc/grpc-js": "^1.10.9", + "@grpc/proto-loader": "^0.7.13", + "protobufjs": "^7.3.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 36f7566..e880c23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,17 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +dependencies: + '@grpc/grpc-js': + specifier: ^1.10.9 + version: 1.10.9 + '@grpc/proto-loader': + specifier: ^0.7.13 + version: 0.7.13 + protobufjs: + specifier: ^7.3.2 + version: 7.3.2 + devDependencies: abstract-syntax-tree: specifier: ^2.22.0 @@ -86,6 +97,25 @@ packages: - supports-color dev: true + /@grpc/grpc-js@1.10.9: + resolution: {integrity: sha512-5tcgUctCG0qoNyfChZifz2tJqbRbXVO9J7X6duFcOjY3HUNCxg5D0ZCK7EP9vIcZ0zRpLU9bWkyCqVCLZ46IbQ==} + engines: {node: '>=12.10.0'} + dependencies: + '@grpc/proto-loader': 0.7.13 + '@js-sdsl/ordered-map': 4.4.2 + dev: false + + /@grpc/proto-loader@0.7.13: + resolution: {integrity: sha512-AiXO/bfe9bmxBjxxtYxFAXGZvMaN5s8kO+jBHAJCON8rJoB5YS/D6X7ZNc6XQkuHNmyl4CYaMI1fJ/Gn27RGGw==} + engines: {node: '>=6'} + hasBin: true + dependencies: + lodash.camelcase: 4.3.0 + long: 5.2.3 + protobufjs: 7.3.2 + yargs: 17.7.2 + dev: false + /@isaacs/cliui@8.0.2: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -98,6 +128,10 @@ packages: wrap-ansi-cjs: /wrap-ansi@7.0.0 dev: true + /@js-sdsl/ordered-map@4.4.2: + resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==} + dev: false + /@malept/cross-spawn-promise@1.1.1: resolution: {integrity: sha512-RTBGWL5FWQcg9orDOCcp4LvItNzUPcyEU9bwaeJX0rJ1IQxzucC48Y0/sQLp/g6t99IQgAlGIaesJS+gTn7tVQ==} engines: {node: '>= 10'} @@ -124,6 +158,49 @@ packages: dev: true optional: true + /@protobufjs/aspromise@1.1.2: + resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} + dev: false + + /@protobufjs/base64@1.1.2: + resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} + dev: false + + /@protobufjs/codegen@2.0.4: + resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} + dev: false + + /@protobufjs/eventemitter@1.1.0: + resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} + dev: false + + /@protobufjs/fetch@1.1.0: + resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/inquire': 1.1.0 + dev: false + + /@protobufjs/float@1.0.2: + resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} + dev: false + + /@protobufjs/inquire@1.1.0: + resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} + dev: false + + /@protobufjs/path@1.1.2: + resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} + dev: false + + /@protobufjs/pool@1.1.0: + resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} + dev: false + + /@protobufjs/utf8@1.1.0: + resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} + dev: false + /@tootallnate/once@2.0.0: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} @@ -149,7 +226,6 @@ packages: resolution: {integrity: sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==} dependencies: undici-types: 5.26.5 - dev: true /@types/plist@3.0.5: resolution: {integrity: sha512-E6OCaRmAe4WDmWNsL/9RMqdkkzDCY1etutkflWk4c+AcjDU07Pcz1fQwTX0TQz+Pxqn9i4L1TU3UFpjnrcDgxA==} @@ -213,7 +289,6 @@ packages: /ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - dev: true /ansi-regex@6.0.1: resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} @@ -225,7 +300,6 @@ packages: engines: {node: '>=8'} dependencies: color-convert: 2.0.1 - dev: true /ansi-styles@6.2.1: resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} @@ -505,18 +579,15 @@ packages: string-width: 4.2.3 strip-ansi: 6.0.1 wrap-ansi: 7.0.0 - dev: true /color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} dependencies: color-name: 1.1.4 - dev: true /color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true /combined-stream@1.0.8: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} @@ -725,7 +796,6 @@ packages: /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true /emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} @@ -744,7 +814,6 @@ packages: /escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} - dev: true /esquery@1.5.0: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} @@ -835,7 +904,6 @@ packages: /get-caller-file@2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} - dev: true /glob@10.3.14: resolution: {integrity: sha512-4fkAqu93xe9Mk7le9v0y3VrPDqLKHarNi2s4Pv7f2yOvfhWfhc7hRPHC/JyqMqb8B/Dt/eGS4n7ykwf3fOsl8g==} @@ -941,7 +1009,6 @@ packages: /is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} - dev: true /isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -1018,6 +1085,10 @@ packages: readable-stream: 2.3.8 dev: true + /lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + dev: false + /lodash.defaults@4.2.0: resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} dev: true @@ -1042,6 +1113,10 @@ packages: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true + /long@5.2.3: + resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==} + dev: false + /lru-cache@10.2.2: resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==} engines: {node: 14 || >=16.14} @@ -1192,6 +1267,25 @@ packages: retry: 0.12.0 dev: true + /protobufjs@7.3.2: + resolution: {integrity: sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==} + engines: {node: '>=12.0.0'} + requiresBuild: true + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/base64': 1.1.2 + '@protobufjs/codegen': 2.0.4 + '@protobufjs/eventemitter': 1.1.0 + '@protobufjs/fetch': 1.1.0 + '@protobufjs/float': 1.0.2 + '@protobufjs/inquire': 1.1.0 + '@protobufjs/path': 1.1.2 + '@protobufjs/pool': 1.1.0 + '@protobufjs/utf8': 1.1.0 + '@types/node': 20.12.11 + long: 5.2.3 + dev: false + /punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -1244,7 +1338,6 @@ packages: /require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} - dev: true /retry@0.12.0: resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} @@ -1350,7 +1443,6 @@ packages: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - dev: true /string-width@5.1.2: resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} @@ -1378,7 +1470,6 @@ packages: engines: {node: '>=8'} dependencies: ansi-regex: 5.0.1 - dev: true /strip-ansi@7.1.0: resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} @@ -1454,7 +1545,6 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} requiresBuild: true - dev: true /universalify@2.0.1: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} @@ -1502,7 +1592,6 @@ packages: ansi-styles: 4.3.0 string-width: 4.2.3 strip-ansi: 6.0.1 - dev: true /wrap-ansi@8.1.0: resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} @@ -1526,7 +1615,6 @@ packages: /y18n@5.0.8: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} - dev: true /yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} @@ -1535,7 +1623,6 @@ packages: /yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} - dev: true /yargs@17.7.2: resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} @@ -1548,7 +1635,6 @@ packages: string-width: 4.2.3 y18n: 5.0.8 yargs-parser: 21.1.1 - dev: true /zip-stream@4.1.1: resolution: {integrity: sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==} diff --git a/res/protos/dynamic.proto b/res/protos/dynamic.proto new file mode 100644 index 0000000..dd3c483 --- /dev/null +++ b/res/protos/dynamic.proto @@ -0,0 +1,431 @@ +syntax = "proto3"; + +package bilibili.app.dynamic.v2; + + +// v2动态, rpc 按字母顺序排列 +service Dynamic { + // 动态详情页 + rpc DynDetail(DynDetailReq) returns (DynDetailReply); +} +// 动态详情页-响应 +message DynDetailReply { + // 动态详情 + DynamicItem item = 1; +} +// 动态详情页-请求 +message DynDetailReq { + // 动态ID + string dynamic_id = 2; +} + +// 动态卡片 +message DynamicItem { + // 动态卡片类型 + DynamicType card_type = 1; + // 转发类型下,源卡片类型 + DynamicType item_type = 2; + // 模块内容 + repeated Module modules = 3; + // 操作相关字段 + // Extend extend = 4; + // 该卡片下面是否含有折叠卡 + int32 has_fold = 5; + // 透传到客户端的埋点字段。 + string server_info = 6; +} + +// 枚举-动态类型 +enum DynamicType { + dyn_none = 0; // 占位 + forward = 1; // 转发 + av = 2; // 稿件: ugc、小视频、短视频、UGC转PGC + pgc = 3; // pgc:番剧、PGC番剧、PGC电影、PGC电视剧、PGC国创、PGC纪录片 + courses = 4; // 付费更新批次 + fold = 5; // 折叠 + word = 6; // 纯文字 + draw = 7; // 图文 + article = 8; // 专栏 原仅phone端 + music = 9; // 音频 原仅phone端 + common_square = 10; // 通用卡 方形 + common_vertical = 11; // 通用卡 竖形 + live = 12; // 直播卡 只有转发态 + medialist = 13; // 播单 原仅phone端 只有转发态 + courses_season = 14; // 付费更新批次 只有转发态 + ad = 15; // 广告卡 + applet = 16; // 小程序卡 + subscription = 17; // 订阅卡 + live_rcmd = 18; // 直播推荐卡 + banner = 19; // 通栏 + ugc_season = 20; // 合集卡 + subscription_new = 21; // 新订阅卡 + story = 22; // + topic_rcmd = 23; // + cour_up = 24; // + topic_set = 25; // + notice = 26; // + text_notice = 27; // +} +// 动态模块 +message Module { + // 类型 + DynModuleType module_type = 1; + oneof module_item { + // // 用户模块 1 + // ModuleAuthor module_author = 2; + // // 争议黄条模块 2 + // ModuleDispute module_dispute = 3; + // // 动态正文模块 3 + // ModuleDesc module_desc = 4; + // 动态卡模块 4 + ModuleDynamic module_dynamic = 5; + // // 点赞外露(废弃) + // ModuleLikeUser module_likeUser = 6; + // // 小卡模块 6 + // ModuleExtend module_extend = 7; + // // 大卡模块 5 + // ModuleAdditional module_additional = 8; + // // 计数模块 8 + // ModuleStat module_stat = 9; + // // 折叠模块 9 + // ModuleFold module_fold = 10; + // // 评论外露(废弃) + // ModuleComment module_comment = 11; + // // 外露交互模块(点赞、评论) 7 + // ModuleInteraction module_interaction = 12; + // // 转发卡-原卡用户模块 + // ModuleAuthorForward module_author_forward = 13; + // // 广告卡 + // ModuleAd module_ad = 14; + // // 通栏 + // ModuleBanner module_banner = 15; + // // 获取物料失败 + // ModuleItemNull module_item_null = 16; + // // 分享组件 + // ModuleShareInfo module_share_info = 17; + // // 相关推荐模块 + // ModuleRecommend module_recommend = 18; + // // 顶部模块 + // ModuleTop module_top = 19; + // // 底部模块 + // ModuleButtom module_buttom = 20; + // // 转发卡计数模块 + // ModuleStat module_stat_forward = 21; + // // + // ModuleStory module_story = 22; + // // + // ModuleTopic module_topic = 23; + // // + // ModuleTopicDetailsExt module_topic_details_ext = 24; + // // + // ModuleTopTag module_top_tag = 25; + // // + // ModuleTopicBrief module_topic_brief = 26; + // // + // ModuleTitle module_title = 27; + // // + // ModuleButton module_button = 28; + // // + // ModuleNotice module_notice = 29; + // // + // ModuleOpusSummary module_opus_summary = 30; + // // + // ModuleCopyright module_copyright = 31; + // // + // ModuleParagraph module_paragraph = 32; + // // + // ModuleBlocked module_blocked = 33; + // // + // ModuleTextNotice module_text_notice = 34; + // // + // ModuleOpusCollection module_opus_collection = 35; + } +} +// 动态模块类型 +enum DynModuleType { + module_none = 0; // 占位 + module_author = 1; // 发布人模块 + module_dispute = 2; // 争议小黄条 + module_desc = 3; // 描述文案 + module_dynamic = 4; // 动态卡片 + module_forward = 5; // 转发模块 + module_likeUser = 6; // 点赞用户(废弃) + module_extend = 7; // 小卡模块 + module_additional = 8; // 附加卡 + module_stat = 9; // 计数信息 + module_fold = 10; // 折叠 + module_comment = 11; // 评论外露(废弃) + module_interaction = 12; // 外露交互模块(点赞、评论) + module_author_forward = 13; // 转发卡的发布人模块 + module_ad = 14; // 广告卡模块 + module_banner = 15; // 通栏模块 + module_item_null = 16; // 获取物料失败模块 + module_share_info = 17; // 分享组件 + module_recommend = 18; // 相关推荐模块 + module_stat_forward = 19; // 转发卡计数信息 + module_top = 20; // 顶部模块 + module_bottom = 21; // 底部模块 + module_story = 22; // + module_topic = 23; // + module_topic_details_ext = 24; // + module_top_tag = 25; // + module_topic_brief = 26; // + module_title = 27; // + module_button = 28; + module_notice = 29; + module_opus_summary = 30; + module_copyright = 31; + module_paragraph = 32; + module_blocked = 33; + module_text_notice = 34; + module_opus_collection = 35; +} +// 动态-发布人模块 +// message ModuleAuthor { +// // 用户mid +// int64 mid = 1; +// // 时间标签 +// string ptime_label_text = 2; +// // 用户详情 +// UserInfo author = 3; +// // 装扮卡片 +// DecorateCard decorate_card = 4; +// // 点击跳转链接 +// string uri = 5; +// // 右侧操作区域 - 三点样式 +// repeated ThreePointItem tp_list = 6; +// // 右侧操作区域样式枚举 +// ModuleAuthorBadgeType badge_type = 7; +// // 右侧操作区域 - 按钮样式 +// ModuleAuthorBadgeButton badge_button = 8; +// // 是否关注 +// // 1:关注 0:不关注 默认0,注:点赞列表使用,其他场景不使用该字段 +// int32 attend = 9; +// // 关注状态 +// Relation relation = 10; +// // 右侧操作区域 - 提权样式 +// Weight weight = 11; +// // 是否展示关注 +// bool show_follow = 12; +// // 是否置顶 +// bool is_top = 13; +// // ip属地 +// string ptime_location_text = 14; +// // +// bool show_level = 15; +// // +// OnlyFans only_fans = 16; +// } + + +// 动态-详情模块 +message ModuleDynamic { + // 类型 + ModuleDynamicType type = 1; + oneof module_item { + //稿件 + MdlDynArchive dyn_archive = 2; + // //pgc + // MdlDynPGC dyn_pgc = 3; + // //付费课程-系列 + // MdlDynCourSeason dyn_cour_season = 4; + // //付费课程-批次 + // MdlDynCourBatch dyn_cour_batch = 5; + // //转发卡 + // MdlDynForward dyn_forward = 6; + // //图文 + // MdlDynDraw dyn_draw = 7; + // //专栏 + // MdlDynArticle dyn_article = 8; + // //音频 + // MdlDynMusic dyn_music = 9; + // //通用卡方 + // MdlDynCommon dyn_common = 10; + // //直播卡 + // MdlDynLive dyn_common_live = 11; + // //播单 + // MdlDynMedialist dyn_medialist = 12; + // //小程序卡 + // MdlDynApplet dyn_applet = 13; + // //订阅卡 + // MdlDynSubscription dyn_subscription = 14; + // //直播推荐卡 + // MdlDynLiveRcmd dyn_live_rcmd = 15; + // //UGC合集 + // MdlDynUGCSeason dyn_ugc_season = 16; + // //订阅卡 + // MdlDynSubscriptionNew dyn_subscription_new = 17; + // //课程 + // MdlDynCourUp dyn_cour_batch_up = 18; + // //话题集合 + // MdlDynTopicSet dyn_topic_set = 19; + } +} +// 动态详情模块类型 +enum ModuleDynamicType { + mdl_dyn_archive = 0; // 稿件 + mdl_dyn_pgc = 1; // pgc + mdl_dyn_cour_season = 2; // 付费课程-系列 + mdl_dyn_cour_batch = 3; // 付费课程-批次 + mdl_dyn_forward = 4; // 转发卡 + mdl_dyn_draw = 5; // 图文 + mdl_dyn_article = 6; // 专栏 + mdl_dyn_music = 7; // 音频 + mdl_dyn_common = 8; // 通用卡方 + mdl_dyn_live = 9; // 直播卡 + mdl_dyn_medialist = 10; // 播单 + mdl_dyn_applet = 11; // 小程序卡 + mdl_dyn_subscription = 12; // 订阅卡 + mdl_dyn_live_rcmd = 13; // 直播推荐卡 + mdl_dyn_ugc_season = 14; // UGC合集 + mdl_dyn_subscription_new = 15; // 订阅卡 + mdl_dyn_cour_batch_up = 16; // 课程 + mdl_dyn_topic_set = 17; // 话题集合 +} +// 动态-详情模块-稿件 +message MdlDynArchive { + // 标题 + string title = 1; + // 封面图 + string cover = 2; + // 秒开地址 + string uri = 3; + // 视频封面展示项 1 + string cover_left_text_1 = 4; + // 视频封面展示项 2 + string cover_left_text_2 = 5; + // 封面视频展示项 3 + string cover_left_text_3 = 6; + // avid + int64 avid = 7; + // cid + int64 cid = 8; + // 视频源类型 + MediaType media_type = 9; + // 尺寸信息 + Dimension dimension = 10; + // 角标,多个角标之前有间距 + repeated VideoBadge badge = 11; + // 是否能够自动播放 + bool can_play= 12; + // stype + VideoType stype = 13; + // 是否PGC + bool isPGC = 14; + // inline播放地址 + string inlineURL = 15; + // PGC的epid + int64 EpisodeId = 16; + // 子类型 + int32 SubType = 17; + // PGC的ssid + int64 PgcSeasonId = 18; + // 播放按钮 + string play_icon = 19; + // 时长 + int64 duration = 20; + // 跳转地址 + string jump_url = 21; + // 番剧是否为预览视频 + bool is_preview = 22; + // 新角标,多个角标之前没有间距 + repeated VideoBadge badge_category = 23; + // 当前是否是pgc正片 + bool is_feature = 24; + // 是否是预约召回 + ReserveType reserve_type = 25; + // bvid + string bvid = 26; + // 播放数 + int32 view = 27; + // + bool show_premiere_badge = 28; + // + bool premiere_card = 29; + // + bool show_progress = 30; + // + int64 part_duration = 31; + // + int64 part_progress = 32; +} +// 播放器类型 +enum MediaType { + MediaTypeNone = 0; // 本地 + MediaTypeUGC = 1; // UGC + MediaTypePGC = 2; // PGC + MediaTypeLive = 3; // 直播 + MediaTypeVCS = 4; // 小视频 +} +// 尺寸信息 +message Dimension { + // + int64 height = 1; + // + int64 width = 2; + // + int64 rotate = 3; +} +// 角标信息 +message VideoBadge { + // 文案 + string text = 1; + // 文案颜色-日间 + string text_color = 2; + // 文案颜色-夜间 + string text_color_night = 3; + // 背景颜色-日间 + string bg_color = 4; + // 背景颜色-夜间 + string bg_color_night = 5; + // 边框颜色-日间 + string border_color = 6; + // 边框颜色-夜间 + string border_color_night = 7; + // 样式 + int32 bg_style = 8; + // 背景透明度-日间 + int32 bg_alpha = 9; + // 背景透明度-夜间 + int32 bg_alpha_night = 10; +} + +// 视频类型 +enum VideoType { + video_type_general = 0; //普通视频 + video_type_dynamic = 1; //动态视频 + video_type_playback = 2; //直播回放视频 + video_type_story = 3; // +} +// +enum ReserveType { + reserve_none = 0; // 占位 + reserve_recall = 1; // 预约召回 +} + +message Device { + int32 app_id = 1; + int32 build = 2; + string buvid = 3; + string mobi_app = 4; + string platform = 5; + string device = 6; + string channel = 7; + string brand = 8; + string model = 9; + string osver = 10; + string fp_local = 11; + string fp_remote = 12; + string version_name = 13; + string fp = 14; + int64 fts = 15; +} +message Metadata { + string access_key = 1; + string mobi_app = 2; + string device = 3; + int32 build = 4; + string channel = 5; + string buvid = 6; + string platform = 7; +} \ No newline at end of file diff --git a/res/scripts/injectExt.js b/res/scripts/injectExt.js index abcd440..37f2858 100644 --- a/res/scripts/injectExt.js +++ b/res/scripts/injectExt.js @@ -1,4 +1,4 @@ -const {protocol, session} = require('electron') +const {protocol, ipcMain} = require('electron') const https = require('https'); const HttpGet = (url, headers = {})=>{ return new Promise((resolve, reject)=>{ @@ -121,7 +121,8 @@ BrowserWindow.prototype.loadURL = function(){ }) // 设置PAC代理脚本 this.webContents.on('ipc-message-sync', (event, ...args)=>{ - if(args[0] === "config/roamingPAC"){ + if(args[0] === "config/roamingPAC") + { console.log("receive config/roamingPAC: ", ...args) const ses = this.webContents.session ses.setProxy({ @@ -171,6 +172,119 @@ BrowserWindow.prototype.loadFile = function(...args){ _loadFile.apply(this, args) // this.loadURL('http://www.jysafe.cn') } + +/** + * + * @param {string} struct + */ +const genBuffer = (struct, data) => { + const { load } = require("protobufjs"); // respectively "./node_modules/protobufjs" + return new Promise((resolve, reject) => { + try { + load(path.resolve(__dirname, './assets/protos/dynamic.proto'), function(err, root) { + if (err) + throw err; + + // example code + const AwesomeMessage = root.lookupType(`bilibili.app.dynamic.v2.${struct}`); + + let message = AwesomeMessage.create(data); + console.log(`message = ${JSON.stringify(message)}`); + + let buffer = AwesomeMessage.encode(message).finish(); + resolve(buffer) + // console.log(`buffer = ${Array.prototype.toString.call(buffer)}`); + + // let decoded = AwesomeMessage.decode(buffer); + // console.log(`decoded = ${JSON.stringify(decoded)}`); + }); + } + catch(err) { + reject(err) + } + }) +} +ipcMain.handle('roaming/queryDynamicDetail', (_, dynamicId, accessKey) => { + return new Promise(async (resolve, reject) => { + console.log('dynamic id:', dynamicId, accessKey) + + const path = require('path') + /**@type {import('@grpc/grpc-js')} */ + const grpc = require("@grpc/grpc-js"); + const protoLoader = require("@grpc/proto-loader"); + const packageDefinition = protoLoader.loadSync(path.resolve(__dirname, './assets/protos/dynamic.proto'), { + keepCase: true, + longs: String, + enums: String, + defaults: true, + oneofs: true, + }); + var proto = grpc.loadPackageDefinition(packageDefinition).bilibili.app.dynamic.v2; + + // service: Greeter + /**@type {import('@grpc/grpc-js').GrpcObject} */ + var client = new proto.Dynamic( + "grpc.biliapi.net", + grpc.credentials.createSsl() + ); + var meta = new grpc.Metadata(); + meta.add('user-agent', 'Dalvik/2.1.0 (Linux; U; Android 10; RMX2117 Build/QP1A.190711.020) 7.61.0 os/android model/Pixel XL mobi_app/android build/7610300 channel/yingyongbao innerVer/7610310 osVer/10 network/2 grpc-java-cronet/1.36.1'); + meta.add('x-bili-gaia-vtoken', ''); + meta.add('x-bili-aurora-eid', 'UlcBQFgHB1M='); + meta.add('x-bili-aurora-zone', ''); + meta.add('x-bili-trace-id', '344211a71a0dcf47432b69ac84666e79:432b69ac84666e79:0:0'); + meta.add('x-bili-fawkes-req-bin', Buffer.from('CglhbmRyb2lkNjQSBHByb2QaCDlhMjU2NWM2', 'base64')); + + const data = { + access_key: accessKey, + mobi_app: 'android', + device: 'phone', + build: 6830300, + channel: 'bili', + buvid: 'XX82B818F96FB2F312B3A1BA44DB41892FF99', + platform: 'android', + } + meta.add('x-bili-metadata-bin', await genBuffer('Metadata', data)); + meta.add('authorization', `identify_v1 ${accessKey}`); + const device = { + mobi_app: 'android', + device: 'phone', + build: 6830300, + channel: 'bili', + buvid: 'XX82B818F96FB2F312B3A1BA44DB41892FF99', + platform: 'android', + } + const d = await genBuffer('Device', device) + console.log('Device:', d.toString('base64')) + // 固定数据 + meta.add('x-bili-device-bin', d); + // 固定数据 + meta.add('x-bili-network-bin', Buffer.from('CAEaBTQ2MDAx', 'base64')); + meta.add('x-bili-restriction-bin', Buffer.from('', 'base64')); + // 固定数据 + meta.add('x-bili-locale-bin', Buffer.from('CggKAnpoGgJDThIICgJ6aBoCQ04', 'base64')); + meta.add('x-bili-exps-bin', Buffer.from('', 'base64')); + meta.add('buvid', 'XX82B818F96FB2F312B3A1BA44DB41892FF99'); + // meta.add('bili-http-engine', 'cronet'); + meta.add('te', 'trailers'); + // console.log(meta) + + const reqData = { + dynamic_id: `${dynamicId}` + } + // action: sayHello + client.DynDetail(reqData, meta, {}, (error, value) => { + if (error) { + console.log(`Received error ${error}`); + reject(error) + return; + } + console.log('Response:'); + console.log(`- ${JSON.stringify(value)}`); + resolve(value) + }) + }) +}) app.on('ready', ()=>{ // const path = require('path'); // const extPath = path.join(path.dirname(app.getAppPath()), "extensions"); diff --git a/tools/fix-other.sh b/tools/fix-other.sh index e33eaaa..3380192 100755 --- a/tools/fix-other.sh +++ b/tools/fix-other.sh @@ -64,5 +64,13 @@ cat "$root_dir/res/scripts/injectBridge.js" > "app/main/assets/temp.js" cat "app/main/assets/bili-bridge.js" >> "app/main/assets/temp.js" rm "app/main/assets/bili-bridge.js" mv "app/main/assets/temp.js" "app/main/assets/bili-bridge.js" +cp "$root_dir/res/protos/dynamic.proto" "app/main/assets/protos/dynamic.proto" +mkdir tmp +cd tmp +echo "{}" > package.json +npm install @grpc/grpc-js +cd .. +cp -rf tmp/node_modules/* app/node_modules +rm -rf tmp asar p app app.asar rm -rf app