(
    session_key: str,
    query: str,
    key: Optional[int],
    playlist: bool,
    platform: str,
    archive: bool = True,
    manually_requested: bool = True,
)
return True, message, queue_key
Performs the actual requesting of the music, not an endpoint.
    Enqueues the requested song or playlist into the queue, using appropriate providers.
    Returns a 3-tuple: successful, message, queue_key
Performs the actual requesting of the music, not an endpoint.
    Enqueues the requested song or playlist into the queue, using appropriate providers.
    Returns a 3-tuple: successful, message, queue_key
Performs the actual requesting of the music not an endpoint . Enqueues the requested song or playlist into the queue using appropriate providers . Returns a 3 - tuple : successful message queue_key
def do_request_music(
    session_key: str,
    query: str,
    key: Optional[int],
    playlist: bool,
    platform: str,
    archive: bool = True,
    manually_requested: bool = True,
) -> Tuple[bool, str, Optional[int]]:
    """Performs the actual requesting of the music, not an endpoint.
    Enqueues the requested song or playlist into the queue, using appropriate providers.
    Returns a 3-tuple: successful, message, queue_key"""
    providers: List[MusicProvider] = []

    provider: MusicProvider
    music_provider_class: Union[Type[PlaylistProvider], Type[SongProvider]]
    local_provider_class: Type[MusicProvider]
    jamendo_provider_class: Type[MusicProvider]
    soundcloud_provider_class: Type[MusicProvider]
    spotify_provider_class: Type[MusicProvider]
    youtube_provider_class: Type[MusicProvider]

    if playlist:
        music_provider_class = PlaylistProvider
        local_provider_class = PlaylistProvider
        if storage.get("jamendo_enabled"):
            from core.musiq.jamendo import JamendoPlaylistProvider

            jamendo_provider_class = JamendoPlaylistProvider
        if storage.get("soundcloud_enabled"):
            from core.musiq.soundcloud import SoundcloudPlaylistProvider

            soundcloud_provider_class = SoundcloudPlaylistProvider
        if storage.get("spotify_enabled"):
            from core.musiq.spotify import SpotifyPlaylistProvider

            spotify_provider_class = SpotifyPlaylistProvider
        if storage.get("youtube_enabled"):
            from core.musiq.youtube import YoutubePlaylistProvider

            youtube_provider_class = YoutubePlaylistProvider
    else:
        music_provider_class = SongProvider
        local_provider_class = LocalSongProvider
        if storage.get("jamendo_enabled"):
            from core.musiq.jamendo import JamendoSongProvider

            jamendo_provider_class = JamendoSongProvider
        if storage.get("soundcloud_enabled"):
            from core.musiq.soundcloud import SoundcloudSongProvider

            soundcloud_provider_class = SoundcloudSongProvider
        if storage.get("spotify_enabled"):
            from core.musiq.spotify import SpotifySongProvider

            spotify_provider_class = SpotifySongProvider
        if storage.get("youtube_enabled"):
            from core.musiq.youtube import YoutubeSongProvider

            youtube_provider_class = YoutubeSongProvider

    if key is not None:
        # an archived entry was requested.
        # The key determines the Provider
        provider = music_provider_class.create(query, key)
        if provider is None:
            return False, "No provider found for requested key", None
        providers.append(provider)
    else:
        if platform == "local":
            # local music can only be searched explicitly
            providers.append(local_provider_class(query, key))
        if storage.get("soundcloud_enabled"):
            try:
                soundcloud_provider = soundcloud_provider_class(query, key)
                if platform == "soundcloud":
                    providers.insert(0, soundcloud_provider)
                else:
                    providers.append(soundcloud_provider)
            except WrongUrlError:
                pass
        if storage.get("spotify_enabled"):
            try:
                spotify_provider = spotify_provider_class(query, key)
                if platform == "spotify":
                    providers.insert(0, spotify_provider)
                else:
                    providers.append(spotify_provider)
            except WrongUrlError:
                pass
        if storage.get("jamendo_enabled"):
            try:
                jamendo_provider = jamendo_provider_class(query, key)
                if platform == "jamendo":
                    providers.insert(0, jamendo_provider)
                else:
                    providers.append(jamendo_provider)
            except WrongUrlError:
                pass
        if storage.get("youtube_enabled"):
            try:
                youtube_provider = youtube_provider_class(query, key)
                if platform == "youtube":
                    providers.insert(0, youtube_provider)
                else:
                    providers.append(youtube_provider)
            except WrongUrlError:
                pass

    if not providers:
        return False, "No backend configured to handle your request.", None

    fallback = False
    for i, provider in enumerate(providers):
        try:
            provider.request(
                session_key, archive=archive, manually_requested=manually_requested
            )
            # the current provider could provide the song, don't try the other ones
            break
        except ProviderError:
            # this provider cannot provide this song, use the next provider
            # if this was the last provider, show its error
            # in new music only mode, do not allow fallbacks
            if storage.get("new_music_only") or i == len(providers) - 1:
                return False, provider.error, None
            fallback = True
    message = provider.ok_message
    queue_key = None
    if not playlist:
        queued_song = cast(SongProvider, provider).queued_song
        if not queued_song:
            logging.error(
                "no placeholder was created for query '%s' and key '%s'", query, key
            )
            return False, "No placeholder was created", None
        queue_key = queued_song.id
    if fallback:
        message += " (used fallback)"
    return True, message, queue_key
def do_request_music ( session_key : str , query : str , key : Optional [ int ] , playlist : bool , platform : str , archive : bool = True , manually_requested : bool = True , ) -> Tuple [ bool , str , Optional [ int ] ] : providers : List [ MusicProvider ] = [ ] provider : MusicProvider music_provider_class : Union [ Type [ PlaylistProvider ] , Type [ SongProvider ] ] local_provider_class : Type [ MusicProvider ] jamendo_provider_class : Type [ MusicProvider ] soundcloud_provider_class : Type [ MusicProvider ] spotify_provider_class : Type [ MusicProvider ] youtube_provider_class : Type [ MusicProvider ] if playlist : music_provider_class = PlaylistProvider local_provider_class = PlaylistProvider if storage . get ( "jamendo_enabled" ) : from core . musiq . jamendo import JamendoPlaylistProvider jamendo_provider_class = JamendoPlaylistProvider if storage . get ( "soundcloud_enabled" ) : from core . musiq . soundcloud import SoundcloudPlaylistProvider soundcloud_provider_class = SoundcloudPlaylistProvider if storage . get ( "spotify_enabled" ) : from core . musiq . spotify import SpotifyPlaylistProvider spotify_provider_class = SpotifyPlaylistProvider if storage . get ( "youtube_enabled" ) : from core . musiq . youtube import YoutubePlaylistProvider youtube_provider_class = YoutubePlaylistProvider else : music_provider_class = SongProvider local_provider_class = LocalSongProvider if storage . get ( "jamendo_enabled" ) : from core . musiq . jamendo import JamendoSongProvider jamendo_provider_class = JamendoSongProvider if storage . get ( "soundcloud_enabled" ) : from core . musiq . soundcloud import SoundcloudSongProvider soundcloud_provider_class = SoundcloudSongProvider if storage . get ( "spotify_enabled" ) : from core . musiq . spotify import SpotifySongProvider spotify_provider_class = SpotifySongProvider if storage . get ( "youtube_enabled" ) : from core . musiq . youtube import YoutubeSongProvider youtube_provider_class = YoutubeSongProvider if key is not None : # an archived entry was requested. # The key determines the Provider provider = music_provider_class . create ( query , key ) if provider is None : return False , "No provider found for requested key" , None providers . append ( provider ) else : if platform == "local" : # local music can only be searched explicitly providers . append ( local_provider_class ( query , key ) ) if storage . get ( "soundcloud_enabled" ) : try : soundcloud_provider = soundcloud_provider_class ( query , key ) if platform == "soundcloud" : providers . insert ( 0 , soundcloud_provider ) else : providers . append ( soundcloud_provider ) except WrongUrlError : pass if storage . get ( "spotify_enabled" ) : try : spotify_provider = spotify_provider_class ( query , key ) if platform == "spotify" : providers . insert ( 0 , spotify_provider ) else : providers . append ( spotify_provider ) except WrongUrlError : pass if storage . get ( "jamendo_enabled" ) : try : jamendo_provider = jamendo_provider_class ( query , key ) if platform == "jamendo" : providers . insert ( 0 , jamendo_provider ) else : providers . append ( jamendo_provider ) except WrongUrlError : pass if storage . get ( "youtube_enabled" ) : try : youtube_provider = youtube_provider_class ( query , key ) if platform == "youtube" : providers . insert ( 0 , youtube_provider ) else : providers . append ( youtube_provider ) except WrongUrlError : pass if not providers : return False , "No backend configured to handle your request." , None fallback = False for i , provider in enumerate ( providers ) : try : provider . request ( session_key , archive = archive , manually_requested = manually_requested ) # the current provider could provide the song, don't try the other ones break except ProviderError : # this provider cannot provide this song, use the next provider # if this was the last provider, show its error # in new music only mode, do not allow fallbacks if storage . get ( "new_music_only" ) or i == len ( providers ) - 1 : return False , provider . error , None fallback = True message = provider . ok_message queue_key = None if not playlist : queued_song = cast ( SongProvider , provider ) . queued_song if not queued_song : logging . error ( "no placeholder was created for query '%s' and key '%s'" , query , key ) return False , "No placeholder was created" , None queue_key = queued_song . id if fallback : message += " (used fallback)" return True , message , queue_key