getTrackDownloadUrl: restore 320kbps downloads for free users

The encrypted fallback method still allows 320kbps downloads
This commit is contained in:
Namkhai B 2021-08-03 16:47:26 -05:00
parent e2d488bf21
commit 93b24c7c8d
No known key found for this signature in database
GPG Key ID: 9DC021F538318528

View File

@ -66,6 +66,7 @@ const getTrackUrlFromServer = async (track_token: string, format: string): Promi
* @param quality 1 = 128kbps, 3 = 320kbps and 9 = flac (around 1411kbps)
*/
export const getTrackDownloadUrl = async (track: trackType, quality: number): Promise<{trackUrl: string, isEncrypted: boolean, fileSize: number} | null> => {
let wrongLicense = false;
let formatName: string;
switch (quality) {
case 9:
@ -96,7 +97,7 @@ export const getTrackDownloadUrl = async (track: trackType, quality: number): Pr
}
} catch (err) {
if (err instanceof WrongLicense) {
throw new Error(`Your account can't stream ${formatName} tracks`);
wrongLicense = true;
} else {
throw err;
}
@ -113,6 +114,7 @@ export const getTrackDownloadUrl = async (track: trackType, quality: number): Pr
fileSize: fileSize,
};
}
if (wrongLicense) throw new Error(`Your account can't stream ${formatName} tracks`);
return null;
};