mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 01:18:27 +00:00
api/soundcloud: ignore encrypted protocols, match against prefix
This commit is contained in:
parent
2154f464d7
commit
adc5b89fc2
@ -43,12 +43,14 @@ async function findClientID() {
|
|||||||
const findBestForPreset = (transcodings, preset) => {
|
const findBestForPreset = (transcodings, preset) => {
|
||||||
let inferior;
|
let inferior;
|
||||||
for (const entry of transcodings) {
|
for (const entry of transcodings) {
|
||||||
if (entry.snipped) {
|
const protocol = entry?.format?.protocol;
|
||||||
|
|
||||||
|
if (entry.snipped || protocol?.includes('encrypted')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.preset === preset) {
|
if (entry?.preset?.startsWith(`${preset}_`)) {
|
||||||
if (entry?.format?.protocol === 'progressive') {
|
if (protocol === 'progressive') {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,9 +110,9 @@ export default async function(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let bestAudio = "opus",
|
let bestAudio = "opus",
|
||||||
selectedStream = findBestForPreset(json.media.transcodings, "opus_0_0");
|
selectedStream = findBestForPreset(json.media.transcodings, "opus");
|
||||||
|
|
||||||
const mp3Media = findBestForPreset(json.media.transcodings, "mp3_0_0");
|
const mp3Media = findBestForPreset(json.media.transcodings, "mp3");
|
||||||
|
|
||||||
// use mp3 if present if user prefers it or if opus isn't available
|
// use mp3 if present if user prefers it or if opus isn't available
|
||||||
if (mp3Media && (obj.format === "mp3" || !selectedStream)) {
|
if (mp3Media && (obj.format === "mp3" || !selectedStream)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user