Skip to content
Closed
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
16 changes: 8 additions & 8 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions pr-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Summary
- Replace `viuer` with `ratatui-image` for rendering cover images
- Remove manual `set_skip` / `clear_area` hacks — `ratatui-image` renders as a native ratatui widget
- Remove `viuer` initialization in `main.rs`, use `Picker::from_query_stdio()` for protocol auto-detection
- Remove `cover_img_scale` usage (no longer needed — scaling is handled by `ratatui-image`)

## Notes
`Picker::from_query_stdio()` must run after `enable_raw_mode()` but before `EnterAlternateScreen` for correct protocol detection.

In nested terminals (e.g. neovim floating terminal), stdio queries don't reach the actual terminal emulator, so the protocol falls back to Halfblocks. This is a known limitation of `ratatui-image`'s detection approach. Regular terminals (foot, kitty, iTerm2, etc.) work correctly.

README still references `viuer` — leaving that for maintainer to decide how to update.
2 changes: 1 addition & 1 deletion spotify_player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ log = "0.4.29"
chrono = "0.4.44"
chrono-humanize = "0.2.3"
reqwest = { version = "0.13.2", features = ["json", "query"] }
rspotify = {version = "0.15.3", features = ["cli"] }
rspotify = {version = "0.16.0", features = ["cli"] }
serde = { version = "1.0.228", features = ["derive"] }
tokio = { version = "1.50.0", features = [
"rt",
Expand Down
17 changes: 11 additions & 6 deletions spotify_player/src/cli/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use crate::{
PlaylistId, SharedState, TrackId,
},
};
use rspotify::prelude::{BaseClient, OAuthClient};
use rspotify::{
model::LibraryId,
prelude::{BaseClient, OAuthClient},
};

use super::{
Command, Deserialize, EditAction, GetRequest, IdOrName, ItemId, ItemType, Key, PlaylistCommand,
Expand Down Expand Up @@ -179,9 +182,9 @@ async fn handle_socket_request(

if let Some(id) = track.and_then(|t| t.id.clone()) {
if unlike {
client.current_user_saved_tracks_delete([id]).await?;
client.library_remove([LibraryId::Track(id)]).await?;
} else {
client.current_user_saved_tracks_add([id]).await?;
client.library_add([LibraryId::Track(id)]).await?;
}
}

Expand Down Expand Up @@ -513,15 +516,17 @@ async fn handle_playlist_request(client: &AppClient, command: PlaylistCommand) -
}
PlaylistCommand::Delete { id } => {
let following = client
.playlist_check_follow(id.clone(), &[uid])
.library_contains([LibraryId::Playlist(id.clone())])
.await
.context(format!("Could not find playlist '{}'", id.id()))?
.pop()
.unwrap();

// Won't delete if not following
if following {
client.playlist_unfollow(id.clone()).await?;
client
.library_remove([LibraryId::Playlist(id.clone())])
.await?;
Ok(format!("Playlist '{id}' was deleted/unfollowed"))
} else {
Ok(format!(
Expand Down Expand Up @@ -595,7 +600,7 @@ async fn handle_playlist_request(client: &AppClient, command: PlaylistCommand) -
}

let pl_follow = client
.playlist_check_follow(to_id.as_ref(), &[uid.as_ref()])
.library_contains([LibraryId::Playlist(to_id.as_ref())])
.await?
.pop()
.unwrap();
Expand Down
48 changes: 30 additions & 18 deletions spotify_player/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use librespot_core::SpotifyUri;
use parking_lot::Mutex;

use reqwest::StatusCode;
use rspotify::model::LibraryId;
use rspotify::{http::Query, prelude::*};

mod handlers;
Expand Down Expand Up @@ -689,6 +690,7 @@ impl AppClient {

/// Get Spotify's available browse categories
pub async fn browse_categories(&self) -> Result<Vec<Category>> {
#[allow(deprecated)]
let first_page = self
.categories_manual(Some("EN"), None, Some(50), None)
.await?;
Expand Down Expand Up @@ -996,6 +998,7 @@ impl AppClient {
.filter_map(|t| TrackId::from_id(t.original_gid).ok());

// Retrieve tracks based on IDs
#[allow(deprecated)]
let tracks = self
.tracks(track_ids, Some(rspotify::model::Market::FromToken))
.await?;
Expand Down Expand Up @@ -1200,10 +1203,10 @@ impl AppClient {
match item {
Item::Track(track) => {
let contains = self
.current_user_saved_tracks_contains([track.id.as_ref()])
.library_contains([LibraryId::Track(track.id.as_ref())])
.await?;
if !contains[0] {
self.current_user_saved_tracks_add([track.id.as_ref()])
self.library_add([LibraryId::Track(track.id.as_ref())])
.await?;
// update the in-memory `user_data`
state
Expand All @@ -1216,19 +1219,22 @@ impl AppClient {
}
Item::Album(album) => {
let contains = self
.current_user_saved_albums_contains([album.id.as_ref()])
.library_contains([LibraryId::Album(album.id.as_ref())])
.await?;
if !contains[0] {
self.current_user_saved_albums_add([album.id.as_ref()])
self.library_add([LibraryId::Album(album.id.as_ref())])
.await?;
// update the in-memory `user_data`
state.data.write().user_data.saved_albums.insert(0, album);
}
}
Item::Artist(artist) => {
let follows = self.user_artist_check_follow([artist.id.as_ref()]).await?;
let follows = self
.library_contains([LibraryId::Artist(artist.id.as_ref())])
.await?;
if !follows[0] {
self.user_follow_artists([artist.id.as_ref()]).await?;
self.library_add([LibraryId::Artist(artist.id.as_ref())])
.await?;
// update the in-memory `user_data`
state
.data
Expand All @@ -1247,12 +1253,13 @@ impl AppClient {
.as_ref()
.map(|u| u.id.clone());

if let Some(user_id) = user_id {
if let Some(_user_id) = user_id {
let follows = self
.playlist_check_follow(playlist.id.as_ref(), &[user_id])
.library_contains([LibraryId::Playlist(playlist.id.as_ref())])
.await?;
if !follows[0] {
self.playlist_follow(playlist.id.as_ref(), None).await?;
self.library_add([LibraryId::Playlist(playlist.id.as_ref())])
.await?;
// update the in-memory `user_data`
state
.data
Expand All @@ -1264,9 +1271,12 @@ impl AppClient {
}
}
Item::Show(show) => {
let follows = self.check_users_saved_shows([show.id.as_ref()]).await?;
let follows = self
.library_contains([LibraryId::Show(show.id.as_ref())])
.await?;
if !follows[0] {
self.save_shows([show.id.as_ref()]).await?;
self.library_add([LibraryId::Show(show.id.as_ref())])
.await?;
// update the in-memory `user_data`
state.data.write().user_data.saved_shows.insert(0, show);
}
Expand All @@ -1280,7 +1290,7 @@ impl AppClient {
match id {
ItemId::Track(id) => {
let uri = id.uri();
self.current_user_saved_tracks_delete([id]).await?;
self.library_remove([LibraryId::Track(id)]).await?;
state.data.write().user_data.saved_tracks.remove(&uri);
}
ItemId::Album(id) => {
Expand All @@ -1290,7 +1300,7 @@ impl AppClient {
.user_data
.saved_albums
.retain(|a| a.id != id);
self.current_user_saved_albums_delete([id]).await?;
self.library_remove([LibraryId::Album(id)]).await?;
}
ItemId::Artist(id) => {
state
Expand All @@ -1299,7 +1309,7 @@ impl AppClient {
.user_data
.followed_artists
.retain(|a| a.id != id);
self.user_unfollow_artists([id]).await?;
self.library_remove([LibraryId::Artist(id)]).await?;
}
ItemId::Playlist(id) => {
state
Expand All @@ -1311,7 +1321,7 @@ impl AppClient {
PlaylistFolderItem::Playlist(p) => p.id != id,
PlaylistFolderItem::Folder(_) => true,
});
self.playlist_unfollow(id).await?;
self.library_remove([LibraryId::Playlist(id)]).await?;
}
ItemId::Show(id) => {
state
Expand All @@ -1320,8 +1330,7 @@ impl AppClient {
.user_data
.saved_shows
.retain(|s| s.id != id);
self.remove_users_saved_shows([id], Some(rspotify::model::Market::FromToken))
.await?;
self.library_remove([LibraryId::Show(id)]).await?;
}
}
Ok(())
Expand Down Expand Up @@ -1356,7 +1365,7 @@ impl AppClient {
"{SPOTIFY_API_ENDPOINT}/playlists/{}/tracks",
playlist_id.id(),
),
playlist.tracks.total as usize,
playlist.items.total as usize,
)
.await?
.into_iter()
Expand Down Expand Up @@ -1418,6 +1427,8 @@ impl AppClient {
.context("get artist")?
.into();

// this is the main feb 2026 spotify api update
#[allow(deprecated)]
let top_tracks = self
.artist_top_tracks(artist_id.as_ref(), Some(rspotify::model::Market::FromToken))
.await
Expand Down Expand Up @@ -1726,6 +1737,7 @@ impl AppClient {
&track.album.id.as_ref().unwrap().id()[..6]
)
}
#[allow(deprecated)]
rspotify::model::PlayableItem::Episode(ref episode) => {
format!(
"{}-{}-cover-{}.jpg",
Expand Down
44 changes: 25 additions & 19 deletions spotify_player/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use crate::{
key::{Key, KeySequence},
state::{
ActionListItem, Album, AlbumId, Artist, ArtistFocusState, ArtistId, ArtistPopupAction,
BrowsePageUIState, Context, ContextId, ContextPageType, ContextPageUIState, DataReadGuard,
Focusable, Id, Item, ItemId, LibraryFocusState, LibraryPageUIState, PageState, PageType,
PlayableId, Playback, PlaylistCreateCurrentField, PlaylistFolderItem, PlaylistId,
PlaylistPopupAction, PopupState, SearchFocusState, SearchPageUIState, SharedState, ShowId,
Track, TrackId, TrackOrder, TracksId, UIStateGuard, USER_LIKED_TRACKS_ID,
USER_RECENTLY_PLAYED_TRACKS_ID, USER_TOP_TRACKS_ID,
BrowsePageUIState, ConfirmableAction, Context, ContextId, ContextPageType,
ContextPageUIState, DataReadGuard, Focusable, Id, Item, ItemId, LibraryFocusState,
LibraryPageUIState, PageState, PageType, PlayableId, Playback, PlaylistCreateCurrentField,
PlaylistFolderItem, PlaylistId, PlaylistPopupAction, PopupState, SearchFocusState,
SearchPageUIState, SharedState, ShowId, Track, TrackId, TrackOrder, TracksId, UIStateGuard,
USER_LIKED_TRACKS_ID, USER_RECENTLY_PLAYED_TRACKS_ID, USER_TOP_TRACKS_ID,
},
ui::{single_line_input::LineInput, Orientation},
utils::parse_uri,
Expand Down Expand Up @@ -289,12 +289,14 @@ pub fn handle_action_in_context(
..
} = ui.current_page()
{
client_pub.send(ClientRequest::DeleteTrackFromPlaylist(
playlist_id.clone_static(),
track.id,
))?;
ui.popup = Some(PopupState::ConfirmAction {
message: format!("Delete {}?", track.name),
action: ConfirmableAction::DeleteTrackFromPlaylist {
playlist_id: playlist_id.clone_static(),
track_id: track.id,
},
});
}
ui.popup = None;
Ok(true)
}
_ => Ok(false),
Expand All @@ -318,8 +320,10 @@ pub fn handle_action_in_context(
Ok(true)
}
Action::DeleteFromLibrary => {
client_pub.send(ClientRequest::DeleteFromLibrary(ItemId::Album(album.id)))?;
ui.popup = None;
ui.popup = Some(PopupState::ConfirmAction {
message: format!("Delete {}?", album.name),
action: ConfirmableAction::DeleteFromLibrary(ItemId::Album(album.id)),
});
Ok(true)
}
Action::CopyLink => {
Expand Down Expand Up @@ -376,10 +380,10 @@ pub fn handle_action_in_context(
Ok(true)
}
Action::DeleteFromLibrary => {
client_pub.send(ClientRequest::DeleteFromLibrary(ItemId::Playlist(
playlist.id,
)))?;
ui.popup = None;
ui.popup = Some(PopupState::ConfirmAction {
message: format!("Delete {}?", playlist.name),
action: ConfirmableAction::DeleteFromLibrary(ItemId::Playlist(playlist.id)),
});
Ok(true)
}
_ => Ok(false),
Expand All @@ -397,8 +401,10 @@ pub fn handle_action_in_context(
Ok(true)
}
Action::DeleteFromLibrary => {
client_pub.send(ClientRequest::DeleteFromLibrary(ItemId::Show(show.id)))?;
ui.popup = None;
ui.popup = Some(PopupState::ConfirmAction {
message: format!("Delete {}?", show.name),
action: ConfirmableAction::DeleteFromLibrary(ItemId::Show(show.id)),
});
Ok(true)
}
_ => Ok(false),
Expand Down
Loading
Loading