2021-01-09 03:36:14 +00:00
|
|
|
//! API bindings for ListenBrainz.
|
2021-01-19 23:37:39 +00:00
|
|
|
//!
|
|
|
|
//! This crate aims to be an idiomatic wrapper of the [ListenBrainz HTTP API] (version 1).
|
|
|
|
//! It contains functionality for direct access to the API in the [`raw`] module, as well
|
|
|
|
//! as a more convenient [`ListenBrainz`] client which is easier to use.
|
|
|
|
//!
|
2021-10-20 18:19:27 +01:00
|
|
|
//! [ListenBrainz HTTP API]: https://listenbrainz.readthedocs.io/en/production/dev/api/
|
|
|
|
//!
|
2021-01-19 23:37:39 +00:00
|
|
|
//! Generally, using the `raw` functionality is more cumbersome, as its types and functions
|
|
|
|
//! map one-to-one to the HTTP API's JSON input- and response data. Using the `ListenBrainz`
|
|
|
|
//! type is therefore recommended.
|
|
|
|
//!
|
2021-01-20 00:11:47 +00:00
|
|
|
//! # Example
|
|
|
|
//!
|
2021-10-20 18:19:27 +01:00
|
|
|
//! Submit a currently playing song to ListenBrainz.org:
|
2021-01-20 00:11:47 +00:00
|
|
|
//! ```no_run
|
|
|
|
//! # use listenbrainz::ListenBrainz;
|
|
|
|
//! #
|
|
|
|
//! let mut client = ListenBrainz::new();
|
|
|
|
//!
|
|
|
|
//! client.authenticate("LISTENBRAINZ TOKEN")
|
|
|
|
//! .expect("Could not authenticate with ListenBrainz");
|
|
|
|
//!
|
|
|
|
//! client.playing_now("The Beatles", "Here Comes the Sun", "Abbey Road")
|
|
|
|
//! .expect("Could not submit 'playing now' request");
|
|
|
|
//! ```
|
|
|
|
//!
|
2021-10-20 18:19:27 +01:00
|
|
|
//! Use a custom API URL, for example to submit songs to [Maloja]:
|
|
|
|
//! ```no_run
|
|
|
|
//! # use listenbrainz::ListenBrainz;
|
|
|
|
//! #
|
|
|
|
//! let mut client = ListenBrainz::new_with_url("http://maloja.example.com/apis/listenbrainz");
|
|
|
|
//!
|
|
|
|
//! client.authenticate("MALOJA API KEY")
|
|
|
|
//! .expect("Could not authenticate with Maloja");
|
|
|
|
//!
|
|
|
|
//! client.listen("Lymbyc Systym", "Split Stones", "Split Stones")
|
|
|
|
//! .expect("Could not submit listen");
|
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! [Maloja](https://github.com/krateng/maloja)
|
2021-01-09 03:36:14 +00:00
|
|
|
|
2021-10-19 22:56:42 +01:00
|
|
|
#![deny(
|
|
|
|
missing_docs,
|
|
|
|
missing_debug_implementations,
|
|
|
|
unsafe_code,
|
|
|
|
unstable_features
|
|
|
|
)]
|
|
|
|
|
2021-01-10 18:30:03 +00:00
|
|
|
mod error;
|
2021-01-19 22:41:54 +00:00
|
|
|
pub mod raw;
|
2021-01-19 23:16:53 +00:00
|
|
|
mod wrapper;
|
2021-01-09 03:36:14 +00:00
|
|
|
|
2021-01-14 01:42:17 +00:00
|
|
|
pub use crate::error::Error;
|
2021-01-19 23:16:53 +00:00
|
|
|
pub use crate::wrapper::ListenBrainz;
|