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:
parent
276caa011a
commit
ed8af6ca96
4 changed files with 17 additions and 37 deletions
|
@ -139,39 +139,20 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
|
|||
|
||||
const serviceBestAudio = r.bestAudio || services[host]["bestAudio"];
|
||||
const isBestAudio = audioFormat === "best";
|
||||
const isBestOrMp3 = audioFormat === "mp3" || isBestAudio;
|
||||
const isBestOrMp3 = isBestAudio || audioFormat === "mp3";
|
||||
const isBestAudioDefined = isBestAudio && serviceBestAudio;
|
||||
const isBestHostAudio = serviceBestAudio && (audioFormat === serviceBestAudio);
|
||||
|
||||
const isTikTok = host === "tiktok" || host === "douyin";
|
||||
const isTumblrAudio = host === "tumblr" && !r.filename;
|
||||
const isSoundCloud = host === "soundcloud";
|
||||
|
||||
if (isTikTok && services.tiktok.audioFormats.includes(audioFormat)) {
|
||||
if (r.isMp3 && isBestOrMp3) {
|
||||
audioFormat = "mp3";
|
||||
processType = "bridge"
|
||||
} else if (isBestAudio) {
|
||||
audioFormat = "m4a";
|
||||
processType = "bridge"
|
||||
}
|
||||
}
|
||||
|
||||
if (isSoundCloud && services.soundcloud.audioFormats.includes(audioFormat)) {
|
||||
if (r.isMp3 && isBestOrMp3) {
|
||||
audioFormat = "mp3";
|
||||
processType = "render"
|
||||
copy = true
|
||||
} else if (isBestAudio || audioFormat === "opus") {
|
||||
audioFormat = "opus";
|
||||
processType = "render"
|
||||
copy = true
|
||||
}
|
||||
}
|
||||
|
||||
if (isBestAudioDefined || isBestHostAudio) {
|
||||
audioFormat = serviceBestAudio;
|
||||
processType = "bridge";
|
||||
if (isSoundCloud) {
|
||||
processType = "render"
|
||||
copy = true
|
||||
}
|
||||
} else if (isBestAudio && !isSoundCloud) {
|
||||
audioFormat = "m4a";
|
||||
copy = true
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,9 @@ export default async function(obj) {
|
|||
detail = detail?.aweme_list?.find(v => v.aweme_id === postId);
|
||||
if (!detail) return { error: 'ErrorCouldntFetch' };
|
||||
|
||||
let video, videoFilename, audioFilename, isMp3, audio, images,
|
||||
filenameBase = `tiktok_${detail.author.unique_id}_${postId}`;
|
||||
let video, videoFilename, audioFilename, audio, images,
|
||||
filenameBase = `tiktok_${detail.author.unique_id}_${postId}`,
|
||||
bestAudio = 'm4a';
|
||||
|
||||
images = detail.image_post_info?.images;
|
||||
|
||||
|
@ -56,12 +57,12 @@ export default async function(obj) {
|
|||
} else {
|
||||
let fallback = playAddr.url_list[0];
|
||||
audio = fallback;
|
||||
audioFilename = `${filenameBase}_audio_fv`; // fv - from video
|
||||
audioFilename = `${filenameBase}_audio`;
|
||||
if (obj.fullAudio || fallback.includes("music")) {
|
||||
audio = detail.music.play_url.url_list[0]
|
||||
audioFilename = `${filenameBase}_audio`
|
||||
audioFilename = `${filenameBase}_audio_original`
|
||||
}
|
||||
if (audio.slice(-4) === ".mp3") isMp3 = true;
|
||||
if (audio.slice(-4) === ".mp3") bestAudio = 'mp3';
|
||||
}
|
||||
|
||||
if (video) return {
|
||||
|
@ -72,7 +73,7 @@ export default async function(obj) {
|
|||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3
|
||||
bestAudio
|
||||
}
|
||||
if (images) {
|
||||
let imageLinks = [];
|
||||
|
@ -86,13 +87,13 @@ export default async function(obj) {
|
|||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3
|
||||
bestAudio
|
||||
}
|
||||
}
|
||||
if (audio) return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3
|
||||
bestAudio
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
"alias": "tiktok videos, photos & audio",
|
||||
"patterns": [":user/video/:postId", ":id", "t/:id", ":user/photo/:postId"],
|
||||
"subdomains": ["vt", "vm"],
|
||||
"audioFormats": ["best", "m4a", "mp3"],
|
||||
"enabled": true
|
||||
},
|
||||
"douyin": {
|
||||
|
@ -74,7 +73,6 @@
|
|||
"soundcloud": {
|
||||
"patterns": [":author/:song/s-:accessKey", ":author/:song", ":shortLink"],
|
||||
"subdomains": ["on", "m"],
|
||||
"audioFormats": ["best", "opus", "mp3"],
|
||||
"enabled": true
|
||||
},
|
||||
"instagram": {
|
||||
|
|
Loading…
Reference in a new issue