rustfm_scrobble_proxy/
lib.rs

1#![doc(html_root_url = "https://docs.rs/rustfm-scrobble/1.0.0")]
2#![deny(clippy::all)]
3#![deny(clippy::pedantic)]
4//! # rustfm-scrobble
5//!
6//! Client for the Last.fm Scrobble API v2.0. Allows easy access to the most-commonly used Scrobble/Now Playing
7//! endpoints in the Last.fm API, as well as robust support for multiple authentication flows. More advanced API
8//! features such as metadata correction are also exposed to help build more sophisticated Scrobble clients. 
9//! 
10//! The primary types to use are `Scrobbler` - the actual client, which you will authenticate and then use to send 
11//! scrobble requests - and `Scrobble` - which represents a single track played at a point in time. An example using
12//! these types to scrobble a track to Last.fm is given below.
13//! 
14//! # Example usage
15//! ```ignore
16//! use rustfm_scrobble_proxy::{Scrobble, Scrobbler};
17//! use std::error::Error;
18//!
19//! fn main() -> Result<(), Box<dyn Error>> {
20//!    let api_key = "{{api_key}}";
21//!    let api_secret = "{{api_secret}}";
22//!    let username = "{{username}}";
23//!    let password = "{{password}}";
24//!
25//!    let mut scrobbler = Scrobbler::new(api_key, api_secret);
26//!
27//!    let response = scrobbler.authenticate_with_password(username, password)?;
28//!    println!("Authenticated! {:#?}", response);
29//!
30//!    let track = Scrobble::new("Los Campesinos!", "To Tundra", "No Blues");
31//!    let response = scrobbler.now_playing(&track)?;
32//!    println!("Sent now playing! {:#?}", response);
33//!
34//!    let response = scrobbler.scrobble(&track)?;
35//!    println!("Sent scrobble! {:#?}", response);
36//!
37//!    Ok(())
38//! }
39//! ```
40//! 
41//! *Note:* This crate does not implement any of the logic to comply with Last.fm's scrobbling rules. Typical
42//! ("real-time") implementations will likely want to adhere to these rules, outlined in Last.fm's 
43//! [API Documentation](https://www.last.fm/api/scrobbling#scrobble-requests). Other implementations may choose to
44//! ignore these guidelines. This crate provides the flexibility to develop any type of Scrobbling application.
45//! 
46#[macro_use]
47extern crate wrapped_vec;
48
49mod auth;
50mod client;
51mod error;
52mod models;
53mod scrobbler;
54
55pub use crate::models::metadata::{Scrobble, ScrobbleBatch};
56pub use crate::scrobbler::Scrobbler;
57pub use crate::error::ScrobblerError;
58
59
60/// Last.fm API Response Types
61/// 
62/// Types used to represent responses from the Last.fm API
63pub mod responses {
64    pub use crate::models::responses::{
65        BatchScrobbleResponse, NowPlayingResponse, ScrobbleResponse, SessionResponse,
66    };
67
68    /// Data types used to represent values in API Response types
69    pub mod values {
70        pub use crate::models::responses::{CorrectableString, ScrobbleList};
71    }
72}