mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-12 11:52:12 +01: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,
|
url,
|
||||||
author: patternMatch.author,
|
author: patternMatch.author,
|
||||||
song: patternMatch.song,
|
song: patternMatch.song,
|
||||||
|
format: obj.aFormat,
|
||||||
shortLink: patternMatch.shortLink || false,
|
shortLink: patternMatch.shortLink || false,
|
||||||
accessKey: patternMatch.accessKey || false
|
accessKey: patternMatch.accessKey || false
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,11 +63,12 @@ export default async function(obj) {
|
||||||
if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
|
if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
let bestAudio = "opus",
|
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
|
// use mp3 if present if user prefers it or if opus isn't available
|
||||||
if (selectedStream.length === 0) {
|
if (mp3Media && (obj.format === "mp3" || !selectedStream)) {
|
||||||
selectedStream = json.media.transcodings.find(v => v.preset === "mp3_0_0");
|
selectedStream = mp3Media;
|
||||||
bestAudio = "mp3"
|
bestAudio = "mp3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue