Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FLAC support #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add FLAC support #111

wants to merge 2 commits into from

Conversation

10p3
Copy link

@10p3 10p3 commented May 30, 2024

I've used this to download a couple of playlists and it seems to work so far (using the free trial).
It'd be good if someone could test that it doesn't break operation with free accounts since i don't currently have one.
I've yet to observe any songs with AAC as an option so the change to the "exists already" check doesn't handle that yet.
I'm not sure how robust the error handling is if the server returns results in an unexpected format.

The web client gets media urls with a seperate API call using TRACK_TOKEN from the song data, the encryption on FLACs seems unchanged.
Some songs have a "Fallback" to a different ID and do not allow downloads using the original id, this is currently handled after failing on the original file but it might be worth not trying the original if a fallback is supplied.

@mryan43
Copy link

mryan43 commented Jun 9, 2024

Small comment to mention that I have tested this (with a non-free account) and it works for me ! thanks a lot !

@kmille
Copy link
Owner

kmille commented Nov 22, 2024

sorry for not taking care :(
Currently don't have time for it. There was something I didn't like - I think it was just renameing mp3 to flac file ending...

@10p3
Copy link
Author

10p3 commented Nov 22, 2024

I'm not sure I understand.
Is there something I could do to help fix it?
I don't have a premium account to test with at the moment but it definitely was working with a playlist I tried when I wrote it.
image

@kmille
Copy link
Owner

kmille commented Nov 22, 2024

yea, thanks for the PR. I just need some time for this.

@kito30
Copy link

kito30 commented Nov 27, 2024

it seems that for me, I can only download 128kbps not 320

@e-nicolas
Copy link

Worked well with a premium account!.

With a free account deezer returned 403 if I tried to download sound_quality = 3 (flac)

@krististefa1
Copy link

krististefa1 commented Jan 30, 2025

Maybe I'm a noob, but how does one run the PR? Do you have to clone down the commits and run through the poetry build process?

@mryan43
Copy link

mryan43 commented Jan 31, 2025

if you're running with docker you can use the image I have built : mryan/deezer-downloader:shamu

@kmille
Copy link
Owner

kmille commented Feb 5, 2025

Hey @10p3
can you explain a bit the usage of web_sound_quality and song.get('FALLBACK')? It's hard to understand when reading the code.

Can you tell my when/how often this case is relevant?

if not data['data'][0].get('media'):
    print(data)
    sleep((random.random()+2**i))
    return get_song_url(song, i+1)

I also have some troubles understanding the logic of get_song_url:

if i == 1 and song.get('FALLBACK'):
    song = song['FALLBACK']
  • first run with i=0 - if that fails, call the function with i=1 (why do we wait here? why random sleep)?
  • when i>2, then an exception is raised
  • so there is the case i=1 left. There two relevant cases: song.get('FALLBACK') is None or not
    • when song.get('FALLBACK') is None: Then the function does the same when called with i=1 (and always fails like in the first run) or am I wrong here?

Before you change anything: I'm currently trying to review/merge #133. I fix some things like the Exception handling and smaller issues. The MR contains parts of your changes. So let's merge that before. Right now I'm failing to push into branch of the MR...

@10p3
Copy link
Author

10p3 commented Feb 5, 2025

Hi
web_sound_quality is there so the quality profiles the current account is allowed to use - which is used to detect premium accounts (which include a lossless profile) and use the new download logic in that case.

song.get('FALLBACK') is there since (with the playlist i was trying to download when I wrote this) there were some songs that seemed to error (I think this may have been a region/license issue).
The API sometimes provides a fallback song that in my experience has the same title/artist but is a different rendition.

As for the random sleep, honestly I don't recall - sorry. Maybe I was thinking ratelimits on a large number of requests?

If there isn't a fallback then I'd imagine it would fail like i=1 unless there was some other network issue or something, it might make more sense to just raise the exception immediately if there isn't a fallback.

sorry not sure I'm any help with your force-push issue, good luck though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants