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
28 changes: 14 additions & 14 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 spotify_player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rspotify = "0.11.7"
serde = { version = "1.0.163", features = ["derive"] }
tokio = { version = "1.28.1", features = ["rt", "rt-multi-thread", "macros", "time"] }
toml = "0.7.3"
tui = "0.19.0"
ratatui = "0.21.0"
unicode-width = "0.1.10"
rand = "0.8.5"
maybe-async = "0.2.7"
Expand Down
3 changes: 2 additions & 1 deletion spotify_player/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ pub async fn new_session(auth_config: &AuthConfig, reauth: bool) -> Result<Sessi
}
Err(err) => match err {
SessionError::AuthenticationError(err) => {
let msg = format!("Failed to authenticate using cached credentials: {err}");
let msg =
format!("Failed to authenticate using cached credentials: {err:#}");
if reauth {
eprintln!("{msg}");
new_session_with_new_creds(auth_config).await
Expand Down
6 changes: 3 additions & 3 deletions spotify_player/src/cli/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ pub async fn start_socket(client: Client, state: SharedState) -> Result<()> {
let mut buf = [0; 4096];
loop {
match socket.recv_from(&mut buf).await {
Err(err) => tracing::warn!("Failed to receive from the socket: {err}"),
Err(err) => tracing::warn!("Failed to receive from the socket: {err:#}"),
Ok((n_bytes, dest_addr)) => {
let req_buf = &buf[0..n_bytes];
let request: Request = match serde_json::from_slice(req_buf) {
Ok(v) => v,
Err(err) => {
tracing::error!("Cannot deserialize the socket request: {err}");
tracing::error!("Cannot deserialize the socket request: {err:#}");
continue;
}
};

tracing::info!("Handling socket request: {request:?}...");
let response = match handle_socket_request(&client, &state, request).await {
Err(err) => {
tracing::error!("Failed to handle socket request: {err}");
tracing::error!("Failed to handle socket request: {err:#}");
let msg = format!("Bad request: {err}");
Response::Err(msg.into_bytes())
}
Expand Down
6 changes: 3 additions & 3 deletions spotify_player/src/client/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn start_client_handler(
if client.spotify.session().await.is_invalid() {
tracing::info!("Spotify client's session is invalid, re-creating a new session...");
if let Err(err) = client.new_session(&state).await {
tracing::error!("Failed to create a new session: {err}");
tracing::error!("Failed to create a new session: {err:#}");
continue;
}
}
Expand Down Expand Up @@ -128,10 +128,10 @@ pub async fn start_player_event_watchers(
tokio::time::sleep(refresh_duration).await;

if let Err(err) = handle_track_end_event(&state, &client_pub).await {
tracing::error!("Encountered error when handling track end event: {err}");
tracing::error!("Encountered error when handling track end event: {err:#}");
}
if let Err(err) = handle_queue_change_event(&state, &client_pub).await {
tracing::error!("Encountered error when handling queue change event: {err}");
tracing::error!("Encountered error when handling queue change event: {err:#}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions spotify_player/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl Client {
None
}
Err(err) => {
tracing::error!("Failed to find an available device: {err}");
tracing::error!("Failed to find an available device: {err:#}");
None
}
}
Expand All @@ -397,7 +397,7 @@ impl Client {
if let Some(id) = id {
tracing::info!("Trying to connect to device (id={id})");
if let Err(err) = self.spotify.transfer_playback(&id, Some(false)).await {
tracing::warn!("Connection failed (device_id={id}): {err}");
tracing::warn!("Connection failed (device_id={id}): {err:#}");
} else {
tracing::info!("Connection succeeded (device_id={id})!");
// upon new connection, reset the buffered playback
Expand Down
2 changes: 1 addition & 1 deletion spotify_player/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl AppConfig {
.as_ref()
.and_then(|proxy| match Url::parse(proxy) {
Err(err) => {
tracing::warn!("failed to parse proxy url {proxy}: {err}");
tracing::warn!("failed to parse proxy url {proxy}: {err:#}");
None
}
Ok(url) => Some(url),
Expand Down
9 changes: 6 additions & 3 deletions spotify_player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ mod token;
mod ui;
mod utils;

// as `tui` is not actively maintained, we migrate to use `ratatui`
extern crate ratatui as tui;

use anyhow::{Context, Result};
use std::io::Write;

Expand Down Expand Up @@ -174,7 +177,7 @@ async fn start_app(state: state::SharedState, is_daemon: bool) -> Result<()> {
let state = state.clone();
async move {
if let Err(err) = cli::start_socket(client, state).await {
tracing::warn!("Failed to run client socket for CLI: {err}");
tracing::warn!("Failed to run client socket for CLI: {err:#}");
}
}
}));
Expand Down Expand Up @@ -223,7 +226,7 @@ async fn start_app(state: state::SharedState, is_daemon: bool) -> Result<()> {
move || {
if let Err(err) = media_control::start_event_watcher(state, client_pub) {
tracing::error!(
"Failed to start the application's media control event watcher: err={err:?}"
"Failed to start the application's media control event watcher: err={err:#?}"
);
}
}
Expand Down Expand Up @@ -318,7 +321,7 @@ fn main() -> Result<()> {
daemonize.start()?;
}
if let Err(err) = start_app(state, is_daemon) {
tracing::error!("Encountered an error when running the application: {err}");
tracing::error!("Encountered an error when running the application: {err:#}");
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion spotify_player/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub async fn get_token(session: &Session, client_id: &str) -> Result<Token> {

let token = keymaster::get_token(session, client_id, &SCOPES.join(","))
.await
.map_err(|err| anyhow!(format!("failed to get token: {err:?}")))?;
.map_err(|err| anyhow!(format!("failed to get token: {err:#?}")))?;

// converts the token returned by librespot `get_token` function to a `rspotify::Token`

Expand Down
5 changes: 3 additions & 2 deletions spotify_player/src/ui/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ pub fn render_search_page(
.direction(Direction::Vertical)
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
.split(rect)
.into_iter()
.iter()
.flat_map(|rect| {
Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
.split(rect)
.split(*rect)
.to_vec()
})
.collect::<Vec<_>>();

Expand Down
8 changes: 4 additions & 4 deletions spotify_player/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn render_playback_text(
"\n" => {
let mut tmp = vec![];
std::mem::swap(&mut tmp, &mut spans);
playback_text.lines.push(Spans::from(tmp));
playback_text.lines.push(Line::from(tmp));
continue;
}
"{track}" => (
Expand Down Expand Up @@ -197,7 +197,7 @@ fn render_playback_text(
spans.push(Span::raw(format_str[ptr..].to_string()));
}
if !spans.is_empty() {
playback_text.lines.push(Spans::from(spans));
playback_text.lines.push(Line::from(spans));
}

let playback_desc = Paragraph::new(playback_text).wrap(Wrap { trim: true });
Expand Down Expand Up @@ -271,7 +271,7 @@ fn render_playback_cover_image(
}

if let Err(err) = remove_temp_files() {
tracing::error!("Failed to remove temp files: {err}");
tracing::error!("Failed to remove temp files: {err:#}");
}

let data = state.data.read();
Expand All @@ -297,7 +297,7 @@ fn render_playback_cover_image(
..Default::default()
},
) {
tracing::error!("Failed to render the image: {err}",);
tracing::error!("Failed to render the image: {err:#}",);
}
}
}
Expand Down