Skip to content

[BUG] Error Fetching Audio Key #325

@Resparing

Description

@Resparing

Runtime error when attempting to fetch Audio

import logging
from librespot.core import Session
from librespot.metadata import TrackId
from librespot.audio.decoders import AudioQuality, FormatOnlyAudioQuality
from librespot.audio.decoders import SuperAudioFormat


logging.basicConfig(level=logging.DEBUG)

# This will log an url in the terminal that you have to open

session = Session.Builder().oauth(None).create()  # type: ignore

track_id = TrackId.from_uri("spotify:track:3DsHJFNrKKLK08LzcJwyCX")
stream = session.content_feeder().load(track_id, FormatOnlyAudioQuality(AudioQuality.NORMAL, SuperAudioFormat.AAC), False, None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): apresolve.spotify.com:443
DEBUG:urllib3.connectionpool:https://apresolve.spotify.com:443 "GET /?type=accesspoint HTTP/1.1" 200 None
INFO:Librespot:Session:Created new session! device_id: DEVICE_ID, ap: ap-guc3.spotify.com:80
INFO:Librespot:Session:Connection successfully!
INFO:Librespot:Session:Session.Receiver started
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): apresolve.spotify.com:443
DEBUG:urllib3.connectionpool:https://apresolve.spotify.com:443 "GET /?type=spclient HTTP/1.1" 200 None
INFO:Librespot:Session:Skipping 02
INFO:Librespot:Session:Received license_version: 0
INFO:Librespot:Session:Received country_code: CA
DEBUG:Librespot:Session:Parsed product info: {'type': 'free', 'ab-ad-player-targeting': '1', 'ab-watch-now': '0', 'ab_recently_played_feature_time_filter_threshold': 'com.spotify.gaia=30,driving-mode=120,spotify%3Ainternal%3Astartpage=30', 'ad-formats-preroll-video': '0', 'ad-session-persistence': '1', 'ads': '1', 'app-developer': '0', 'arsenal_country': '1', 'audio-preview-url-template': 'https://p.scdn.co/mp3-preview/{id}', 'audio-quality': '0', 'audiobook-onboarding-completed': '0', 'autoplay': '1', 'capping-bar-threshold': '3601', 'catalogue': 'free', 'collection': '1', 'created_by_partner': None, 'employee-free-opt-in': '0', 'enable-annotations': '2', 'enable-annotations-read': '0', 'enable-crossfade': '1', 'explicit-content': '1', 'financial-product': 'pr:free,tc:0', 'head-file-caching': '1', 'head-files': '1', 'head-files-url': 'https://heads-fa-tls13.spotifycdn.com/head/{file_id}', 'high-bitrate': '0', 'image-url': 'https://i.scdn.co/image/{file_id}', 'incognito_mode_timeout': '21600', 'is_email_verified': '1', 'key-caching-auto-offline': '0', 'key-caching-max-count': '10000', 'key-caching-max-offline-seconds': '1800', 'key-memory-cache-mode': '1:15,300', 'libspotify': '0', 'license-agreements': None, 'metadata-link-lookup-modes': '0', 'mobile': '0', 'name': 'Spotify Free', 'nft-disabled': '1', 'offline': '0', 'on-demand': '1', 'on-demand-trial-in-progress': '0', 'payments-locked-state': '0', 'player-license': 'on-demand', 'player-license-v2': 'on-demand', 'playlist-annotations-markup': '0', 'preferred-locale': 'en', 'prefetch-keys': '1', 'prefetch-strategy': '18', 'prefetch-window-max': '2', 'public-toplist': '1', 'publish-activity': '1', 'publish-playlist': '0', 'radio': '1', 'rating-access': '1', 'remote-control': '6', 'restrict-playlist-collaboration': '0', 'send-email': '0', 'shows-collection': '1', 'shows-collection-jam': '0', 'shuffle': '0', 'shuffle-algorithm': 'FRESH', 'sidebar-navigation-enabled': '0', 'storage-size-config': '10240,90,500,3', 'streaming': '1', 'streaming-rules': None, 'ugc-abuse-report': '1', 'ugc-abuse-report-url': 'https://support.spotify.com/abuse/?uri={uri}', 'video-cdn-sampling': '100', 'video-device-blacklisted': '0', 'video-manifest-url': 'https://spclient.wg.spotify.com/manifests/v6/{type}/sources/{source_id}/options/supports_drm', 'widevine-license-url': 'https://spclient.wg.spotify.com/widevine-license/v1/video/license'}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): apresolve.spotify.com:443
INFO:Librespot:Session:Skipping 1f
INFO:Librespot:Session:Skipping 69
DEBUG:Librespot:MercuryClient:Handling packet, cmd: 0xb5, seq: 1905946232145051648, flags: b'\x01', parts: 1
DEBUG:Librespot:MercuryClient:Couldn't dispatch Mercury event seq: 1905946232145051648, uri: hm://pusher/v1/connections/ZGI0NDUxOGM0MjBlMmU1YjQyNThkYzU4YWYzYWM3NjNkMTc2NzhiYytBUCt0Y3A6Ly8wYWIxNDljNy5pcC5ndWMzLnNwb3RpZnkubmV0OjUwMDcrRDRFRjkwOTIwNEUwMDYzREJDMDY2QkQyNUU5OEQ1QzFBN0I4QjUwNkMzQkI2RjlDMTk2MEZENzkxQ0M5ODE5Qw%3D%3D, code: 200, payload: b''
DEBUG:Librespot:Session:Received 0x10: 929ea9ac9c3ab5be09fe2552f0c352a3320d4403
DEBUG:urllib3.connectionpool:https://apresolve.spotify.com:443 "GET /?type=dealer HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): login5.spotify.com:443
INFO:Librespot:Session:Skipping unknown command cmd: 0x75, payload: b'\x00\x00\x01'
DEBUG:urllib3.connectionpool:https://login5.spotify.com:443 "POST /v3/login HTTP/1.1" 200 None
INFO:Librespot:TokenProvider:Login5 authentication successful, got access token
DEBUG:Librespot:TokenProvider:Using Login5 access token for scopes: ['playlist-read']
INFO:Librespot:Session:Authenticated as 31qmtun5ak42jvq2y7phoyy246b4!
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): clienttoken.spotify.com:443
DEBUG:urllib3.connectionpool:https://clienttoken.spotify.com:443 "POST /v1/clienttoken HTTP/1.1" 200 None
DEBUG:Librespot:ApiClient:Updated client token: CLiEnTTOKEN
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gae2-spclient.spotify.com:443
DEBUG:urllib3.connectionpool:https://gae2-spclient.spotify.com:443 "POST /extended-metadata/v0/extended-metadata HTTP/1.1" 200 777
WARNING:Librespot:Player:FormatOnlyAudioQuality:Using AAC format file with HIGH quality because preferred NORMAL quality couldn't be found.
DEBUG:urllib3.connectionpool:https://gae2-spclient.spotify.com:443 "GET /storage-resolve/files/audio/interactive/14a50dac4fffef56431335866543b417e2d2dfbb HTTP/1.1" 200 479
CRITICAL:Librespot:AudioKeyManager:Audio key error, code: 1
CRITICAL:Librespot:AudioKeyManager:Audio key error, code: 1
Traceback (most recent call last):
  File "/Users/resparing/dev/librespot-python/s.py", line 15, in <module>
    stream = session.content_feeder().load(track_id, FormatOnlyAudioQuality(AudioQuality.NORMAL, SuperAudioFormat.AAC), False, None)
  File "/Users/hudsonregis/Documents/Projects/Major-Projects/spotify-dl/librespot-python/librespot/audio/__init__.py", line 738, in load
    return self.load_track(playable_id, audio_quality_picker, preload,
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           halt_listener)
                           ^^^^^^^^^^^^^^
  File "/Users/resparing/dev/librespot-python/librespot/audio/__init__.py", line 802, in load_track
    return self.load_stream(file, track, None, preload, halt_listener)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/resparing/dev/librespot-python/librespot/audio/__init__.py", line 755, in load_stream
    return CdnFeedHelper.load_track(self.__session, track, file,
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                    response, preload, halt_lister)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/resparing/dev/librespot-python/librespot/audio/__init__.py", line 340, in load_track
    key = session.audio_key().get_audio_key(track.gid, file.file_id)
  File "/Users/resparing/dev/librespot-python/librespot/audio/__init__.py", line 278, in get_audio_key
    return self.get_audio_key(gid, file_id, False)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/Users/resparing/dev/librespot-python/librespot/audio/__init__.py", line 279, in get_audio_key
    raise RuntimeError(
        "Failed fetching audio key! gid: {}, fileId: {}".format(
            util.bytes_to_hex(gid), util.bytes_to_hex(file_id)))
RuntimeError: Failed fetching audio key! gid: 777be4317add443b8ff7b250a7570987, fileId: 14a50dac4fffef56431335866543b417e2d2dfbb

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions