tamland / python-tidal

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

How do we search for albums - models = [tidalapi.album.Album] does not work #136

Closed arsaboo closed 1 year ago

arsaboo commented 1 year ago

I am trying to search for albums on Tidal. Here's the code that I have:

import tidalapi
album = "Dangerously in Love. Columbia."
search_result = session.search(query=album, models = [tidalapi.album.Album], limit="1", offset="0")
print(search_result)

Here's the output that I am getting:

{'artists': [], 'albums': [], 'tracks': [], 'videos': [], 'playlists': [], 'top_hit': None}
tehkillerbee commented 1 year ago

Have you completed the login first, as per the documentation?

import tidalapi

session = tidalapi.Session()
# Will run until you visit the printed url and link your account
session.login_oauth_simple()
...
arsaboo commented 1 year ago

Yes, I have completed the login. Track search works.

arsaboo commented 1 year ago

Here's the output of a track search:

import tidalapi
search_result = session.search(query="Cuff It", models = [tidalapi.media.Track])
print(search_result)

Here's the output:

{'artists': [], 'albums': [], 'tracks': [<tidalapi.media.Track object at 0x000001F781B0EC40>, <tidalapi.media.Track object at 0x000001F781CC7FA0>, <tidalapi.media.Track object at 0x000001F7818F9DC0>, <tidalapi.media.Track object at 0x000001F781C270D0>, <tidalapi.media.Track object at 0x000001F7804562E0>, <tidalapi.media.Track object at 0x000001F781CBD8E0>, <tidalapi.media.Track object at 0x000001F781C15E50>, <tidalapi.media.Track object at 0x000001F781A52190>, <tidalapi.media.Track object at 0x000001F781A52DF0>, <tidalapi.media.Track object at 0x000001F781A528E0>, <tidalapi.media.Track object at 0x000001F781A525B0>, <tidalapi.media.Track object at 0x000001F781A52520>, <tidalapi.media.Track object at 0x000001F781A52B50>, <tidalapi.media.Track object at 0x000001F781A52400>], 'videos': [], 'playlists': [], 'top_hit': <tidalapi.media.Track object at 0x000001F781A52D60>}

Can you provide a working album search snippet...thanks!

arsaboo commented 1 year ago

Ok...looks like the code is working. We get the first output when there are no search results.

{'artists': [], 'albums': [], 'tracks': [], 'videos': [], 'playlists': [], 'top_hit': None}

If a result is returned, we get the right out. Closing this...thanks!