librespot-python icon indicating copy to clipboard operation
librespot-python copied to clipboard

[BUG] Failed fetching audio key! gid

Open Masterolic opened this issue 1 year ago • 16 comments

Traceback (most recent call last): File "/root/Spotify-downloa-bot/mbot/plugins/Spotify.py", line 166, in spotify_dl await create_task(episode_down(item , item_name, randomdir , Mbot , message, get_prem)) File "/root/Spotify-downloa-bot/mbot/utils/SpotDL.py", line 97, in episode_down randomfile = await create_task(download_file(session, episode_id, randomdir, get_prem)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/Spotify-downloa-bot/mbot/utils/SpotDL.py", line 58, in download_file stream = session.content_feeder().load(episode_id, VorbisOnlyAudioQuality(AudioQuality.HIGH), False, None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/librespot/audio/init.py", line 742, in load return self.load_episode(playable_id, audio_quality_picker, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/librespot/audio/init.py", line 780, in load_episode return self.load_stream(file, None, episode, preload, halt_listener) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/librespot/audio/init.py", line 756, in load_stream return CdnFeedHelper.load_episode(self.__session, episode, file, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/librespot/audio/init.py", line 391, in load_episode key = session.audio_key().get_audio_key(episode.gid, file.file_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/librespot/audio/init.py", line 277, in get_audio_key return self.get_audio_key(gid, file_id, False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/librespot/audio/init.py", line 278, in get_audio_key raise RuntimeError( RuntimeError: Failed fetching audio key! gid: ef41ab6ee4495ebb9a4a8e9593699e6c, fileId: 051faa3f4b7b38a1687bd7f3ba2a6f7d0236bf28

Item_,type = Episode

Masterolic avatar Jul 07 '24 06:07 Masterolic

Generally, you are trying to load 320 kbps music on a non-premium account or region-locked.

kokarare1212 avatar Jul 07 '24 06:07 kokarare1212

I got this error with Audio key error, code: 2 Account premium, if retry, it may work again. So it's not region-locked. first try:

[DEBUG    11:52:07] https://guc3-spclient.spotify.com:443 "GET /metadata/4/track/17bd212d25dd45d088136391057e274f HTTP/1.1" 200 702
[DEBUG    11:52:08] https://guc3-spclient.spotify.com:443 "GET /storage-resolve/files/audio/interactive/3e65c9ae6648bef681f0b66508693f4cfd78bd4d HTTP/1.1" 200 347
[CRITICAL 11:52:08] Audio key error, code: 2
[CRITICAL 11:52:08] Audio key error, code: 2
Traceback (most recent call last):
  File "spot.py", line 108, in <module>
    stream = session.content_feeder().load(trackId, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 739, in load
    return self.load_track(playable_id, audio_quality_picker, preload,
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 800, in load_track
    return self.load_stream(file, track, None, preload, halt_listener)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 754, in load_stream
    return CdnFeedHelper.load_track(self.__session, track, file,
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 339, in load_track
    key = session.audio_key().get_audio_key(track.gid, file.file_id)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 277, in get_audio_key
    return self.get_audio_key(gid, file_id, False)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 278, in get_audio_key
    raise RuntimeError(
RuntimeError: Failed fetching audio key! gid: 17bd212d25dd45d088136391057e274f, fileId: 3e65c9ae6648bef681f0b66508693f4cfd78bd4d

success in 2nd try:

[DEBUG    11:53:14] https://guc3-spclient.spotify.com:443 "GET /metadata/4/track/17bd212d25dd45d088136391057e274f HTTP/1.1" 200 702
[DEBUG    11:53:14] https://guc3-spclient.spotify.com:443 "GET /storage-resolve/files/audio/interactive/3e65c9ae6648bef681f0b66508693f4cfd78bd4d HTTP/1.1" 200 347
[DEBUG    11:53:14] Starting new HTTPS connection (1): audio4-fa.scdn.co:443
[DEBUG    11:53:14] https://audio4-fa.scdn.co:443 "GET /audio/3e65c9ae6648bef681f0b66508693f4cfd78bd4d?1725105194_hUqm75ZOf5qGSCKdiQ1YRTqpRWmc5SHiEKzh6jRBSKU= HTTP/1.1" 206 131072
[DEBUG    11:53:14] Chunk 1/57 completed, cached: False, stream: file_id: 3e65c9ae6648bef681f0b66508693f4cfd78bd4d
[DEBUG    11:53:14] Loaded normalization data, track_gain: -9.830001831054688, track_peak: 1.033494472503662, album_gain: -9.959999084472656, album_peak: 1.0541013479232788

pdtan avatar Aug 30 '24 11:08 pdtan

I got this error with Audio key error, code: 2 Account premium, if retry, it may work again. So it's not region-locked. first try:

[DEBUG    11:52:07] https://guc3-spclient.spotify.com:443 "GET /metadata/4/track/17bd212d25dd45d088136391057e274f HTTP/1.1" 200 702
[DEBUG    11:52:08] https://guc3-spclient.spotify.com:443 "GET /storage-resolve/files/audio/interactive/3e65c9ae6648bef681f0b66508693f4cfd78bd4d HTTP/1.1" 200 347
[CRITICAL 11:52:08] Audio key error, code: 2
[CRITICAL 11:52:08] Audio key error, code: 2
Traceback (most recent call last):
  File "spot.py", line 108, in <module>
    stream = session.content_feeder().load(trackId, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 739, in load
    return self.load_track(playable_id, audio_quality_picker, preload,
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 800, in load_track
    return self.load_stream(file, track, None, preload, halt_listener)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 754, in load_stream
    return CdnFeedHelper.load_track(self.__session, track, file,
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 339, in load_track
    key = session.audio_key().get_audio_key(track.gid, file.file_id)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 277, in get_audio_key
    return self.get_audio_key(gid, file_id, False)
  File "/usr/local/lib/python3.8/dist-packages/librespot/audio/__init__.py", line 278, in get_audio_key
    raise RuntimeError(
RuntimeError: Failed fetching audio key! gid: 17bd212d25dd45d088136391057e274f, fileId: 3e65c9ae6648bef681f0b66508693f4cfd78bd4d

success in 2nd try:

[DEBUG    11:53:14] https://guc3-spclient.spotify.com:443 "GET /metadata/4/track/17bd212d25dd45d088136391057e274f HTTP/1.1" 200 702
[DEBUG    11:53:14] https://guc3-spclient.spotify.com:443 "GET /storage-resolve/files/audio/interactive/3e65c9ae6648bef681f0b66508693f4cfd78bd4d HTTP/1.1" 200 347
[DEBUG    11:53:14] Starting new HTTPS connection (1): audio4-fa.scdn.co:443
[DEBUG    11:53:14] https://audio4-fa.scdn.co:443 "GET /audio/3e65c9ae6648bef681f0b66508693f4cfd78bd4d?1725105194_hUqm75ZOf5qGSCKdiQ1YRTqpRWmc5SHiEKzh6jRBSKU= HTTP/1.1" 206 131072
[DEBUG    11:53:14] Chunk 1/57 completed, cached: False, stream: file_id: 3e65c9ae6648bef681f0b66508693f4cfd78bd4d
[DEBUG    11:53:14] Loaded normalization data, track_gain: -9.830001831054688, track_peak: 1.033494472503662, album_gain: -9.959999084472656, album_peak: 1.0541013479232788

Yes buddy i too facing same issues:)

Masterolic avatar Aug 30 '24 16:08 Masterolic

seems problem is about rate limit, checkout here I switched to fetch audio key from seektables & mp4 format

pdtan avatar Sep 04 '24 13:09 pdtan

seems problem is about rate limit, checkout here I switched to fetch audio key from seektables & mp4 format

Fetching from seektables also has the rate limit issue right?

Masterolic avatar Sep 05 '24 15:09 Masterolic

Fetching from seektables also has the rate limit issue right?

Not yet. Still in testing

pdtan avatar Sep 05 '24 15:09 pdtan

Fetching from seektables also has the rate limit issue right?

Not yet. Still in testing

Could you please share the repo which support seektables

Masterolic avatar Sep 05 '24 15:09 Masterolic

@Masterolic I'm using this

pdtan avatar Sep 05 '24 16:09 pdtan

@Masterolic I'm using this

Thank you

https://github.com/KagChi/librespot-python

Support seektables seems like that also has limits after certain time

Masterolic avatar Sep 05 '24 16:09 Masterolic

seems problem is about rate limit, checkout here I switched to fetch audio key from seektables & mp4 format

Any idea about the limit? For me the error appears at random, even with sequential track processing.

wolkenschieber avatar Sep 08 '24 17:09 wolkenschieber

seems problem is about rate limit, checkout here I switched to fetch audio key from seektables & mp4 format

Any idea about the limit? For me the error appears at random, even with sequential track processing.

For me around 10 to 15 is the maximum then it goes for awhile

Masterolic avatar Sep 09 '24 08:09 Masterolic

@Masterolic I'm using this

Thank you

https://github.com/KagChi/librespot-python

Support seektables seems like that also has limits after certain time

Hey, did you got it working with the repo? 🤔

KagChi avatar Oct 07 '24 00:10 KagChi

Hey, did you got it working with the repo? 🤔

No buddy it wont as 404 raise from seektables seems like its a cdn so generate when requested but dont know how to request

Purchasing family package and creating 6 account and sharing the premium and using multiple account to generate link works fine

Masterolic avatar Oct 07 '24 09:10 Masterolic

Hey, did you got it working with the repo? 🤔

No buddy it wont as 404 raise from seektables seems like its a cdn so generate when requested but dont know how to request

Purchasing family package and creating 6 account and sharing the premium and using multiple account to generate link works fine

seektables only works on aac format which is need wvd files as far i know

KagChi avatar Oct 07 '24 09:10 KagChi

Hello, anyone finds the solution?

abdullahrahimoon avatar Jun 10 '25 09:06 abdullahrahimoon

or region-locked

@kokarare1212 How are available countries checked exactly? Because sometimes file data may return no countries at all, which means audio is not country-restricted. In this case will the check be performed?

staniel359 avatar Oct 28 '25 21:10 staniel359