From e3e75f7a173ea9186fabbea5cc2508e9777a57bd Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Sun, 16 Mar 2025 12:03:50 +0100 Subject: [PATCH] fix: Skip unplayable tracks I think this worked before but must have regressed. The value `is_playable` was not taken into account and instead overshadowed by a dummy method. Fixes #1552 --- CHANGELOG.md | 7 +++++++ src/model/playable.rs | 4 ++++ src/model/track.rs | 2 +- src/spotify.rs | 8 ++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cbdf48..6522e48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Skip unplayable tracks + ## [1.2.2] ### Added @@ -231,6 +237,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Albums with more than 50 songs not showing all the songs when viewed in the library - Bug that could cause items to not load until the screen is filled on bigger screens +[Unreleased]: https://github.com/hrkfdn/ncspot/compare/v1.2.2..HEAD [1.2.2]: https://github.com/hrkfdn/ncspot/compare/v1.2.1...v1.2.2 [1.2.1]: https://github.com/hrkfdn/ncspot/compare/v1.2.0...v1.2.1 [1.2.0]: https://github.com/hrkfdn/ncspot/compare/v1.1.2...v1.2.0 diff --git a/src/model/playable.rs b/src/model/playable.rs index 4668925..1db903d 100644 --- a/src/model/playable.rs +++ b/src/model/playable.rs @@ -173,6 +173,10 @@ impl fmt::Display for Playable { } impl ListItem for Playable { + fn is_playable(&self) -> bool { + self.as_listitem().is_playable() + } + fn is_playing(&self, queue: &Queue) -> bool { self.as_listitem().is_playing(queue) } diff --git a/src/model/track.rs b/src/model/track.rs index 9c8c937..66dfde7 100644 --- a/src/model/track.rs +++ b/src/model/track.rs @@ -336,7 +336,7 @@ impl ListItem for Track { #[inline] fn is_playable(&self) -> bool { - true + self.is_playable == Some(true) } fn as_listitem(&self) -> Box { diff --git a/src/spotify.rs b/src/spotify.rs index 6a24d5b..8694f0b 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -29,6 +29,7 @@ use crate::model::playable::Playable; use crate::mpris::{MprisCommand, MprisManager}; use crate::spotify_api::WebApi; use crate::spotify_worker::{Worker, WorkerCommand}; +use crate::traits::ListItem; /// One percent of the maximum supported [Player] volume, used when setting the volume to a certain /// percent. @@ -316,6 +317,13 @@ impl Spotify { /// `start_playing` is true. Start playing from `position_ms` in the song. pub fn load(&self, track: &Playable, start_playing: bool, position_ms: u32) { info!("loading track: {:?}", track); + + if !track.is_playable() { + warn!("track {:?} can not be played, skipping..", track); + self.events.send(Event::Player(PlayerEvent::FinishedTrack)); + return; + } + self.send_worker(WorkerCommand::Load( track.clone(), start_playing,