1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-02 03:01:04 +02:00

fix(music): remote mpris album art not showing

Fixes #55.
This commit is contained in:
Jake Stanger 2023-01-29 17:46:40 +00:00
parent 15f0857859
commit 5772711192
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
5 changed files with 28 additions and 24 deletions

View file

@ -22,7 +22,7 @@ pub struct Track {
pub disc: Option<u64>,
pub genre: Option<String>,
pub track: Option<u64>,
pub cover_path: Option<PathBuf>,
pub cover_path: Option<String>,
}
#[derive(Clone, Debug)]

View file

@ -121,12 +121,16 @@ impl MpdClient {
fn convert_song(song: &Song, music_dir: &Path) -> Track {
let (track, disc) = song.number();
let cover_path = music_dir.join(
song.file_path()
.parent()
.expect("Song path should not be root")
.join("cover.jpg"),
);
let cover_path = music_dir
.join(
song.file_path()
.parent()
.expect("Song path should not be root")
.join("cover.jpg"),
)
.into_os_string()
.into_string()
.ok();
Track {
title: song.title().map(std::string::ToString::to_string),
@ -136,7 +140,7 @@ impl MpdClient {
genre: try_get_first_tag(song, &Tag::Genre).map(std::string::ToString::to_string),
disc: Some(disc),
track: Some(track),
cover_path: Some(cover_path),
cover_path,
}
}
}

View file

@ -5,7 +5,6 @@ use color_eyre::Result;
use lazy_static::lazy_static;
use mpris::{DBusError, Event, Metadata, PlaybackStatus, Player, PlayerFinder};
use std::collections::HashSet;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::time::Duration;
@ -260,10 +259,7 @@ impl From<Metadata> for Track {
.and_then(mpris::MetadataValue::as_str_array)
.and_then(|arr| arr.first().map(|val| (*val).to_string())),
track: value.track_number().map(|track| track as u64),
cover_path: value
.art_url()
.map(|path| path.replace("file://", ""))
.map(PathBuf::from),
cover_path: value.art_url().map(|s| s.to_string()),
}
}
}