Code parity between libraries

This commit is contained in:
RemixDev 2021-08-02 23:08:06 +02:00
parent d5a22abbe2
commit 77e453c5ed
2 changed files with 5 additions and 7 deletions

View file

@ -102,7 +102,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
formats = {...formats_non_360}
}
async function testURL(track, url, formatNumber, formatName){
async function testURL(track, url, formatName){
let request
try{
request = got.get(
@ -121,7 +121,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
return true
}
if (e instanceof got.ReadError || e instanceof got.TimeoutError){
return await testURL(track, url, formatNumber, formatName)
return await testURL(track, url, formatName)
}
if (e instanceof got.HTTPError) return false
console.trace(e)
@ -134,8 +134,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
let url
try {
url = await dz.get_track_url(track.trackToken, formatName)
let isUrlOk = await testURL(track, url, formatNumber, formatName)
if (isUrlOk) return url
if (await testURL(track, url, formatName, formatNumber)) return url
url = undefined
} catch (e){
wrongLicense = (e.name === "WrongLicense")
@ -144,8 +143,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
// Fallback to old method
if (!url){
url = generateCryptedStreamURL(track.id, track.MD5, track.mediaVersion, formatNumber)
let isUrlOk = await testURL(track, url, formatNumber, formatName)
if (isUrlOk) return url
if (await testURL(track, url, formatName, formatNumber)) return url
url = undefined
}
return url

View file

@ -35,8 +35,8 @@ class IDownloadObject{
failed: this.failed,
progress: this.progress,
errors: this.errors,
extrasPath: this.extrasPath,
files: this.files,
extrasPath: this.extrasPath,
__type__: this.__type__
}
}