-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_userplaycount() returning None #441
Comments
@hugovk could you help me out with this? i have been trying on this for hours. basically what i want is to get the amount of scrobbles the user doing the command has on the artist & album. the code for getting the "track_play_count" is correct, but the is where the issue is, they just keep coming back as None even though its not. |
Can you print out what And what |
It looks like this info might be missing from the Last.fm API. The three endpoints:
If you click the example URLs (XML) and replace If not, then the data just isn't available from Last.fm, or there's a problem with the API, and you'll need to report it to them at https://support.last.fm/c/support/api/47. |
I suggest reporting it to Last.fm and see what they say. |
will do, im still researching some other bots and features they have. the bleed bot has commands called "whoknows" or "wk" commands, it basically looks up stats for users in a server. this includes track, artist and album plays and the info is accurate, is this already existing in pylast or something similar to it maybe i can use instead? |
wait but the site you directed me to says this |
Ah, right, if we add a username like <stats>
<listeners>1623190</listeners>
<playcount>25614479</playcount>
<userplaycount>28</userplaycount>
</stats> With pylast, you can set a username setting up the network = pylast.LastFMNetwork(api_key=LASTFM_API_KEY, api_secret=LASTFM_API_SECRET, username= username) Also, you may need to set a For example, instead of: artist_play_count = now_playing.artist.get_userplaycount() Check if there's a username set on the artist artist = now_playing.artist
print(f"{artist=}")
artist_play_count = artist.get_userplaycount() And you can set it like this: artist = now_playing.artist
artist.username = username
print(f"{artist=}")
artist_play_count = artist.get_userplaycount() Does that help? It might be an idea to allow passing a |
I faced the same issue, and with the snippet above I was able to get what seems to be the correct playcount for artists. |
So I have tried to do this, and I only see None as the value. my code - network = pylast.LastFMNetwork(
api_key=API_KEY,
api_secret=API_SECRET,
username=username,
password_hash=password_hash,
)
artist = network.get_artist("Yellowcard")
artist_name = artist.get_name()
playcount = artist.get_userplaycount()
print("playcount of " + artist_name + " " + str(playcount)) |
Does this help? |
When I tried this -
it gives this error - |
Should have read closer -
|
How does this line work?
Is this setting an attribute of the artist object to find the username in the artist's listeners? |
What did you do?
i am trying to create a detailed "nowplaying" command on my bot
What did you expect to happen?
i expected the user's artist & album plays on the nowplaying track would be easier to get after i figured out the track play count, but i have been struggling with this.
What actually happened?
they just keep showing up as "None", im sure i have the wrong code though, and it may be a simple fix but I can't figure it out.
What versions are you using?
Please include code that reproduces the issue.
the codes that are giving me the issue is in:
The best reproductions
are
self-contained scripts
with minimal dependencies.
The text was updated successfully, but these errors were encountered: