mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Search through full playlist for unplayable tracks
This commit is contained in:
parent
a28199f073
commit
16112d71b9
1 changed files with 4 additions and 17 deletions
|
@ -913,20 +913,7 @@ impl SpircTask {
|
||||||
|
|
||||||
// Mark unavailable tracks so we can skip them later
|
// Mark unavailable tracks so we can skip them later
|
||||||
fn handle_unavailable(&mut self, track_id: SpotifyId) {
|
fn handle_unavailable(&mut self, track_id: SpotifyId) {
|
||||||
let playing_index = self.state.get_playing_track_index() as usize;
|
let unavailables = self.get_track_index_for_spotify_id(&track_id, 0);
|
||||||
let mut unavailables = self.get_track_index_for_spotify_id(&track_id, playing_index);
|
|
||||||
if unavailables.is_empty() {
|
|
||||||
trace!(
|
|
||||||
"Couldn't find unavailables searching from {:?} -- {:?}, cycling through entire playlist",
|
|
||||||
playing_index,
|
|
||||||
self.state.get_track().len()
|
|
||||||
);
|
|
||||||
// We could just do this everytime, but for most cases it's needless overhead.
|
|
||||||
// we are still repeating the serach for (playing_index..) in this case
|
|
||||||
unavailables = self.get_track_index_for_spotify_id(&track_id, 0);
|
|
||||||
}
|
|
||||||
// Sanity check
|
|
||||||
debug_assert!(!unavailables.is_empty());
|
|
||||||
for &index in unavailables.iter() {
|
for &index in unavailables.iter() {
|
||||||
debug_assert_eq!(self.state.get_track()[index].get_gid(), track_id.to_raw());
|
debug_assert_eq!(self.state.get_track()[index].get_gid(), track_id.to_raw());
|
||||||
let mut unplayable_track_ref = TrackRef::new();
|
let mut unplayable_track_ref = TrackRef::new();
|
||||||
|
@ -1191,6 +1178,8 @@ impl SpircTask {
|
||||||
.filter(|&(_, track_ref)| track_ref.get_gid() == track_id.to_raw())
|
.filter(|&(_, track_ref)| track_ref.get_gid() == track_id.to_raw())
|
||||||
.map(|(idx, _)| start_index + idx)
|
.map(|(idx, _)| start_index + idx)
|
||||||
.collect();
|
.collect();
|
||||||
|
// Sanity check
|
||||||
|
debug_assert!(!index.is_empty());
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,9 +1211,7 @@ impl SpircTask {
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Skipping track <{:?}> at position [{}] of {}",
|
"Skipping track <{:?}> at position [{}] of {}",
|
||||||
track_ref.get_uri(),
|
track_ref, new_playlist_index, tracks_len
|
||||||
new_playlist_index,
|
|
||||||
tracks_len
|
|
||||||
);
|
);
|
||||||
|
|
||||||
new_playlist_index += 1;
|
new_playlist_index += 1;
|
||||||
|
|
Loading…
Reference in a new issue