From 5b61e95c1f372ea731929ba02964376b7c2f29db Mon Sep 17 00:00:00 2001 From: wukko Date: Tue, 23 Aug 2022 21:05:30 +0600 Subject: [PATCH] oops: part 2 --- src/modules/servicesConfig.json | 1 + src/modules/sub/matchActionDecider.js | 30 +++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/modules/servicesConfig.json b/src/modules/servicesConfig.json index e4d094b..890261d 100644 --- a/src/modules/servicesConfig.json +++ b/src/modules/servicesConfig.json @@ -59,6 +59,7 @@ }, "tiktok": { "patterns": [":user/video/:postId", ":id", "t/:id"], + "audioFormats": ["best", "m4a", "mp3"], "enabled": true }, "douyin": { diff --git a/src/modules/sub/matchActionDecider.js b/src/modules/sub/matchActionDecider.js index cee9860..db73f0c 100644 --- a/src/modules/sub/matchActionDecider.js +++ b/src/modules/sub/matchActionDecider.js @@ -45,9 +45,24 @@ export default function(r, host, ip, audioFormat, isAudioOnly) { return apiJSON(1, { u: r.urls }) } } else { - let type = "render" - let copy = false + if (host == "reddit" && r.typeId == 1 || audioIgnore.includes(host)) return apiJSON(0, { t: r.audioFilename }); + + let type = "render"; + let copy = false; if (!supportedAudio.includes(audioFormat)) audioFormat = "best"; + + if ((host == "tiktok" || host == "douyin") && r.isAudio && services.tiktok.audioFormats.includes(audioFormat)) { + if (r.isMp3) { + if (audioFormat == "mp3" || audioFormat == "best") { + audioFormat = "mp3" + type = "bridge" + } + } else if (audioFormat == "best") { + audioFormat = "m4a" + type = "bridge" + } + } + if ((audioFormat == "best" && services[host]["bestAudio"]) || services[host]["bestAudio"] && (audioFormat == services[host]["bestAudio"])) { audioFormat = services[host]["bestAudio"] type = "bridge" @@ -55,17 +70,6 @@ export default function(r, host, ip, audioFormat, isAudioOnly) { audioFormat = "m4a" copy = true } - if ((host == "tiktok" || host == "douyin") && r.isAudio && audioFormat == "best") { - if (r.isMp3) { - audioFormat = "mp3" - type = "bridge" - copy = false - } else { - type = "bridge" - copy = false - } - } - if (host == "reddit" && r.typeId == 1 || audioIgnore.includes(host)) return apiJSON(0, { t: r.audioFilename }); return apiJSON(2, { type: type, u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,