mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-13 03:39:59 +00:00
soundcloud: fix fallback & use source mp3 if preferred
This commit is contained in:
parent
7cf08c5eeb
commit
0e6ea09b16
2 changed files with 6 additions and 4 deletions
|
@ -114,6 +114,7 @@ export default async function(host, patternMatch, url, lang, obj) {
|
|||
url,
|
||||
author: patternMatch.author,
|
||||
song: patternMatch.song,
|
||||
format: obj.aFormat,
|
||||
shortLink: patternMatch.shortLink || false,
|
||||
accessKey: patternMatch.accessKey || false
|
||||
});
|
||||
|
|
|
@ -63,11 +63,12 @@ export default async function(obj) {
|
|||
if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
|
||||
|
||||
let bestAudio = "opus",
|
||||
selectedStream = json.media.transcodings.find(v => v.preset === "opus_0_0");
|
||||
selectedStream = json.media.transcodings.find(v => v.preset === "opus_0_0"),
|
||||
mp3Media = json.media.transcodings.find(v => v.preset === "mp3_0_0");
|
||||
|
||||
// fall back to mp3 if no opus is available
|
||||
if (selectedStream.length === 0) {
|
||||
selectedStream = json.media.transcodings.find(v => v.preset === "mp3_0_0");
|
||||
// use mp3 if present if user prefers it or if opus isn't available
|
||||
if (mp3Media && (obj.format === "mp3" || !selectedStream)) {
|
||||
selectedStream = mp3Media;
|
||||
bestAudio = "mp3"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue