fix(library): allow local artwork paths
This commit is contained in:
1 parent
3f13212978
commit
be28ab1396
3 files changed
+22
-4
No files matched your search
@@ -21,6 +21,12 @@ fn get_artwork_cache_dir() -> Result<PathBuf, String> {
|
||||
|
||||
/// Download artwork to cache and return the path
|
||||
fn cache_artwork(url: &str) -> Result<PathBuf, String> {
|
||||
if let Some(local_path) = resolve_local_artwork(url) {
|
||||
if local_path.exists() {
|
||||
return Ok(local_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a hash of the URL for the filename
|
||||
let mut hasher = Md5::new();
|
||||
hasher.update(url.as_bytes());
|
||||
@@ -56,6 +62,19 @@ fn cache_artwork(url: &str) -> Result<PathBuf, String> {
|
||||
Ok(cache_path)
|
||||
}
|
||||
|
||||
fn resolve_local_artwork(url: &str) -> Option<PathBuf> {
|
||||
if let Some(path) = url.strip_prefix("file://") {
|
||||
return Some(PathBuf::from(path));
|
||||
}
|
||||
|
||||
if let Some(path) = url.strip_prefix("asset://localhost/") {
|
||||
let decoded = urlencoding::decode(path).ok()?;
|
||||
return Some(PathBuf::from(decoded.into_owned()));
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Format quality info for notification
|
||||
fn format_quality(bit_depth: Option<u32>, sample_rate: Option<u32>) -> String {
|
||||
match (bit_depth, sample_rate) {
|
||||
|
||||
Reference in new issue
Block a user