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

View file

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