(url: Optional[str] = None)
Checks whether to add a song by autoplay and does so if necessary.
    :param url: if given, this url is used to find the next autoplayed song.
    Otherwise, the current song is used.
Checks whether to add a song by autoplay and does so if necessary.
    :param url: if given, this url is used to find the next autoplayed song.
    Otherwise, the current song is used.
Checks whether to add a song by autoplay and does so if necessary . : param url : if given this url is used to find the next autoplayed song . Otherwise the current song is used .
def handle_autoplay(url: Optional[str] = None) -> None:
    """Checks whether to add a song by autoplay and does so if necessary.
    :param url: if given, this url is used to find the next autoplayed song.
    Otherwise, the current song is used."""
    if storage.get("autoplay") and models.QueuedSong.objects.count() == 0:
        if url is None:
            # if no url was specified, use the one of the current song
            try:
                current_song = models.CurrentSong.objects.get()
                url = current_song.external_url
            except (
                models.CurrentSong.DoesNotExist,
                models.CurrentSong.MultipleObjectsReturned,
            ):
                return

        from core.musiq.song_provider import SongProvider

        provider = SongProvider.create(external_url=url)
        try:
            suggestion = provider.get_suggestion()
            # The player loop is not restarted after error automatically.
            # As this function can raise several exceptions (it might do networking)
            # we catch every exception to make sure the loop keeps running
        except Exception as e:  # pylint: disable=broad-except
            logging.exception("error during suggestions for %s: %s", url, e)
        else:
            musiq.do_request_music(
                "",
                suggestion,
                None,
                False,
                provider.type,
                archive=False,
                manually_requested=False,
            )
def handle_autoplay ( url : Optional [ str ] = None ) -> None : if storage . get ( "autoplay" ) and models . QueuedSong . objects . count ( ) == 0 : if url is None : # if no url was specified, use the one of the current song try : current_song = models . CurrentSong . objects . get ( ) url = current_song . external_url except ( models . CurrentSong . DoesNotExist , models . CurrentSong . MultipleObjectsReturned , ) : return from core . musiq . song_provider import SongProvider provider = SongProvider . create ( external_url = url ) try : suggestion = provider . get_suggestion ( ) # The player loop is not restarted after error automatically. # As this function can raise several exceptions (it might do networking) # we catch every exception to make sure the loop keeps running except Exception as e : # pylint: disable=broad-except logging . exception ( "error during suggestions for %s: %s" , url , e ) else : musiq . do_request_music ( "" , suggestion , None , False , provider . type , archive = False , manually_requested = False , )