Skip to content

Conversation

@deuslhepague
Copy link
Contributor

@deuslhepague deuslhepague commented Oct 28, 2025

Spotify made an update where it only returned file IDs in OGG and AAC_24 in gid_metadata, and this is my attempt to fix it. #74

I also updated the TOTP link (got it from the Discord server, thanks to whoever made it). #75

Added new TRACK_PLAYBACK_API_URL and updated methods to use token headers for authorization.
Enhance get_gid_metadata to include additional metadata handling and file ID extraction for playback information.
@frozenisback
Copy link

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\PC> votify "https://open.spotify.com/episode/3kwxWnzGH8T6UY2Nq582zx"
[INFO 11:55:19] Starting Votify
Traceback (most recent call last):
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\utils.py", line 14, in check_response
response.raise_for_status()
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 1026, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://open.spotify.com/api/token?reason=init&productType=web-player&totp=035426&totpServer=035426&totpVer=61&_authfailed=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Scripts\votify.exe_main
.py", line 7, in
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\cli.py", line 429, in main
spotify_api = SpotifyApi.from_cookies_file(cookies_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\spotify_api.py", line 76, in from_cookies_file
return cls(sp_dc=sp_dc)
^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\spotify_api.py", line 56, in init
self._set_session()
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\spotify_api.py", line 82, in _set_session
self._setup_authorization()
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\spotify_api.py", line 166, in _setup_authorization
self._setup_authorization_with_totp()
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\spotify_api.py", line 135, in _setup_authorization_with_totp
check_response(response)
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\utils.py", line 16, in check_response
_raise_response_exception(response)
File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\utils.py", line 20, in _raise_response_exception
raise Exception(
Exception: Request failed with status code 401: {"error":{"code":401,"message":"Unauthorized","trace":"eyJoYXNoIjoiMWExZWJlNzVjNjE0YTFmOCIsImVuY3J5cHRlZCI6IjEyZTBjNGIxNTFlMTNmZTg5NmQ3ZDBmNDAxZTZlMDdkNGI0YTNhYzY4ZTBlMGFiN2JjOWMwN2I4MmFkMTg2NmE1NzJlYWQ4YWZlM2QwYzA1ZWExNjFmYTlhNDc4Yzc5ODAyZGM2Y2RjOGYyYWU3YmI3OWMxN2Y2N2U0NWM3MDQyZWI2Mzc0ZjYzOWEzZTU5NmFiN2MzMzZhNzY3NWU4ZmNmNGY3M2VlZmQyNWVlNGNmYzA1NjZkM2MzZDBlNTMzMWFkOWExMzkxZWRkMmZjOWZiOWJhZjFkYTIxYjY1OGQ3MDk1MjM3NzZjZmM4NWZjYjQwMWY0MzcwZjkxOTA2ZTA0ODVlM2ZmYmUxMWMxNWMzN2UyNGZkMjM3M2JmMmMzYmE2ZTEyZGVlOTUwZTI0MWEyOTI4NGVkNjI1OTAxMWE0MWVjZjdiYTQ0M2QxMmM0YTlkNjlkNTMwYWQ5OWQxMGM4ZDg4MmU3ZjE2NjYxNjliZDYyNjg2ZGU2NDQ5M2E4N2YwYmNkMGE5NGQxYWZhMjRiNTU4M2RlYmFiYmQ3ZmFiM2FlMDE3YzA1NmVmZTNiMmY2NDM2OTRlYmMwYWFmNzczMTA4OWQ2NTlmNGIyMzQ1Nzc4MzYxN2Q5OTYzY2IyMzZiYTRlNmQ2NjFlOTQ4OTRjOWE1MDAwZWFiOTkwZmI2NTlkZmM1YWM1MDU3ZWUzZThkZWY2ZDI2Y2FhYmQ0NDZkYWZiNjNjMWFlM2M3NTA2NGU2ODZmODczMTMzNjgyNmJjMGJjNjNjZWIxZTExNGViMzZiMzk0ZWY5IiwiaXYiOiIyNTQ3NDc2ZWY2ZTliODM0MTE5M2M3NzkxYWY0OGI3ZiIsImF1dGhUYWciOiJmYTY0NjQzNTA3ZDljOWQ1OWM1YmZhMjUzODQ3OTg3NSIsInRpbWVzdGFtcCI6IjIwMjUtMTAtMjlUMDY6MjU6NTAuMjIxWiJ9"}}
PS C:\Users\PC>

bro i tried your fork but its also not working

@deuslhepague
Copy link
Contributor Author

PS C:\Users\PC> votify "https://open.spotify.com/episode/3kwxWnzGH8T6UY2Nq582zx" [INFO 11:55:19] Starting Votify Traceback (most recent call last): File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\votify\utils.py", line 14, in check_response response.raise_for_status() File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 1026, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://open.spotify.com/api/token?reason=init&productType=web-player&totp=035426&totpServer=035426&totpVer=61&_authfailed=1
bro i tried your fork but its also not working

That happened here too. But when I exported the cookies again, it worked.

@yashikada
Copy link

Good patch for solve #76 but wrong PR.
You should not include the patch of other PRs, because then there will be conflicts during the merge.

@deuslhepague deuslhepague marked this pull request as draft November 4, 2025 19:55
@deuslhepague deuslhepague marked this pull request as ready for review November 4, 2025 20:02
@deuslhepague
Copy link
Contributor Author

Good patch for solve #76 but wrong PR. You should not include the patch of other PRs, because then there will be conflicts during the merge.

Thank you, and I apologize. I don't know what I was thinking when I thought it would be a good idea to mix them. You're right.

@deuslhepague
Copy link
Contributor Author

If we change file_ids_mp4 to file_ids_mp4flac, the API returns the file_id for MP4_FLAC.

However, MP4_FLAC is format 17. So, STREAM_URLS_API_URL will probably have to be changed for votify to support lossless in the future to something like:

STREAM_URLS_API_URL = (“https://gue1-spclient.spotify.com/storage-resolve/v2/files/audio/interactive/{format}/{file_id}?version=10000000&product=9&platform=39&alt=json”)

Example:
https://gue1-spclient.spotify.com/storage-resolve/v2/files/audio/interactive/17/6ccf387b9185fcd54f137c9416e9c99c36068bc9?version=10000000&product=9&platform=39&alt=json

You can verify that this type of format is protected by Widevine at https://seektables.scdn.co/seektable/6ccf387b9185fcd54f137c9416e9c99c36068bc9.json, as it contains PSSH and pssh_widevine (which are the same). However, attempting to obtain the license did not work here.

Here is a list of the most common formats and their respective DRMs:

OGG_VORBIS_96 = 0; // playplay
OGG_VORBIS_160 = 1; // playplay
OGG_VORBIS_320 = 2; // playplay
AAC_24 = 8; // playplay
MP4_128 = 10; // widevine
MP4_256 = 11; // widevine
MP4_128_DUAL = 12; // playready / widevine
MP4_256_DUAL = 13; // playready / widevine
MP4_128_CBCS = 14; // fairplay
MP4_256_CBCS = 15; // fairplay
FLAC_FLAC = 16; // playplay
MP4_FLAC = 17; // widevine
FLAC_FLAC_24BIT = 22; // playplay

Apparently, MP4_FLAC_24BIT exists and is format 23. But I couldn't find it anywhere.

@ar5hil
Copy link

ar5hil commented Nov 18, 2025

works like a charm

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.

4 participants