2024-08-28 18:21:13 +02:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
|
|
|
use musichoard::{
|
2024-08-29 13:37:47 +02:00
|
|
|
collection::musicbrainz::Mbid,
|
2024-08-28 18:21:13 +02:00
|
|
|
external::musicbrainz::{
|
|
|
|
api::{lookup::LookupArtistRequest, MusicBrainzClient},
|
|
|
|
http::MusicBrainzHttp,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
use structopt::StructOpt;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
const USER_AGENT: &str = concat!(
|
|
|
|
"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}");
|
|
|
|
|
|
|
|
let http = MusicBrainzHttp::new(USER_AGENT).expect("failed to create API client");
|
|
|
|
let mut client = MusicBrainzClient::new(http);
|
|
|
|
|
|
|
|
let mbid: Mbid = opt.mbid.into();
|
|
|
|
let mut request = LookupArtistRequest::new(&mbid);
|
|
|
|
request.include_release_groups();
|
|
|
|
|
2024-09-22 16:08:22 +02:00
|
|
|
let response = client
|
2024-08-28 18:21:13 +02:00
|
|
|
.lookup_artist(request)
|
|
|
|
.expect("failed to make API call");
|
|
|
|
|
2024-09-22 16:08:22 +02:00
|
|
|
println!("{response:#?}");
|
2024-08-28 18:21:13 +02:00
|
|
|
}
|