Skip to content

xiaomyer/lastfmpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lastfmpy - Last.FM API wrapper written in Python

widget

Maintained by Myer (also known as myerfire, MyerFire)

This library is an async wrapper for the last.fm API.

Features

  • Currently, any API methods that do not require the authentication process are supported.

Installation

lastfmpy is available from the official pYpI package index.

python -m pip install -U lastfmpy

Documentation

  • There are relevant docstrings on the functions of the main wrapper class.
  • Object attribute documentation may (?) be worked on but the code in objects.py is easily readable.
  • There is no API method for a user's currently playing song. The way to get the currently playing song of a user is to request recent tracks and check whether the first index of the list has the attribute playing set to true.
    • UPDATE - There is now a utility function in the User object of the Client that does this for you: get_now_playing(user)

Quick Start

from lastfmpy import LastFM
import asyncio

API_KEY = "hahagetbaited"
# if it isn't obvious enough, replace this string 
# with your API key obtained by going to https://last.fm/api/applications and creating an application

async def main():
    lastfm = await LastFM(API_KEY)
    recent = await lastfm.user.get_recent_tracks(user="myerfire")
    print(f"{recent.items[0].name}")

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

Myer, this attribute is None when I think it shouldn't be!

For certain API methods, Last.FM does not respond with every piece of information about the specific object that was requested. For example, tags is missing from an Artist object in the response from artist.get_similar because the tags do not exist in the API response itself. The tags attribute would be populated if the object was obtained using artist.get_info. The best way to check if this is happening to you is going to the Last.FM API documentation and either looking at the example responses or testing by going to the API url itself.

About

Async Last.fm API wrapper written in Python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published