Skip to main content

A modern Last.fm api wrapper

Project description

pydrag

https://github.com/tefra/pydrag/workflows/tests/badge.svg https://readthedocs.org/projects/pydrag/badge https://codecov.io/gh/tefra/pydrag/branch/master/graph/badge.svg https://img.shields.io/github/languages/top/tefra/pydrag.svg https://www.codefactor.io/repository/github/tefra/pydrag/badge https://img.shields.io/pypi/pyversions/pydrag.svg https://img.shields.io/pypi/v/pydrag.svg

pydrag is a modern api wrapper for the Last.fm api with a fluent syntax!

Quick Start

Apply for a last.fm api key and write down your key and secret.

Install

$ pip install pydrag

Example

>>> from pydrag import User, configure
>>> configure(api_key='54062d8af7afdc_not_real_3459048a4')
>>> rj = User.find("RJ")
>>> rj.real_name
'Richard Jones '
>>> recent = rj.get_recent_tracks(limit=1, page=1)
>>> first = recent.pop()
>>> first.name
'Fu-Gee-La'
>>> similar = first.get_similar(limit=1)
>>> similar[0].name
'Family Business'
>>> similar[0].artist.name
'Fugees'
>>>
>>> for friend in rj.get_friends(recent_tracks=True):
...     friend.name, friend.recent_track.name
...
('meichi', 'Pi')
('demkod', '(bottle back)')
('STBKilla', 'Nowhere Fast')
('keret221', 'Letter Home')
('Lilfix', 'Namorar pra Quê?')
('Yoji', 'Empire State of Mind (feat. Alicia Keys)')
('Kastishka', 'Wipe Your Eyes')
('comingsoon_', 'I Want It All')
('Bagheera', 'Welcome Home')

Development

Use you favorite tool to create a python >= 3.6 virtual environment

$ git clone git@github.com:tefra/pydrag.git
$ pip install .[dev]
$ pre-commit install
$ pytest
$ tox

pydrag uses vcrpy library to record and replay last.fm responses for its unit tests and python-dotenv to auto-configure itself.

All sensitive information like keys and credentials are automatically censored.

So when it’s necessary to record a new response it’s super useful to have a .env file with your configuration!

LASTFM_API_KEY=your_api_key
LASTFM_API_SECRET=your_api_secret
LASTFM_USERNAME=You
LASTFM_PASSWORD=YouPass

Changelog: 22.5 (2022-05-08)

  • Replaced attrs with dataclasses

  • Added support for python 3.10

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydrag-22.5.tar.gz (228.3 kB view details)

Uploaded Source

Built Distribution

pydrag-22.5-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file pydrag-22.5.tar.gz.

File metadata

  • Download URL: pydrag-22.5.tar.gz
  • Upload date:
  • Size: 228.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pydrag-22.5.tar.gz
Algorithm Hash digest
SHA256 f1465a987058ae1bb1e8f63e7299a89336401dcd5aa168e9d39b6c6cd20e1d66
MD5 ae04946e97f3556c3a160f422da90c3f
BLAKE2b-256 fecc6ec72a9a090bd7f92464e668914dc63dd2efce7c7025b07ad77e462c4d01

See more details on using hashes here.

File details

Details for the file pydrag-22.5-py3-none-any.whl.

File metadata

  • Download URL: pydrag-22.5-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pydrag-22.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a02be5faacc64048a50d20a4fef8715ade41299e5af9036f5acda6ef09f035f4
MD5 fda74a81a19311eb0b1d153cadf3a065
BLAKE2b-256 ff41fcfe036633a94b3d39aa7d2d577c14265fa565605ebbfe3763f73af483f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page