kokarare1212 / librespot-python

Open Source Spotify Client
http://librespot-python.rtfd.io
Apache License 2.0
219 stars 43 forks source link

[BUG] Failed fetching audio key! gid #276

Open Masterolic opened 2 months ago

Masterolic commented 2 months ago

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

kokarare1212 commented 2 months ago

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

pdtan commented 1 week ago

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
Masterolic commented 1 week ago

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:)

pdtan commented 2 days ago

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

Masterolic commented 1 day ago

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?

pdtan commented 1 day ago

Fetching from seektables also has the rate limit issue right?

Not yet. Still in testing

Masterolic commented 1 day ago

Fetching from seektables also has the rate limit issue right?

Not yet. Still in testing

Could you please share the repo which support seektables

pdtan commented 1 day ago

@Masterolic I'm using this

Masterolic commented 1 day ago

@Masterolic I'm using this

Thank you

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

Support seektables seems like that also has limits after certain time