musichoard/examples/musicbrainz_api/lookup_artist.rs
Wojciech Kozlowski 041a91de4c
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 2m41s
Cargo CI / Lint (pull_request) Failing after 1m4s
Split API over multiple files
2024-08-28 16:39:35 +02:00

43 lines
1021 B
Rust

#![allow(non_snake_case)]
use musichoard::{
external::musicbrainz::{
api::{lookup::LookupArtistRequest, MusicBrainzClient},
http::MusicBrainzHttp,
},
interface::musicbrainz::Mbid,
};
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();
let albums = client
.lookup_artist(request)
.expect("failed to make API call");
println!("{albums:#?}");
}