mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #1095] The followers field in the current_user is empty #652
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#652
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 @Mews on GitHub (May 1, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1095
I'm trying to get a list of the users that follow me, however, the
followersfield in the data returned bycurrent_user()only shows the number of users that follow me, but not which users.This is the code I'm using (
CLIENT_IDandCLIENT_SECRETare defined earlier in the code)From what I could tell from the spotify api docs I'm using the correct scope, but this code always prints
{'href': None, 'total': 10}Is there a way to get what users follow me?
@dieser-niko commented on GitHub (May 1, 2024):
A quick Google search turned up this Stackoverflow answer from a supposed Spotify employee, suggesting that Spotify has known since 2014 that this has been a long-awaited addition to the API, but has apparently made no progress.
There's a somewhat unofficial way, but using this would technically be against Spotify's Developer Terms, it is also outside of the boundaries of spotipy and may be unreliable since there's no official documentation for this particular endpoint.
This would require an additional package called
spotipy_anonwhich allows you to use a token that is intended for the web UI.Then you can do something like this:
You might notice that there's no escaping for the username whatsoever, so use it at your own risk. Spotify itself hasn't specified what can and can't be inside a user ID (https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids), but my guess would be alphanumeric characters, so a simple str.isalnum() should do the trick.
@Mews commented on GitHub (May 1, 2024):
What do you mean by there's no escaping for the username?
Also why would this not be allowed by the tos?
@Mews commented on GitHub (May 1, 2024):
At any rate this does work thank you so much
@dieser-niko commented on GitHub (May 1, 2024):
Escaping is mostly a method used in SQL queries. I found a Stackoverflow answer which explains the process of escaping pretty good: https://stackoverflow.com/a/10646166
Obviously we're not using SQL here, but the principle stays the same. For example, if you host a web app and a user tries to enter a username like "@malicious-website.com", the request might go to malicious-website.com instead of spotify.com. But to be honest, I'm not up to date with URL injections (and this example didn't even work when I tested it), but I hope you can see where I'm going with this.
Check section IV of the developer terms, I assume the usage of my script would violate at least one of these terms.
@Mews commented on GitHub (May 1, 2024):
Oh ok but is escaping really necessary then? The
get_user_followersfunction you wrote expects a user id so it should be fine no?@dieser-niko commented on GitHub (May 1, 2024):
Just because the argument is
user: strdoesn't mean it only accepts usernames. But I've updated the code snippet to include a check for alphanumeric characters just to make sure.@Mews commented on GitHub (May 1, 2024):
But you're meant to pass a user id to it no? At least thats what worked for me
I dont see how you would end up with an id that has invalid characters
@dieser-niko commented on GitHub (May 1, 2024):
Yes, but as I said, this depends on the usecase. If you're building a web app that asks for a user ID, then you could end up with an invalid ID very fast.
@Mews commented on GitHub (May 2, 2024):
Alright anyway your solution fixed it tysm