musichoard/examples/musicbrainz_api/lookup_artist_release_groups.rs

37 lines
921 B
Rust
Raw Normal View History

#![allow(non_snake_case)]
use musichoard::{
external::musicbrainz::api::{client::MusicBrainzApiClient, MusicBrainzApi},
interface::musicbrainz::{IMusicBrainz, Mbid},
};
use structopt::StructOpt;
use uuid::Uuid;
const USER_AGENT: &str = concat!(
"MusicHoard---examples---musicbrainz-api---lookup-artist-release-groups/",
env!("CARGO_PKG_VERSION"),
" ( musichoard@thenineworlds.net )"
);
#[derive(StructOpt)]
struct Opt {
#[structopt(help = "Artist MBID to lookup")]
mbid: Uuid,
}
fn main() {
let opt = Opt::from_args();
println!("USER_AGENT: {USER_AGENT}");
let client = MusicBrainzApiClient::new(USER_AGENT).expect("failed to create API client");
let mut api = MusicBrainzApi::new(client);
let mbid: Mbid = opt.mbid.into();
let albums = api
.lookup_artist_release_groups(&mbid)
.expect("failed to make API call");
println!("{albums:#?}");
}