tamland / python-tidal

Python API for TIDAL music streaming service
GNU Lesser General Public License v3.0
406 stars 110 forks source link

404 Response Adding Album to Favorites #121

Closed ehakin919 closed 1 year ago

ehakin919 commented 1 year ago

Hey all, been using this API to migrate from Spotify -> Tidal, and I'd like to programmatically add in my extensive library using this API. Having the below issue when attempting to add an album to my favorites.

Any help would be appreciated.

Thanks

tidal_session = tidalapi.session.Session()
tidal_login = tidal_session.login_oauth_simple()

user_favorites = tidalapi.user.Favorites(session=tidal_session, user_id=u_name)

user_favorites.add_album(album_id="31758300")

Returns:

HTTP error on 404
Traceback (most recent call last):
  File "/Users/ed/Documents/py_projects/tidal_migration/tidal_migration.py", line 51, in <module>
    user_favorites_session.add_album(album_id="31758300")
  File "/Users/ed/Documents/py_projects/tidal_migration/lib/python3.10/site-packages/tidalapi/user.py", line 185, in add_album
    return self.requests.request('POST', self.base_url + '/albums', data={'albumId': album_id}).ok
  File "/Users/ed/Documents/py_projects/tidal_migration/lib/python3.10/site-packages/tidalapi/request.py", line 99, in request
    request.raise_for_status()
  File "/Users/ed/Documents/py_projects/tidal_migration/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.tidal.com/v1/users/<>/favorites/albums?sessionId=0d9df3e4-60a4-409f-b8c9-77b057f6add0&countryCode=US&limit=1000

I've removed username from the 404 response URL

WilliamGuisan commented 1 year ago

Hello! I seem to be having a similar issue. Currently trying to write a program that gets tracks from my "Tracks" list and writes the information into a CSV file.

tidal_session = tidalapi.session.Session()

tidal_session.login_oauth_simple()
tidal_session.check_login()         # == True
tidal_user = tidal_session.user
user_id = tidal_user.id

def get_favorite_tracks():
      favorites = tidalapi.user.Favorites(tidal_session, user_id)
      favorite_tracks = favorites.tracks()

The following is the Error message that i get:

HTTP error on 404
Traceback (most recent call last):
  File "/home/tidal_csv_downloader.py", line 85, in <module>
    main()
  File "/home/*/tidal_csv_downloader.py", line 76, in main
    get_favorite_tracks()
  File "/home/*/tidal_csv_downloader.py", line 12, in get_favorite_tracks
    favorite_tracks = favorites.tracks()
  File "/home/*/.local/lib/python3.10/site-packages/tidalapi/user.py", line 344, in tracks
    return self.requests.map_request(
  File "/home/*/.local/lib/python3.10/site-packages/tidalapi/request.py", line 116, in map_request
    json_obj = self.request('GET', url, params).json()
  File "/home/*/.local/lib/python3.10/site-packages/tidalapi/request.py", line 99, in request
    request.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.tidal.com/v1/users/favorites/tracks?sessionId=********-****-****-****-************&countryCode=CH&limit=1000&offset=0

The OAuth login process works flawlessly. Are there different Tokens that require a different configuration / different parameters? I am quite new to coding as a whole so excuse me if i am missing something really obvious :)

Maybe you found a solution @ehakin919 ? :D Thanks for reading!

EDIT 2023.06.04: Okay so i seem to have "figured out the problem", as in i scrapped everything and re-wrote it. I think it was some name space / scope issue, i used functions etc. so i am guessing it got something to do with that. This gave me the chance to read through the 'tidalapi' code though and learn about how 'git' works a bit, so that's very nice :). I will further read through the code of this API, get some more coding experience and hope i can contribute to the project at one point! Greetings, Will

tehkillerbee commented 1 year ago

Closing this as it looks like OP already solved the issue.