(self)
return True
Fetches metadata for this song's uri from Jamendo.
Fetches metadata for this song's uri from Jamendo.
Fetches metadata for this song s uri from Jamendo .
def gather_metadata(self) -> bool:
        """Fetches metadata for this song's uri from Jamendo."""
        if not self.id:
            results = self.web_client.get("tracks", {"search": self.query})["results"]

            # apply the filterlist from the settings
            for item in results:
                artist = item["artist_name"]
                title = item["name"]
                if song_utils.is_forbidden(artist) or song_utils.is_forbidden(title):
                    continue
                result = item
                break
            else:
                # all tracks got filtered
                return False
            self.id = result["id"]
        else:
            try:
                result = self.web_client.get("tracks", {"id": self.id})["results"][0]
            except (KeyError, IndexError):
                self.error = f"id {self.id} not found"
                return False
        self.metadata["artist"] = result["artist_name"]
        self.metadata["title"] = result["name"]
        self.metadata["duration"] = result["duration"]
        self.metadata["internal_url"] = self.get_internal_url()
        self.metadata["external_url"] = result["shareurl"]
        self.metadata["stream_url"] = result["audio"]
        self.metadata["cached"] = False
        return True
def gather_metadata ( self ) -> bool : if not self . id : results = self . web_client . get ( "tracks" , { "search" : self . query } ) [ "results" ] # apply the filterlist from the settings for item in results : artist = item [ "artist_name" ] title = item [ "name" ] if song_utils . is_forbidden ( artist ) or song_utils . is_forbidden ( title ) : continue result = item break else : # all tracks got filtered return False self . id = result [ "id" ] else : try : result = self . web_client . get ( "tracks" , { "id" : self . id } ) [ "results" ] [ 0 ] except ( KeyError , IndexError ) : self . error = f"id {self.id} not found" return False self . metadata [ "artist" ] = result [ "artist_name" ] self . metadata [ "title" ] = result [ "name" ] self . metadata [ "duration" ] = result [ "duration" ] self . metadata [ "internal_url" ] = self . get_internal_url ( ) self . metadata [ "external_url" ] = result [ "shareurl" ] self . metadata [ "stream_url" ] = result [ "audio" ] self . metadata [ "cached" ] = False return True