Fixed alternative checking

This commit is contained in:
RemixDev 2021-07-28 13:07:24 +02:00
parent 5d2c7ff200
commit e0c72296d3

View file

@ -76,7 +76,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
if (track.localTrack) { return TrackFormats.LOCAL} if (track.localTrack) { return TrackFormats.LOCAL}
let falledBack = false let falledBack = false
let hasAlternative = track.fallbackID !== "0" let hasAlternative = track.fallbackID != 0
let isGeolocked = false let isGeolocked = false
let wrongLicense = false let wrongLicense = false
@ -157,17 +157,17 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
// Current bitrate is higher than preferred bitrate; skip // Current bitrate is higher than preferred bitrate; skip
if (formatNumber > preferredBitrate) { continue } if (formatNumber > preferredBitrate) { continue }
let url
let currentTrack = track let currentTrack = track
let url = await getCorrectURL(currentTrack, formatName, formatNumber)
let newTrack let newTrack
do { do {
url = await getCorrectURL(currentTrack, formatName, formatNumber) if (!url && hasAlternative){
if (hasAlternative && !url){
newTrack = await dz.gw.get_track_with_fallback(currentTrack.fallbackID) newTrack = await dz.gw.get_track_with_fallback(currentTrack.fallbackID)
currentTrack = new Track() currentTrack = new Track()
currentTrack.parseEssentialData(newTrack) currentTrack.parseEssentialData(newTrack)
hasAlternative = currentTrack.fallbackID !== "0" hasAlternative = currentTrack.fallbackID != 0
} }
url = await getCorrectURL(currentTrack, formatName, formatNumber)
} while (!url && hasAlternative) } while (!url && hasAlternative)
if (url) { if (url) {