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

Method search

src-tauri/src/providers/spotify.rs:629–683  ·  view source on GitHub ↗
(&self, term: String)

Source from the content-addressed store, hash-verified

627
628 #[tracing::instrument(level = "debug", skip(self, term))]
629 async fn search(&self, term: String) -> Result<SearchResult> {
630 let mut ret = SearchResult {
631 songs: vec![],
632 albums: vec![],
633 artists: vec![],
634 playlists: vec![],
635 ..Default::default()
636 };
637
638 if let Some(api_client) = self.get_api_client().await.as_ref() {
639 search_and_parse_all!(
640 api_client.api_client,
641 &term,
642 [
643 (
644 SearchType::Track,
645 rspotify::model::SearchResult::Tracks,
646 |item, vec: &mut Vec<Song>| vec.push(self.parse_playlist_item(item)),
647 ret.songs
648 ),
649 (
650 SearchType::Playlist,
651 rspotify::model::SearchResult::Playlists,
652 |item, vec: &mut Vec<QueryablePlaylist>| vec
653 .push(self.parse_playlist(item)),
654 ret.playlists
655 ),
656 (
657 SearchType::Artist,
658 rspotify::model::SearchResult::Artists,
659 |item: FullArtist, vec: &mut Vec<QueryableArtist>| vec.push(
660 Self::parse_artists(
661 SimplifiedArtist {
662 external_urls: item.external_urls,
663 href: Some(item.href),
664 id: Some(item.id),
665 name: item.name,
666 },
667 Some(item.images)
668 )
669 ),
670 ret.artists
671 ),
672 (
673 SearchType::Album,
674 rspotify::model::SearchResult::Albums,
675 |item, vec: &mut Vec<QueryableAlbum>| vec.push(Self::parse_album(item)),
676 ret.albums
677 )
678 ]
679 );
680 return Ok(ret);
681 }
682 Err("API client not initialized".into())
683 }
684
685 #[tracing::instrument(level = "debug", skip(self, url))]
686 async fn match_url(&self, url: String) -> Result<bool> {

Callers 2

get_album_contentMethod · 0.45
get_artist_contentMethod · 0.45

Calls 1

get_api_clientMethod · 0.45

Tested by

no test coverage detected