musichoard/examples/musicbrainz_api/lookup_artist.rs

40 lines
983 B
Rust
Raw Normal View History

#![allow(non_snake_case)]
use musichoard::{
2024-08-28 16:17:03 +02:00
external::musicbrainz::{http::MusicBrainzHttp, LookupArtistRequest, MusicBrainzClient},
interface::musicbrainz::Mbid,
};
use structopt::StructOpt;
use uuid::Uuid;
const USER_AGENT: &str = concat!(
2024-08-28 16:17:03 +02:00
"MusicHoard---examples---musicbrainz-api---lookup-artist/",
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}");
2024-08-28 16:17:03 +02:00
let http = MusicBrainzHttp::new(USER_AGENT).expect("failed to create API client");
let mut client = MusicBrainzClient::new(http);
let mbid: Mbid = opt.mbid.into();
2024-08-28 16:17:03 +02:00
let mut request = LookupArtistRequest::new(&mbid);
request.include_release_groups();
let albums = client
.lookup_artist(request)
.expect("failed to make API call");
println!("{albums:#?}");
}