feat: add FLAC lossless format support#316
feat: add FLAC lossless format support#316kokarare1212 merged 2 commits intokokarare1212:mainfrom akbad:feat/add-flac
Conversation
- Bug existed since #8 - Resurfaced while adding FLAC
…while staying backward compatible) - Add `FLAC_FLAC` (16), `FLAC_FLAC_24BIT` (22) format codes (based on librespot-org/librespot#796, librespot-org/librespot#1424) - Regenerate Metadata_pb2.py with protoc 3.20.1 - Add enums: `SuperAudioFormat.FLAC`, `AudioQuality.LOSSLESS` - Refactor to generic DRY `FormatOnlyAudioQuality` base class while maintaining existing `VorbisOnlyAudioQuality` as wrapper - Remove `AAC_24_NORM` (replaced by `FLAC_FLAC` at code 16)
|
Please note the failed DeepSource Python check stems from me reusing the existing way of formatting strings for the logger within my changes. Let me know if this is something I should update. |
|
Thanks for the PR! |
|
@akbad I've implemented this lossless format in a downstream project, but I'm having no luck getting FLAC files (even with songs that the mainline app claims to have lossless versions of). All Did you confirm it worked properly for your setup, and if so, can you provide a few songs (preferably links or uuids) that you saw success with so that I can try to replicate it? |
|
@Googolplexed0 I tried the same thing and sadly it didn't work properly. I looked into it and my conclusion is that everything in this PR is indeed needed to support FLAC, and it's simply the Spotify endpoints used that aren't serving FLAC files in response to our requests. My guess is that there's some secret sauce in the Spotify desktop client's requests that we need to replicate somehow here in order to get it to serve us FLAC files. I tried tracing how Spotify's desktop client does it (i.e. using |
I would assume you are correct, given how long it took them to roll out this particular feature.
Bummer. If you have some advice on how I could help with the snooping efforts, let me know. I would really like to gain this functionality if possible. |
|
Created an issue to track this #320 |
Hooking up the changes from kokarare1212/librespot-python#316
|
I tried starting to trace as well but didn't conclude anything productive. FWIW, I found the following setup quite nice to trace (to circumvent certificate pinning etc.), although also a bit over-engineered.
Then, use HTTPToolkit to Intercept from Android Emulator using Frida.
You can also use e.g. blackboxprotobuf to decode some protobufs. But I'm too tired for that now. |
Summary
Details
Add
FLAC_FLAC(16) andFLAC_FLAC_24BIT(22) format codes tometadata.protoMetadata_pb2.pywith protoc 3.20.1 (as in requirements)AAC_24_NORMas done upstream (format that previously occupied code 16)Add enum values for FLAC:
SuperAudioFormat.FLACmaps FLAC formats to FLAC container typeAudioQuality.LOSSLESSmaps FLAC formats to lossless quality tierRefactor to generic DRY
FormatOnlyAudioQualitybase class, while maintaining 100% backward compatibility via:VorbisOnlyAudioQualityas a wrapperLosslessOnlyAudioQualitywrapper for FLAC file selectionAlso fixes minor bug within unknown-format error in decoders.py