Aran404 / SpotAPI

A python wrapper for the public & private Spotify API
GNU General Public License v3.0
189 stars 5 forks source link

Importing cookies error #4

Open Ishannaik opened 1 month ago

Ishannaik commented 1 month ago

Traceback (most recent call last):
  File "sp.py", line 22, in <module>
    saver.save([cookies])
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 68, in save
    current = [
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 71, in <listcomp>
    if not any(
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 72, in <genexpr>
    item["identifier"] == d["identifier"] for d in data
TypeError: string indices must be integers

Getting error here


from spotapi import Login, Config, NoopLogger, JSONSaver

# Correctly structured cookies
cookies = {
    "identifier": "",  
    "cookies": {
        "sp_dc": "",  
        "sp_key": "",  
    },
}

cfg = Config(
    solver=None, 
    logger=NoopLogger(),  
)

saver = JSONSaver()

saver.save([cookies])

instance = Login.from_saver(saver, cfg)

user_info = instance.user.me()
print(f"Logged in as: {user_info['display_name']}")
Aran404 commented 1 month ago

Please provide a working example so I can recreate the error. There is a lot of things wrong in this code. Use an IDE.

Ishannaik commented 1 month ago

Can you add an example code for a cookie login in the readme