From a49ad76c6cfff9bfcc67c2b9e20f3ee2897a4a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=84=86=E8=96=AF=E9=A5=BC?= Date: Sun, 10 Nov 2024 21:16:24 +0800 Subject: [PATCH] fix(Translate.response): YouTube Music Update Translate.response.dev.js Update Translate.response.js Update CHANGELOG.md --- CHANGELOG.md | 7 +------ src/Translate.response.dev.js | 6 +++--- src/Translate.response.js | 6 +++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e920444..97686438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,6 @@ ### 🛠️ Bug Fixes - * 修复 `External.Lyrics.response` 发送请求时错误将字符串 `encodeURIComponent` 两次的问题 + * 修复 `Translate.response` 未能成功识别翻译 `YouTube Music` app 歌词的问题 ### 🔣 Dependencies - * 升级了 `@nsnanocat/util` - * `$platform` 改为 `$app` * 增加了 `@nsnanocat/url` * 使用了全新的 `URL` 和 `URLSearchParams` polyfill - -### 🔄 Other Changes - * 重构了 `detectPlatform` diff --git a/src/Translate.response.dev.js b/src/Translate.response.dev.js index 3306caa4..632fc473 100644 --- a/src/Translate.response.dev.js +++ b/src/Translate.response.dev.js @@ -239,10 +239,10 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); }); } Languages[0] = "AUTO"; - if (body?.contents?.elementRenderer?.n7F172660663?.n8F1?.n9F168777401?.n10F5?.n11F465160965?.n12F4?.n13F1) { - const fullText = body.contents.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map(line => line?.f1 ?? "\u200b"); + if (body?.contents?.renderer?.elementRenderer?.n7F172660663?.n8F1?.n9F168777401?.n10F5?.n11F465160965?.n12F4?.n13F1) { + const fullText = body.contents.renderer.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map(line => line?.f1 ?? "\u200b"); const translation = await Translator(Settings.Vendor, Settings.Method, fullText, Languages, Settings?.[Settings?.Vendor], Settings?.Times, Settings?.Interval, Settings?.Exponential); - body.contents.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1 = body.contents.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map((line, i) => { + body.contents.renderer.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1 = body.contents.renderer.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map((line, i) => { if (line?.f1) line.f1 = combineText(line.f1, translation?.[i], Settings?.ShowOnly, Settings?.Position); return line; }); diff --git a/src/Translate.response.js b/src/Translate.response.js index ff1db0ff..28e66a07 100644 --- a/src/Translate.response.js +++ b/src/Translate.response.js @@ -196,10 +196,10 @@ log(`⚠ FORMAT: ${FORMAT}`, ""); case "YouTube": { body = BrowseResponse.fromBinary(rawBody); Languages[0] = "AUTO"; - if (body?.contents?.elementRenderer?.n7F172660663?.n8F1?.n9F168777401?.n10F5?.n11F465160965?.n12F4?.n13F1) { - const fullText = body.contents.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map(line => line?.f1 ?? "\u200b"); + if (body?.contents?.renderer?.elementRenderer?.n7F172660663?.n8F1?.n9F168777401?.n10F5?.n11F465160965?.n12F4?.n13F1) { + const fullText = body.contents.renderer.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map(line => line?.f1 ?? "\u200b"); const translation = await Translator(Settings.Vendor, Settings.Method, fullText, Languages, Settings?.[Settings?.Vendor], Settings?.Times, Settings?.Interval, Settings?.Exponential); - body.contents.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1 = body.contents.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map((line, i) => { + body.contents.renderer.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1 = body.contents.renderer.elementRenderer.n7F172660663.n8F1.n9F168777401.n10F5.n11F465160965.n12F4.n13F1.map((line, i) => { if (line?.f1) line.f1 = combineText(line.f1, translation?.[i], Settings?.ShowOnly, Settings?.Position); return line; });