def songPath(song):
    song = db.getSong(song)
    return os.path.join(song_dir, song.name + '.mp3')
def songOptionsWindow(song):
    song = db.getSong(song)
    title = song.name + ' options'

    def optionsContent():
        def press(button):
            if button == 'play now':
                media.forcePlay(song)
            elif button == 'add to queue':
                media.queue(song)
            elif button == 'edit tags':
                # new window for editing tags
                def body1():
                    allTags = db.getAllTags()
                    songTags = song.tags
                    boolDict = {}
                    for tag in allTags:
                        if tag in songTags:
                            boolDict[tag.name] = True
                        else:
                            boolDict[tag.name] = False
                    app.properties('song tag selection', value=boolDict)

                    def editTagPress(button):
                        if button == 'submit':
                            result = app.getProperties('song tag selection')
                            newTags = []
                            for tag in result:
                                if result[tag] is True:
                                    newTags.append(db.getTag(tag))
                            db.setSongTags(song, newTags)
                            app.destroySubWindow('edit tags window')

                    app.addButton('submit', editTagPress)

                temporaryWindow('edit tags window', body1)
            elif button == 'change bangericity':
                bangericity = 0.0
                while True:
                    bangericity = app.floatBox(
                        'bangericity input', 'enter a\
                     bangericity from 0 to 100')
                    if bangericity is None:
                        # user cancelled
                        break
                    # validate bangericity
                    if 0 <= bangericity and bangericity <= 100:
                        break
                    app.errorBox(
                        'invalid bangericity box', 'Error: bangericity\
                     must be between 0 and 100')
                if bangericity is not None:
                    db.changeBangericity(song, bangericity)
                    updateSongTable()
            elif button == 'remove from library':
                confirmation = app.yesNoBox(
                    'remove song?', 'Are you sure you\
                 want to remove this song?')
                if confirmation is True:
                    db.removeSong(song)
                    updateSongTable()
                    app.destroySubWindow(title)

        app.addButtons([
            'play now', 'add to queue', 'edit tags', 'change bangericity',
            'remove from library'
        ], press)

    temporaryWindow(title, optionsContent)
def queue(song):
    song = db.getSong(song)
    songQueue.append(song)
    if len(songQueue) == 1:
        realQueue(song)