Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Jukebox functionality is broken #165

Open
in1tiate opened this issue Mar 12, 2021 · 1 comment
Open

Jukebox functionality is broken #165

in1tiate opened this issue Mar 12, 2021 · 1 comment

Comments

@in1tiate
Copy link
Member

When an area is in jukebox mode, playing a song is supposed to add it to the queue. This does not work, the server instead reports "You removed your song from the jukebox" even if the jukebox queue is empty. Newbie Hole has been unable to play music for who knows how long.

@caleb-mabry
Copy link
Contributor

The offending code is

        def add_jukebox_vote(self, client: ClientManager.Client, music_name: str, length: int = -1, showname: str = ''):
            """Cast a vote on the jukebox.
            Args:
                client (ClientManager.Client): Client that is requesting
                music_name (str): track name
                length (int, optional): length of track. Defaults to -1.
                showname (str, optional): showname of voter. Defaults to ''.
            """

            if not self.jukebox:
                return
            if length <= 0:
                self.remove_jukebox_vote(client, False)
            else:
                self.remove_jukebox_vote(client, True)
                self.jukebox_votes.append(
                    self.JukeboxVote(client, music_name, length, showname))
                client.send_ooc('Your song was added to the jukebox.')
                if len(self.jukebox_votes) == 1:
                    self.start_jukebox()

Now, I'm not quite sure what the -1 is used for; however, there's some kind of trap happening here. The parameter length is generated through:

    def get_song_data(self, music_list, music):
        """
        Get information about a track, if exists.
        :param music_list: music list to search
        :param music: track name
        :returns: tuple (name, length or -1)
        :raises: ServerError if track not found
        """
        for item in music_list:
            if 'category' not in item: #skip settings n stuff
                continue
            if item['category'] == music:
                return item['category'], -1
            for song in item['songs']:
                if song['name'] == music:
                    try:
                        return song['name'], song['length']
                    except KeyError:
                        return song['name'], -1

It looks like the config defaults to -1.

If your music.yaml doesn't have the length attribute as something other than -1, it won't allow you to play it on the Jukebox.
I brought this up in the development channel in the Discord and I'll wait to do something until I get feedback there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants