(
        query: Optional[str] = None, key: Optional[int] = None
    )
return provider
Factory method to create a playlist provider.
        Both query and key need to be specified.
        Detects the type of provider needed and returns one of corresponding type.
Factory method to create a playlist provider.
        Both query and key need to be specified.
        Detects the type of provider needed and returns one of corresponding type.
Factory method to create a playlist provider . Both query and key need to be specified . Detects the type of provider needed and returns one of corresponding type .
def create(
        query: Optional[str] = None, key: Optional[int] = None
    ) -> "PlaylistProvider":
        """Factory method to create a playlist provider.
        Both query and key need to be specified.
        Detects the type of provider needed and returns one of corresponding type."""
        if query is None:
            logging.error(
                "archived playlist requested but no query given (key %s)", key
            )
            raise ValueError
        if key is None:
            logging.error("archived playlist requested but no key given")
            raise ValueError
        try:
            archived_playlist = ArchivedPlaylist.objects.get(id=key)
        except ArchivedPlaylist.DoesNotExist:
            logging.error("archived song requested for nonexistent key %s", key)
            raise ValueError

        playlist_type = song_utils.determine_playlist_type(archived_playlist)
        provider_class: Optional[Type[PlaylistProvider]] = None
        if playlist_type == "local":
            from core.musiq.localdrive import LocalPlaylistProvider

            provider_class = LocalPlaylistProvider
        elif storage.get("youtube_enabled") and playlist_type == "youtube":
            from core.musiq.youtube import YoutubePlaylistProvider

            provider_class = YoutubePlaylistProvider
        elif storage.get("spotify_enabled") and playlist_type == "spotify":
            from core.musiq.spotify import SpotifyPlaylistProvider

            provider_class = SpotifyPlaylistProvider
        elif storage.get("soundcloud_enabled") and playlist_type == "soundcloud":
            from core.musiq.soundcloud import SoundcloudPlaylistProvider

            provider_class = SoundcloudPlaylistProvider
        elif storage.get("jamendo_enabled") and playlist_type == "jamendo":
            from core.musiq.jamendo import JamendoPlaylistProvider

            provider_class = JamendoPlaylistProvider
        elif playlist_type == "playlog":
            # The playlist may contain various song types, but all of them will be archived.
            # We can use the local playlist provider to enqueue them.
            from core.musiq.localdrive import LocalPlaylistProvider

            provider_class = LocalPlaylistProvider
        if not provider_class:
            raise NotImplementedError(f"No provider for given playlist: {query}, {key}")
        provider = provider_class(query, key)
        return provider
def create ( query : Optional [ str ] = None , key : Optional [ int ] = None ) -> "PlaylistProvider" : if query is None : logging . error ( "archived playlist requested but no query given (key %s)" , key ) raise ValueError if key is None : logging . error ( "archived playlist requested but no key given" ) raise ValueError try : archived_playlist = ArchivedPlaylist . objects . get ( id = key ) except ArchivedPlaylist . DoesNotExist : logging . error ( "archived song requested for nonexistent key %s" , key ) raise ValueError playlist_type = song_utils . determine_playlist_type ( archived_playlist ) provider_class : Optional [ Type [ PlaylistProvider ] ] = None if playlist_type == "local" : from core . musiq . localdrive import LocalPlaylistProvider provider_class = LocalPlaylistProvider elif storage . get ( "youtube_enabled" ) and playlist_type == "youtube" : from core . musiq . youtube import YoutubePlaylistProvider provider_class = YoutubePlaylistProvider elif storage . get ( "spotify_enabled" ) and playlist_type == "spotify" : from core . musiq . spotify import SpotifyPlaylistProvider provider_class = SpotifyPlaylistProvider elif storage . get ( "soundcloud_enabled" ) and playlist_type == "soundcloud" : from core . musiq . soundcloud import SoundcloudPlaylistProvider provider_class = SoundcloudPlaylistProvider elif storage . get ( "jamendo_enabled" ) and playlist_type == "jamendo" : from core . musiq . jamendo import JamendoPlaylistProvider provider_class = JamendoPlaylistProvider elif playlist_type == "playlog" : # The playlist may contain various song types, but all of them will be archived. # We can use the local playlist provider to enqueue them. from core . musiq . localdrive import LocalPlaylistProvider provider_class = LocalPlaylistProvider if not provider_class : raise NotImplementedError ( f"No provider for given playlist: {query}, {key}" ) provider = provider_class ( query , key ) return provider