Crate rustfm_scrobble

Source
Expand description

§rustfm-scrobble

Client for the Last.fm Scrobble API v2.0. Allows easy access to the most-commonly used Scrobble/Now Playing endpoints in the Last.fm API, as well as robust support for multiple authentication flows. More advanced API features such as metadata correction are also exposed to help build more sophisticated Scrobble clients.

The primary types to use are Scrobbler - the actual client, which you will authenticate and then use to send scrobble requests - and Scrobble - which represents a single track played at a point in time. An example using these types to scrobble a track to Last.fm is given below.

§Example usage

use rustfm_scrobble::{Scrobble, Scrobbler};
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
   let api_key = "{{api_key}}";
   let api_secret = "{{api_secret}}";
   let username = "{{username}}";
   let password = "{{password}}";

   let mut scrobbler = Scrobbler::new(api_key, api_secret);

   let response = scrobbler.authenticate_with_password(username, password)?;
   println!("Authenticated! {:#?}", response);

   let track = Scrobble::new("Los Campesinos!", "To Tundra", "No Blues");
   let response = scrobbler.now_playing(&track)?;
   println!("Sent now playing! {:#?}", response);

   let response = scrobbler.scrobble(&track)?;
   println!("Sent scrobble! {:#?}", response);

   Ok(())
}

Note: This crate does not implement any of the logic to comply with Last.fm’s scrobbling rules. Typical (“real-time”) implementations will likely want to adhere to these rules, outlined in Last.fm’s API Documentation. Other implementations may choose to ignore these guidelines. This crate provides the flexibility to develop any type of Scrobbling application.

Modules§

Structs§

  • Repesents a single music track played at a point in time. In the Last.fm universe, this is known as a “scrobble”.
  • A batch of Scrobbles to be submitted to Last.fm together.
  • A Last.fm Scrobbler client. Submits song play information to Last.fm.
  • Represents an Error that occurred while interacting with the Last.fm API