acgonzales / pydeezer

A package to search and download musics on Deezer.
The Unlicense
52 stars 14 forks source link

Track quality is ALWAYS defaulting to 120kbps. #4

Closed acgonzales closed 4 years ago

acgonzales commented 4 years ago

Deezer's API now emits the other qualities' filesize on the json object they're giving. Like so...

{
   .... ,
   'FILESIZE': '3602807',
   'FILESIZE_AAC_64': '0',
   'FILESIZE_FLAC': '0',
   'FILESIZE_MP3_128': '3602807',
   'FILESIZE_MP3_256': '0',
   'FILESIZE_MP3_320': '0',
   'FILESIZE_MP3_64': '0',
   'FILESIZE_MP4_RA1': '0',
   'FILESIZE_MP4_RA2': '0',
   'FILESIZE_MP4_RA3': '0',
   .....
}

Before, FLAC and MP3_320 almost always have a filesize > 0. I made sure that the track has FLAC and MP3_320 available by hard-coding their quality code on the get_track_download_url().

FLAC = 9 MP3_320 = 5

Before:

def get_track_download_url(self, ....):
   ...

   quality = self._select_valid_quality(track, quality)

   magic_char = "¤"
   step1 = magic_char.join((md5_origin,
                            str(quality["code"]),
                            track_id,
                            media_version))

To:

def get_track_download_url(self, ....):
   ...

   quality = self._select_valid_quality(track, quality)

   magic_char = "¤"
   step1 = magic_char.join((md5_origin,
                            "9",
                            track_id,
                            media_version))

And it downloads just right if it really does have the given quality. The track that really doesn't have the given quality will return a 403 status code when accessed/requested.

My current algorithm on getting the valid quality is to check that same json object then get all qualities that have a value that is > 0 that's why it's defaulting to 120kbps.

To solve the issue, I'm gonna want to check all the qualities and see if they return a 403 or not. Caveats are this is slow because it makes an http request for each quality to be tested.

Let me know if you have any ideas.

auslegungssache commented 4 years ago

This could be helpful https://notabug.org/RemixDev/deemix/commit/89adebd08e887e408b14bcb42f2562a423a00382

rnyPlanet commented 3 years ago

This could be helpful https://notabug.org/RemixDev/deemix/commit/89adebd08e887e408b14bcb42f2562a423a00382

can you share?

picciottino commented 3 years ago

I have only experienced this in the last few days (I might have accidentally updated to a non-up-to-date file?) My quality = self._select_valid_quality(track, quality) line is commented and using the "9" results in no download for me :/ Any help?

MRKaZ commented 3 years ago

@acgonzales Deezer patched their 320 URL generation as well!, Now you need a premium account to download 320Kbps and need a HI-FI account to download FLAC and 320bps, With your information Deezer able to give 128Kbps quality tracks to listen you! because your account is still FREE!