Coder Social home page Coder Social logo

klms / pylast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pylast/pylast

0.0 2.0 0.0 1.13 MB

A Python interface to Last.fm and Libre.fm

Home Page: https://pypi.python.org/pypi/pylast/

License: Apache License 2.0

Shell 0.05% Python 99.95%

pylast's Introduction

pyLast

Build Status PyPI version PyPI downloads Coverage Status Code Health

A Python interface to Last.fm and other API-compatible websites such as Libre.fm.

Try using the pydoc utility for help on usage or see test_pylast.py for examples.

Installation

Install via pip:

pip install pylast

Features

  • Simple public interface.
  • Access to all the data exposed by the Last.fm web services.
  • Scrobbling support.
  • Full object-oriented design.
  • Proxy support.
  • Internal caching support for some web services calls (disabled by default).
  • Support for other API-compatible networks like Libre.fm.
  • Python 3-friendly (Starting from 0.5).

Getting Started

Here's some simple code example to get you started. In order to create any object from pyLast, you need a Network object which represents a social music network that is Last.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm and use it as follows:

import pylast

# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from http://www.last.fm/api/account for Last.fm
API_KEY = "b25b959554ed76058ac220b7b2e0a026" # this is a sample key
API_SECRET = "425b55975eed76058ac220b7b4e8a054"

# In order to perform a write operation you need to authenticate yourself
username = "your_user_name"
password_hash = pylast.md5("your_password")

network = pylast.LastFMNetwork(api_key = API_KEY, api_secret =
    API_SECRET, username = username, password_hash = password_hash)

# Now you can use that object everywhere
artist = network.get_artist("System of a Down")
artist.shout("<3")


track = network.get_track("Iron Maiden", "The Nomad")
track.love()
track.add_tags(("awesome", "favorite"))

# Type help(pylast.LastFMNetwork) or help(pylast) in a Python interpreter to get more help
# about anything and see examples of how it works

More examples in hugovk/lastfm-tools and test_pylast.py.

Testing

tests/test_pylast.py contains integration tests with Last.fm, and plenty of code examples. Unit tests are also in the tests/ directory.

For integration tests you need a test account at Last.fm that will become cluttered with test data, and an API key and secret. Either copy example_test_pylast.yaml to test_pylast.yaml and fill out the credentials, or set them as environment variables like:

export PYLAST_USERNAME=TODO_ENTER_YOURS_HERE
export PYLAST_PASSWORD_HASH=TODO_ENTER_YOURS_HERE
export PYLAST_API_KEY=TODO_ENTER_YOURS_HERE
export PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE

To run all unit and integration tests:

pip install pytest flaky mock
py.test

Or run just one test case:

py.test -k test_scrobble

To run with coverage:

py.test -v --cov pylast --cov-report term-missing
coverage report # for command-line report
coverage html   # for HTML report
open htmlcov/index.html

pylast's People

Contributors

amrhassan avatar brtkrbzhnv avatar colonelpanic8 avatar edwardbetts avatar hugovk avatar inversion avatar kiliankoe avatar lipka avatar peterjeschke avatar sfordinc avatar simmel avatar tetrapus avatar yanggao1119 avatar zer0kg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.