tamland / python-tidal

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

Getting image of artist fails #167

Closed bennetrr closed 1 year ago

bennetrr commented 1 year ago

When calling Artist.image(750), I get following exception:

 File "/Users/wemogymac/projects-bennetr/weckpi/src/coreplugin/src/weckpi/plugin/coreplugin/music/media_providers/tidal.py", line 103, in <listcomp>
    image=x.image(750)
          ^^^^^^^^^^^^
  File "/Users/wemogymac/Library/Caches/pypoetry/virtualenvs/weckpi-coreplugin-YPARpiOD-py3.11/lib/python3.11/site-packages/tidalapi/artist.py", line 180, in image
    self.picture.replace("-", "/"),
    ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

x is an Artist object I got from calling Session.search('')['artists'].

As far as I can tell, getting the image works for Playlists and Tracks.

When I open TIDAL in my browser and look in the devtools, I can see a request to the /artist endpoint, whose response contains a picture id. In the Artist.image() function, the endpoint /artists is requested instead. Could be this the issue?

tehkillerbee commented 1 year ago

Good catch. I did notice that the artist image didn't work properly, but I was nolr sure if this was due to a change by tidal or due to the recent changes in the tidalapi sources.

You are welcome to test if changing the endpoint to /artist does indeed fix the issue (PR is also very welcome) , otherwise we will look into this ASAP.

bennetrr commented 1 year ago

Thanks for your very quick response.

I was mistaken, the TIDAL web app seems to use a different API. Requesting /artist just results in a 404. I will try to figure out what the problem is later this day.

I have no idea how I could get information about the api, so it's probably a better idea if you work out how to fix the bug :)

bennetrr commented 1 year ago

In a way related to this, is it possible to add a Developement.md to the repo, that describes how / where someone can find information about TIDAL's API?

tehkillerbee commented 1 year ago

In a way related to this, is it possible to add a Developement.md to the repo, that describes how / where someone can find information about TIDAL's API

Documentation about the (reverse engineered) tidalapi is currently available here: https://tidalapi.netlify.app/

tehkillerbee commented 1 year ago

Returning artist image directly from tidalapi does seem to work, although certain frontends such as Mopidy-Iris still has problems, which is where I first noticed the issue.

Make sure you get the image URL as such:

...
artist.image(750)

In https://github.com/tamland/python-tidal/pull/174, I have added a default dimension now to avoid having to set the dimension manually. Then the image can be returned as such:

...
artist.image()
bennetrr commented 1 year ago

Hmm, still doesn't work for me. I get the same exception again, with a resolution of 750.

tehkillerbee commented 1 year ago

Perhaps there is no artist image associated with this specific artist? Have you tested with a different one?

bennetrr commented 1 year ago

Perhaps there is no artist image associated with this specific artist?

That's the problem. I didn't think of it until now, but both artists I searched for have collaborations which are also listed under artists. These collaborations do not have images, and that's why the exception is thrown.

A more clear exception was added in #171, but this is not yet released, so I'll wait for that

tehkillerbee commented 1 year ago

#171 has now been merged. Closing this issue.