Skip to content

SpotAPI throwing errors because code.thetadev.de no longer exists #72

Description

@pdwerryhouse

SpotAPI is throwing errors because code.thetadev.de no longer exists:

[11:25:47] Failed to fetch secrets: HTTPSConnectionPool(host='code.thetadev.de', port=443): Max retries exceeded with url: /The ??taDev/s
potify-secrets/raw/branch/main/secrets/secretDict.json (Caused by NameResolutionError("HTTPSConnection(host='code.thetad ????ev.de', port
=443): Failed to resolve 'code.thetadev.de' ([Errno -2] Name or service not known)")). Falling back to default secr ????et.                                                                                                                             ?
Traceback (most recent call last):      
  File "/code/test/sandpit/./test_spotify.py", line 25, in <module>            
    print(search_spotify(title, artist))      
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/test/sandpit/./test_spotify.py", line 17, in search_spotify                  
    songs = song.query_songs(f"{artist} {title}", limit=limit)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/types/annotations.py", line 47, in wrapper      
    result: R = func(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/song.py", line 98, in query_songs            
    "sha256Hash": self.base.part_hash("searchDesktop"),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/types/annotations.py", line 47, in wrapper      
    result: R = func(*args, **kwargs)                        
                ^^^^^^^^^^^^^^^^^^^^^                     
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/client.py", line 255, in part_hash               
    self.get_sha256_hash()                          
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/types/annotations.py", line 47, in wrapper      
    result: R = func(*args, **kwargs)         
                ^^^^^^^^^^^^^^^^^^^^^      
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/client.py", line 267, in get_sha256_hash        
    self.get_session()               
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/types/annotations.py", line 47, in wrapper      
    result: R = func(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/client.py", line 211, in get_session            
    self._get_auth_vars()
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/types/annotations.py", line 47, in wrapper      
    result: R = func(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^
  File "/code/test/sandpit/venv/lib/python3.12/site-packages/spotapi/client.py", line 172, in _get_auth_vars         
    raise BaseClientError(
spotapi.exceptions.errors.BaseClientError: Could not get session auth tokens

I was able to work around this by replacing the code that pulls the secrets from that address with some from an archive of that url that I found in the wayback machine. This won't be a fix that lasts long, I presume:

diff --git a/spotapi/client.py b/spotapi/client.py
index 4ae4382..3895111 100644
--- a/spotapi/client.py
+++ b/spotapi/client.py
@@ -39,12 +39,7 @@ def get_latest_totp_secret() -> Tuple[int, bytearray]:
         return _secret_cache
 
     try:
-        url = "https://code.thetadev.de/ThetaDev/spotify-secrets/raw/branch/main/secrets/secretDict.json"
-        response = requests.get(url, timeout=5)
-        if not response.ok:
-            raise BaseClientError(f"Failed to fetch secrets: {response.status_code}")
-
-        secrets = response.json()
+        secrets = {"59":[123,105,79,70,110,59,52,125,60,49,80,70,89,75,80,86,63,53,123,37,117,49,52,93,77,62,47,86,48,104,68,72],"60":[79,109,69,123,90,65,46,74,94,34,58,48,70,71,92,85,122,63,91,64,87,87],"61":[44,55,47,42,70,40,34,114,76,74,50,111,120,97,75,76,94,102,43,69,49,120,118,80,64,78]}
         version = max(secrets, key=int)
         secret_list = secrets[version]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions