MCPcopy Create free account
hub / github.com/Moosync/Moosync / get_playlist_content

Method get_playlist_content

src-tauri/src/providers/spotify.rs:577–621  ·  view source on GitHub ↗
(
        &self,
        playlist: QueryablePlaylist,
        pagination: Pagination,
    )

Source from the content-addressed store, hash-verified

575
576 #[tracing::instrument(level = "debug", skip(self, playlist, pagination))]
577 async fn get_playlist_content(
578 &self,
579 playlist: QueryablePlaylist,
580 pagination: Pagination,
581 ) -> Result<(Vec<Song>, Pagination)> {
582 let mut ret = vec![];
583 if playlist.playlist_id.is_none() {
584 return Err("Playlist ID cannot be none".into());
585 }
586 let playlist_id = playlist.playlist_id.unwrap();
587 if let Some(api_client) = self.get_api_client().await.as_ref() {
588 let playlist_id = playlist_id
589 .strip_prefix("spotify-playlist:")
590 .unwrap_or(&playlist_id);
591 let items = api_client
592 .api_client
593 .playlist_items_manual(
594 PlaylistId::from_id_or_uri(playlist_id).unwrap(),
595 None,
596 None,
597 Some(pagination.limit),
598 Some(pagination.offset),
599 )
600 .await;
601
602 if let Ok(items) = items {
603 for i in items.items {
604 if i.is_local {
605 continue;
606 }
607
608 match i.track.unwrap() {
609 rspotify::model::PlayableItem::Track(t) => {
610 ret.push(self.parse_playlist_item(t));
611 }
612 rspotify::model::PlayableItem::Episode(_) => {
613 continue;
614 }
615 }
616 }
617 }
618 return Ok((ret, pagination.next_page()));
619 }
620 Err("API client not initialized".into())
621 }
622
623 #[tracing::instrument(level = "debug", skip(self))]
624 async fn get_playback_url(&self, _: Song, _: String) -> Result<String> {

Callers

nothing calls this directly

Calls 3

parse_playlist_itemMethod · 0.80
next_pageMethod · 0.80
get_api_clientMethod · 0.45

Tested by

no test coverage detected