mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #929] missed artists genres list in tracks calling api #558
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#558
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mase-git on GitHub (Jan 8, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/929
Describe the bug
According to the official documentation, calling the GET API tracks/?id=(list of ids), it retrieves a collection of tracks info related to the ids list in input. In these information, we can retrieves some data about tracks artists and albums. However, in the JSON response, there are some missed fields such as "genres" in the artists key.
An example of a piece of the main structure of the JSON response from the official documentation is:
Spotipy should implement the tracks/?id invocation with the following function:
Unfortunately, the response follows an array of the Get Track call JSON response and not the Several Tracks call API output.
Your code
I tested the bug with a customized version of examples/show_track.py script:
Expected behavior
Output with the JSON structure defined in the official Spotify documentation.
Output
Environment:
Additional context
I think that the error occurs for a changing of version in Spotify API and a misalignment with the Spotipy function invocation.
@stephanebruckert commented on GitHub (Jan 8, 2023):
I know that not all artists have genres associated to them. To confirm this is not the problem, can you please share the track ID you are working with?
in comparison, do the artist genres correctly appear when using the
/trackendpoint, akaspotipy.client.Spotify.track?/tracks?ids={ids}seems to already existgithub.com/spotipy-dev/spotipy@922d51df02/spotipy/client.py (L347..L356), I'm confused as to why you suggest we should implement itI'm not sure what you mean. Do you have an example? For both endpoints the JSON have similar
artistobjects@mase-git commented on GitHub (Jan 8, 2023):
I tried with Drake on the "Rich Flex" track. Related IDs info are:
spotify:track:1bDbXMyjaUIooNwFE9wn0Nspotify:artist:3TVXtAsR1Inumwj472S9r4If you give the artist ID in input to examples/show_artists.py, you can check that genres attribute exists for it.
I tried with the spotipy.client.Spotify.track, the result follows the JSON response of the /track/{id} API where the genres key is not part of the artists attributes. Meanwhile, the previous key should be part of JSON response information for the /tracks/?ids={ids}.
I wasn't so clear here, I am sorry. I know that
github.com/spotipy-dev/spotipy@922d51df02/spotipy/client.py (L347..L356)implements the function that I wrote above. I mean that the JSON response of spotipy.client.Spotify.tracks didn't match the JSON structure defined in the Spotify API documentationThe artists attribute of the JSON response in the
spotipy.client.Spotify.trackinvocation is:Meanwhile, the artists attribute of the
spotipy.client.Spotify.tracksinvocation obtains:However, the JSON response for
/tracks/?id={ids}from the official Spotify documentation is:I am not sure that the problem is related to the Spotipy side.
@stephanebruckert commented on GitHub (Jan 8, 2023):
OK I see. My understanding is this is a bug on the Spotify API side, not Python related.
The same happens if you try it in the console with ID
1bDbXMyjaUIooNwFE9wn0Nhttps://developer.spotify.com/console/get-track/This would need to be reported at https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer
Perhaps they voluntarily include a minimised artist object inside the tracks, and they forgot to update the doc.
@mase-git commented on GitHub (Jan 8, 2023):
Oh ok, I didn't notice that. Thank you for the clarification! 👌
@mase-git commented on GitHub (Jan 12, 2023):
Update:
According to the official Spotify Documentation, an alternative solution for this bug is search by artist name and focus on the artist genre. It can't solve completely the problem, however it guarantee a genre type to associate with the artist and/or album. This kind of information is pretty useful in some data analysis project where the track and artist genre can have some statistical correlation and provides interesting insights.
@stephanebruckert commented on GitHub (Jan 16, 2023):
Yep! Thanks for the feedback
I've created a quick discussion in Spotify community https://community.spotify.com/t5/Spotify-for-Developers/Track-endpoints-not-returning-all-artist-fields-as-documented/m-p/5489383#M7675
I'll close the issue as there is nothing that spotipy can do about it now or in the future.