15 releases (4 stable)

1.1.1 Jan 13, 2021
1.1.0 Dec 13, 2020
1.0.1 Aug 14, 2020
1.0.0 Oct 31, 2019
0.2.0 Mar 4, 2017

#110 in Multimedia

Download history 29/week @ 2024-07-21 84/week @ 2024-07-28 91/week @ 2024-08-04 96/week @ 2024-08-11 33/week @ 2024-08-18 72/week @ 2024-08-25 101/week @ 2024-09-01 22/week @ 2024-09-08 60/week @ 2024-09-15 104/week @ 2024-09-22 103/week @ 2024-09-29 22/week @ 2024-10-06 13/week @ 2024-10-13 19/week @ 2024-10-20 12/week @ 2024-10-27 12/week @ 2024-11-03

58 downloads per month
Used in connectr

MIT license

61KB
987 lines

rustfm-scrobble

Latest Version Rust

rustfm-scrobble is a Last.fm Scrobble API 2.0 crate for Rust. It allows easy acccess to the "scrobble" and "now playing" notification endpoints through a simple Rust API. It can be used to record song-plays from music players, build analog scrobbling tools similar to VinylScrobbler or work with IoT Devices. It was initially built to implement a Spotify scrobbling service using the Spotify Connect Protocol when the Alexa Spotify client did not support scrobbling plays to Last.fm.

Features

  • Scrobble songs to Last.fm ('scrobble' API endpoint)
  • Publish now-playing song to Last.fm ('now playing' API endpoint)
  • Batch scrobble support in Scrobbler::scrobble_batch and ScrobbleBatch
  • Multiple authentication flows to gain permissions to publish to Last.fm user profile
    • Store a pre-authenticated session key & throw away secret data after initial authentication
  • Simple error handling; each API operation returns a Result with a simple Error type on failure
  • Unit tested

Install

Add rustfm-scrobble to your Cargo.toml.

[dependencies]
rustfm-scrobble="1.1"

Usage

  • API Documentation
  • Code Examples
    • Example now-playing & scrobbling client
    • Example batch scrobbling client
    • cargo build --examples
    • ./target/debug/examples/example
  • Build: cargo build
  • Run Unit tests: cargo test
extern crate rustfm_scrobble;
use rustfm_scrobble::{Scrobble, Scrobbler};

let username = "last-fm-username";
let password = "last-fm-password";
let api_key = "client-api-key";
let api_secret = "client-api-secret";
 
let mut scrobbler = Scrobbler::new(api_key, api_secret);
scrobbler.authenticate_with_password(username, password);
 
let song = Scrobble::new("Example Artist", "Example Song", "Example Album");
scrobbler.scrobble(song);

In Use

rustfm-scrobble is used in several projects including polaris, connectr, rescrobbled and rb-scrobbler.

Status

The API is stable & backwards compatibility will be guaranteed for all 1.0 releases.

License

MIT license, see ./LICENSE.

Dependencies

~5MB
~88K SLoC