Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 22 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rspotify = { version = "0.14", default-features = false, features = ["cli", "env-file", "client-reqwest", "reqwest-rustls-tls"] }
rspotify = { version = "0.16", default-features = false, features = ["cli", "env-file", "client-reqwest", "reqwest-rustls-tls"] }
ratatui = { version = "0.30", features = ["crossterm", "layout-cache"], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
7 changes: 6 additions & 1 deletion src/cli/cli_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl CliApp {
"https://open.spotify.com/episode/{}",
episode.id.id()
)),
_ => Err(anyhow!("unknown playable item type")),
}
} else {
Err(anyhow!(
Expand Down Expand Up @@ -115,6 +116,7 @@ impl CliApp {
"https://open.spotify.com/show/{}",
episode.show.id.id()
)),
_ => Err(anyhow!("unknown playable item type")),
}
} else {
Err(anyhow!(
Expand Down Expand Up @@ -314,6 +316,7 @@ impl CliApp {
let duration = match item {
PlayableItem::Track(track) => track.duration.num_milliseconds() as u32,
PlayableItem::Episode(episode) => episode.duration.num_milliseconds() as u32,
_ => return Err(anyhow!("unknown playable item type")),
};

(ms.num_milliseconds() as u32, duration)
Expand Down Expand Up @@ -368,6 +371,7 @@ impl CliApp {
Some(i) => match i {
PlayableItem::Track(t) => t.id.ok_or_else(|| anyhow!("item has no id")),
PlayableItem::Episode(_) => Err(anyhow!("saving episodes not yet implemented")),
_ => Err(anyhow!("unknown playable item type")),
},
None => Err(anyhow!("no item playing")),
}?;
Expand Down Expand Up @@ -469,6 +473,7 @@ impl CliApp {
)));
hs
}
_ => return Err(anyhow!("unknown playable item type")),
};

hs.push(Format::Device(context.device.name));
Expand All @@ -487,7 +492,7 @@ impl CliApp {
if let Ok(playlist_id) = rspotify::model::idtypes::PlaylistId::from_id(id_str) {
match self.net.spotify.playlist(playlist_id, None, None).await {
Ok(p) => {
let num = p.tracks.total;
let num = p.items.total;
Some(thread_rng().gen_range(0..num) as usize)
}
Err(e) => {
Expand Down
12 changes: 6 additions & 6 deletions src/cli/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,17 @@ impl Format {
}
FormatType::Show(r) => {
let uri = r.id.uri();
vec![
Self::Artist(r.publisher),
Self::Show(r.name),
Self::Uri(uri),
]
#[allow(deprecated)]
let publisher = r.publisher;
vec![Self::Artist(publisher), Self::Show(r.name), Self::Uri(uri)]
}
FormatType::Episode(e) => {
let uri = e.id.uri();
#[allow(deprecated)]
let publisher = e.show.publisher.clone();
vec![
Self::Show(e.show.name),
Self::Artist(e.show.publisher),
Self::Artist(publisher),
Self::Track(e.name),
Self::Uri(uri),
]
Expand Down
13 changes: 11 additions & 2 deletions src/core/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use rspotify::{
},
prelude::*, // Adds Id trait for .id() method
};
use serde::de::DeserializeOwned;
use std::cell::Cell;
use std::sync::mpsc::Sender;
#[cfg(any(feature = "streaming", all(feature = "mpris", target_os = "linux")))]
Expand Down Expand Up @@ -91,7 +92,7 @@ impl<T> ScrollableResultPages<T> {

// Offset-keyed page caches are always kept sorted by page.offset, but the cache can be sparse.
// Visible-page identity must be derived from page.offset, not raw cache index adjacency.
impl<T> ScrollableResultPages<Page<T>> {
impl<T: DeserializeOwned> ScrollableResultPages<Page<T>> {
pub fn page_index_for_offset(&self, offset: u32) -> Option<usize> {
self
.pages
Expand Down Expand Up @@ -1270,6 +1271,7 @@ impl App {
let duration_ms = match item {
PlayableItem::Track(track) => track.duration.num_milliseconds() as u32,
PlayableItem::Episode(episode) => episode.duration.num_milliseconds() as u32,
_ => return,
};

let event = if seek_ms < duration_ms {
Expand Down Expand Up @@ -1380,6 +1382,7 @@ impl App {
let duration_ms = match item {
PlayableItem::Track(track) => track.duration.num_milliseconds() as u128,
PlayableItem::Episode(episode) => episode.duration.num_milliseconds() as u128,
_ => return,
};

self.song_progress_ms = (self.song_progress_ms + tick_rate_ms).min(duration_ms);
Expand All @@ -1400,6 +1403,7 @@ impl App {
let duration_ms = match item {
PlayableItem::Track(track) => track.duration.num_milliseconds() as u32,
PlayableItem::Episode(episode) => episode.duration.num_milliseconds() as u32,
_ => return,
};

let old_progress = match self.seek_ms {
Expand Down Expand Up @@ -1955,6 +1959,7 @@ impl App {
self.handle_error(anyhow!("failed to set clipboard content: {}", e));
}
}
_ => {}
}
}
}
Expand Down Expand Up @@ -1991,6 +1996,7 @@ impl App {
self.handle_error(anyhow!("failed to set clipboard content: {}", e));
}
}
_ => {}
}
}
}
Expand All @@ -2012,7 +2018,7 @@ impl App {
let mut positions: Vec<usize> = Vec::new();

for (idx, item) in playlist_track_page.items.iter().enumerate() {
if let Some(PlayableItem::Track(full_track)) = item.track.as_ref() {
if let Some(PlayableItem::Track(full_track)) = item.item.as_ref() {
tracks.push(full_track.clone());
if let Some(track_id) = full_track.id.as_ref() {
track_ids.push(track_id.clone().into_static());
Expand Down Expand Up @@ -2747,6 +2753,7 @@ impl App {
));
}

#[allow(deprecated)]
pub fn get_user_country(&self) -> Option<Country> {
self.user.as_ref().and_then(|user| user.country)
}
Expand Down Expand Up @@ -3543,6 +3550,7 @@ mod tests {
use std::collections::HashMap;
use std::sync::mpsc::channel;

#[allow(deprecated)]
fn full_track(id: &str, name: &str) -> FullTrack {
FullTrack {
album: SimplifiedAlbum {
Expand All @@ -3569,6 +3577,7 @@ mod tests {
popularity: 50,
preview_url: None,
track_number: 1,
r#type: rspotify::model::Type::Track,
}
}

Expand Down
Loading
Loading