tiktok & soundcloud: proper best audio picking

also improved tiktok audio file naming scheme. full audio now has the "_audio_original" tag. audio extracted from video is simply "_audio".
This commit is contained in:
wukko
2024-04-30 13:22:29 +06:00
parent 276caa011a
commit ed8af6ca96
4 changed files with 17 additions and 37 deletions

View File

@@ -63,13 +63,13 @@ export default async function(obj) {
if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
let isMp3,
let bestAudio = 'opus',
selectedStream = json.media.transcodings.filter(v => v.preset === "opus_0_0")
// fall back to mp3 if no opus is available
if (selectedStream.length === 0) {
selectedStream = json.media.transcodings.filter(v => v.preset === "mp3_0_0")
isMp3 = true
bestAudio = 'mp3'
}
let fileUrlBase = selectedStream[0]["url"];
let fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
@@ -94,7 +94,7 @@ export default async function(obj) {
title: fileMetadata.title,
author: fileMetadata.artist
},
isMp3,
bestAudio,
fileMetadata
}
}