From 7401d6a96eab95950a360d7ea890b828684bb964 Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 20 Sep 2021 14:20:44 -0300 Subject: [PATCH] Don't panic on local files (#846) Skip tracks whose Spotify ID can't be found --- CHANGELOG.md | 1 + metadata/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 834b0bbf..83bf64fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [playback] `alsa`, `gstreamer`, `pulseaudio`: always output in native endianness - [playback] `alsa`: revert buffer size to ~500 ms - [playback] `alsa`, `pipe`, `pulseaudio`: better error handling +- [metadata] Skip tracks whose Spotify ID's can't be found (e.g. local files, which aren't supported) ## [0.2.0] - 2021-05-04 diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index cf663ce6..2ed9273e 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -291,10 +291,10 @@ impl Metadata for Playlist { .get_contents() .get_items() .iter() - .map(|item| { + .filter_map(|item| { let uri_split = item.get_uri().split(':'); let uri_parts: Vec<&str> = uri_split.collect(); - SpotifyId::from_base62(uri_parts[2]).unwrap() + SpotifyId::from_base62(uri_parts[2]).ok() }) .collect::>();