Formatting
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -82,7 +82,10 @@ async fn main() -> anyhow::Result<()> {
|
||||
} else if results.is_empty() {
|
||||
println!("No artists found.");
|
||||
} else {
|
||||
println!("{:<40} {:<8} {:<5} {}", "NAME", "COUNTRY", "SCORE", "DISAMBIGUATION");
|
||||
println!(
|
||||
"{:<40} {:<8} {:<5} DISAMBIGUATION",
|
||||
"NAME", "COUNTRY", "SCORE"
|
||||
);
|
||||
for r in &results {
|
||||
println!(
|
||||
"{:<40} {:<8} {:<5} {}",
|
||||
@@ -104,7 +107,10 @@ async fn main() -> anyhow::Result<()> {
|
||||
} else if results.is_empty() {
|
||||
println!("No albums found.");
|
||||
} else {
|
||||
println!("{:<35} {:<25} {:<6} {:<5}", "TITLE", "ARTIST", "YEAR", "SCORE");
|
||||
println!(
|
||||
"{:<35} {:<25} {:<6} {:<5}",
|
||||
"TITLE", "ARTIST", "YEAR", "SCORE"
|
||||
);
|
||||
for r in &results {
|
||||
println!(
|
||||
"{:<35} {:<25} {:<6} {:<5}",
|
||||
@@ -126,13 +132,19 @@ async fn main() -> anyhow::Result<()> {
|
||||
} else if results.is_empty() {
|
||||
println!("No tracks found.");
|
||||
} else {
|
||||
println!("{:<35} {:<25} {:<25} {:<5}", "TITLE", "ARTIST", "ALBUM", "SCORE");
|
||||
println!(
|
||||
"{:<35} {:<25} {:<25} {:<5}",
|
||||
"TITLE", "ARTIST", "ALBUM", "SCORE"
|
||||
);
|
||||
for r in &results {
|
||||
println!(
|
||||
"{:<35} {:<25} {:<25} {:<5}",
|
||||
truncate(&r.title, 35),
|
||||
truncate(&r.artist, 25),
|
||||
r.album.as_deref().map(|a| truncate(a, 25)).unwrap_or_default(),
|
||||
r.album
|
||||
.as_deref()
|
||||
.map(|a| truncate(a, 25))
|
||||
.unwrap_or_default(),
|
||||
r.score,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use shanty_tag::provider::MetadataProvider;
|
||||
use shanty_tag::MusicBrainzClient;
|
||||
use shanty_tag::provider::MetadataProvider;
|
||||
|
||||
use crate::error::SearchResult;
|
||||
use crate::provider::{
|
||||
@@ -20,11 +20,7 @@ impl MusicBrainzSearch {
|
||||
}
|
||||
|
||||
impl SearchProvider for MusicBrainzSearch {
|
||||
async fn search_artist(
|
||||
&self,
|
||||
query: &str,
|
||||
limit: u32,
|
||||
) -> SearchResult<Vec<ArtistResult>> {
|
||||
async fn search_artist(&self, query: &str, limit: u32) -> SearchResult<Vec<ArtistResult>> {
|
||||
let results = self.client.search_artist(query, limit).await?;
|
||||
Ok(results
|
||||
.into_iter()
|
||||
@@ -55,7 +51,11 @@ impl SearchProvider for MusicBrainzSearch {
|
||||
title: r.title,
|
||||
artist: r.artist,
|
||||
artist_id: r.artist_mbid,
|
||||
year: r.date.as_deref().and_then(|d| d.split('-').next()).map(String::from),
|
||||
year: r
|
||||
.date
|
||||
.as_deref()
|
||||
.and_then(|d| d.split('-').next())
|
||||
.map(String::from),
|
||||
track_count: r.track_count,
|
||||
score: r.score,
|
||||
})
|
||||
@@ -85,10 +85,7 @@ impl SearchProvider for MusicBrainzSearch {
|
||||
.collect())
|
||||
}
|
||||
|
||||
async fn get_discography(
|
||||
&self,
|
||||
artist_id: &str,
|
||||
) -> SearchResult<Discography> {
|
||||
async fn get_discography(&self, artist_id: &str) -> SearchResult<Discography> {
|
||||
let releases = self.client.get_artist_releases(artist_id, 100).await?;
|
||||
|
||||
// Try to get the artist name from the first release, or use the MBID
|
||||
|
||||
Reference in New Issue
Block a user