oops: part 2

This commit is contained in:
wukko 2022-08-23 21:05:30 +06:00
parent 7472b1732a
commit 5b61e95c1f
2 changed files with 18 additions and 13 deletions

View file

@ -59,6 +59,7 @@
}, },
"tiktok": { "tiktok": {
"patterns": [":user/video/:postId", ":id", "t/:id"], "patterns": [":user/video/:postId", ":id", "t/:id"],
"audioFormats": ["best", "m4a", "mp3"],
"enabled": true "enabled": true
}, },
"douyin": { "douyin": {

View file

@ -45,9 +45,24 @@ export default function(r, host, ip, audioFormat, isAudioOnly) {
return apiJSON(1, { u: r.urls }) return apiJSON(1, { u: r.urls })
} }
} else { } else {
let type = "render" if (host == "reddit" && r.typeId == 1 || audioIgnore.includes(host)) return apiJSON(0, { t: r.audioFilename });
let copy = false
let type = "render";
let copy = false;
if (!supportedAudio.includes(audioFormat)) audioFormat = "best"; 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"])) { if ((audioFormat == "best" && services[host]["bestAudio"]) || services[host]["bestAudio"] && (audioFormat == services[host]["bestAudio"])) {
audioFormat = services[host]["bestAudio"] audioFormat = services[host]["bestAudio"]
type = "bridge" type = "bridge"
@ -55,17 +70,6 @@ export default function(r, host, ip, audioFormat, isAudioOnly) {
audioFormat = "m4a" audioFormat = "m4a"
copy = true 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, { return apiJSON(2, {
type: type, type: type,
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip, u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,