예제 #1
0
def getplaylist():
    current_songs = songs()
    # Format of the songs is name, path, number of votes
    # Need to convert the number of votes into a play order
    current_songs.sort(current_songs, key=lambda song: len(song[2]), reverse=True)
    playlist = []
    order = 1
    for song in current_songs:
        playlist.append({'playorder':order, 'name':song[0], 'path':song[1]})
        order = order + 1
    return playlist
예제 #2
0
def cmd_play(*args):
    """Interrupts whatever is going on, and plays the requested song.

    :param args: [specified user, arguments for command]
    :type args: list

    :return: play song response
    :rtype: str
    """
    args = args[1]

    if len(args) == 0 or not args.isdigit():
        cm.update_state('play_now', -1)

        return 'Skipping straight ahead to the next show!'
    else:
        song = int(args)

        if song < 1 or song > len(cm.songs()):
            return 'Sorry, the song you requested ' + args + ' is out of range :('
        else:
            cm.update_state('play_now', song)

            return '"' + cm.songs()[song - 1][0] + '" coming right up!'
예제 #3
0
def cmd_vote(*args):
    """Casts a vote for the next song to be played

    :param args: [specified user, arguments for command]
    :type args: list

    :return: unknown command response
    :rtype: str
    """
    user = args[0]
    args = args[1]

    if args.isdigit():
        song_num = int(args)

        if user != 'Me' and 0 < song_num <= len(cm.songs()):
            song = cm.songs()[song_num - 1]
            song[2].add(user)
            logging.info('Song requested: ' + str(song))

            return 'Thank you for requesting "' + song[0] \
                   + '", we\'ll notify you when it starts!'
    else:
        return cm.sms()['unknown_command_response']
예제 #4
0
def cmd_list(*args):
    """Lists all the songs from the current playlist.

    :param args: Not used but left in for compatibility
    :type args: list

    :return: list of songs
    :rtype: list
    """
    songlist = ['Vote by texting the song #:\n']
    division = 0
    index = 1

    for song in cm.songs():
        songlist[division] += str(index) + ' - ' + song[0] + '\n'
        index += 1

        if (index - 1) % 4 == 0:
            division += 1
            songlist.append('')

    return songlist