Skip to main content

A modern Last.fm api wrapper

Project description

pydrag

https://travis-ci.org/tefra/pydrag.svg?branch=master https://readthedocs.org/projects/pydrag/badge https://codecov.io/gh/tefra/pydrag/branch/master/graph/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg https://img.shields.io/github/languages/top/tefra/pydrag.svg 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

Project details


Release history Release notifications

This version

18.1

Download files

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

Files for pydrag, version 18.1
Filename, size File type Python version Upload date Hashes
Filename, size pydrag-18.1-py3-none-any.whl (32.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pydrag-18.1.tar.gz (222.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page