Skip to content

Commit

Permalink
add patch for null issue with images field when getting user playli…
Browse files Browse the repository at this point in the history
…st (#402)

Resolves #401
  • Loading branch information
aome510 authored Mar 29, 2024
1 parent 174876f commit 670fcbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .dir-locals.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((rustic-mode . ((lsp-rust-features . ["lyric-finder" "image" "notify" "clipboard"]))))
((rustic-mode . ((eglot-workspace-configuration
. (:rust-analyzer (:cargo (:features ["lyric-finder" "image" "notify" "clipboard"])
:check (:command "clippy")))))))
18 changes: 12 additions & 6 deletions spotify_player/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use librespot_connect::spirc::Spirc;
use librespot_core::session::Session;
use rspotify::{
http::Query,
model::{FullPlaylist, Market},
model::{FullPlaylist, Market, Page, SimplifiedPlaylist},
prelude::*,
};

Expand Down Expand Up @@ -47,9 +47,7 @@ struct TrackData {
const SPOTIFY_API_ENDPOINT: &str = "https://api.spotify.com/v1";

fn market_query() -> Query<'static> {
let mut payload = Query::with_capacity(1);
payload.insert("market", "from_token");
payload
Query::from([("market", "from_token")])
}

impl Client {
Expand Down Expand Up @@ -678,10 +676,18 @@ impl Client {

/// gets all playlists of the current user
pub async fn current_user_playlists(&self) -> Result<Vec<Playlist>> {
// TODO: this should use `rspotify::current_user_playlists_manual` API instead of `internal_call`
// See: https://github.com/ramsayleung/rspotify/issues/459
let first_page = self
.spotify
.current_user_playlists_manual(Some(50), None)
.internal_call::<Page<SimplifiedPlaylist>>(
&format!("{SPOTIFY_API_ENDPOINT}/me/playlists"),
&Query::from([("limit", "50")]),
)
.await?;
// let first_page = self
// .spotify
// .current_user_playlists_manual(Some(50), None)
// .await?;

let playlists = self.all_paging_items(first_page, &Query::new()).await?;
Ok(playlists.into_iter().map(|p| p.into()).collect())
Expand Down

0 comments on commit 670fcbe

Please sign in to comment.