(
        self, query: str, playlist: bool
    )
return unique_suggestions
Returns a list of suggested items for the given query.
        Returns playlists if :param playlist: is True, songs otherwise.
Returns a list of suggested items for the given query.
        Returns playlists if :param playlist: is True, songs otherwise.
Returns a list of suggested items for the given query . Returns playlists if : param playlist : is True songs otherwise .
def get_search_suggestions(
        self, query: str, playlist: bool
    ) -> List[Tuple[str, str]]:
        """Returns a list of suggested items for the given query.
        Returns playlists if :param playlist: is True, songs otherwise."""
        result = self.web_client.get(
            "search",
            params={
                "q": query,
                "limit": "20",
                "market": "from_token",
                "type": "playlist" if playlist else "track",
            },
        )

        if playlist:
            items = result["playlists"]["items"]
        else:
            items = result["tracks"]["items"]

        suggestions = []
        for item in items:
            external_url = item["external_urls"]["spotify"]
            title = item["name"]
            if playlist:
                displayname = title
            else:
                artist = item["artists"][0]["name"]
                # apply filter from the settings
                if song_utils.is_forbidden(artist) or song_utils.is_forbidden(title):
                    continue
                displayname = song_utils.displayname(artist, title)
            suggestions.append((displayname, external_url))

        # remove duplicates and filter by keywords
        chosen_displaynames = set()
        unique_suggestions = []
        for suggestion in suggestions:
            if suggestion[0] in chosen_displaynames:
                continue
            unique_suggestions.append(suggestion)
            chosen_displaynames.add(suggestion[0])
        return unique_suggestions
def get_search_suggestions ( self , query : str , playlist : bool ) -> List [ Tuple [ str , str ] ] : result = self . web_client . get ( "search" , params = { "q" : query , "limit" : "20" , "market" : "from_token" , "type" : "playlist" if playlist else "track" , } , ) if playlist : items = result [ "playlists" ] [ "items" ] else : items = result [ "tracks" ] [ "items" ] suggestions = [ ] for item in items : external_url = item [ "external_urls" ] [ "spotify" ] title = item [ "name" ] if playlist : displayname = title else : artist = item [ "artists" ] [ 0 ] [ "name" ] # apply filter from the settings if song_utils . is_forbidden ( artist ) or song_utils . is_forbidden ( title ) : continue displayname = song_utils . displayname ( artist , title ) suggestions . append ( ( displayname , external_url ) ) # remove duplicates and filter by keywords chosen_displaynames = set ( ) unique_suggestions = [ ] for suggestion in suggestions : if suggestion [ 0 ] in chosen_displaynames : continue unique_suggestions . append ( suggestion ) chosen_displaynames . add ( suggestion [ 0 ] ) return unique_suggestions