Exemplo n.º 1
0
def addSong():
    path = app.openBox('select a song to add', fileTypes=[('Audio', '*.mp3')])
    if path:
        name = ntpath.basename(path)
        app.infoBox('test', path + '\n' + name)
        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:
            try:
                db.addSong(path, name, bangericity)
            except FileExistsError:
                app.errorBox(
                    'duplicate song error box',
                    'Error: A song with this name already exists. The song will\
                     not be added.')
            updateSongTable()
Exemplo n.º 2
0
 def submit(button):
     if button == 'submit':
         # bangericity
         minBangericity = float(app.getEntry('minimum bangericity'))
         maxBangericity = float(app.getEntry('maximum bangericity'))
         # validate bangericities
         if not minBangericity < maxBangericity:
             app.errorBox(
                 'invalid bangericities', 'minimum bangericity\
              must be less than maximum bangericity')
             return None
         # include logic
         andLogic = app.getCheckBox('use AND logic on includes')
         # tags
         newIncludedTags = []
         newExcludedTags = []
         includedTagDict = app.getProperties('included tags')
         excludedTagDict = app.getProperties('excluded tags')
         ##### left off here investigating bug where you can't edit then add
         # also label entries
         # figure out what the new tags will be
         for tag in includedTagDict:
             if includedTagDict[tag] is True:
                 newIncludedTags.append(db.getTag(tag))
             if excludedTagDict[tag] is True:
                 newExcludedTags.append(db.getTag(tag))
         # name
         if playlist is None:
             name = app.getEntry('name')
             # validate name
             if name == '':
                 app.errorBox('invalid name',
                              'playlist must have a name')
                 return None
             existingPlaylistNames = [
                 playlist.name for playlist in db.getAllPlaylists()
             ]
             if name in existingPlaylistNames:
                 app.errorBox(
                     'duplicate name', 'a playlist with that\
                  name already exists')
                 return None
             # create playlist
             db.addPlaylist(name, newIncludedTags, newExcludedTags,
                            minBangericity, maxBangericity, andLogic)
             showPlaylistSongs(name)
             updatePlaylistTable()
             app.destroySubWindow(title)
         else:
             # edit playlist
             playlist.includedTags = newIncludedTags
             playlist.excludedTags = newExcludedTags
             playlist.minBangericity = minBangericity
             playlist.maxBangericity = maxBangericity
             playlist.andLogic = andLogic
             showPlaylistSongs(playlist)
             updatePlaylistTable()
             app.destroySubWindow(title)
Exemplo n.º 3
0
 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')
Exemplo n.º 4
0
        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)
Exemplo n.º 5
0
 def press(button):
     if button == 'view songs':
         songs = tag.songs
         songNames = [song.name for song in songs]
         app.infoBox('songs', '\n'.join(songNames))
     elif button == 'remove':
         if app.yesNoBox('confirmation',
                         'are you sure you want to remove this tag?'):
             db.removeTag(tag)
             updateTagTable()
             app.destroySubWindow(title)
Exemplo n.º 6
0
def playlistOptionsWindow(playlist):
    playlist = db.getPlaylist(playlist)
    title = playlist.name + ' playlist options window'

    def optionsContent():
        def press(button):
            if button == 'play now':
                media.forcePlayPlaylist(playlist)
            elif button == 'add to queue':
                media.queuePlaylist(playlist)
            elif button == 'view songs':
                showPlaylistSongs(playlist)
            elif button == 'edit':
                playlistForm(playlist)
                # remember to edit bangericity and includeLogic too
            elif button == 'remove':
                confirmation = app.yesNoBox(
                    'remove playlist?',
                    'Are you sure you want to remove this playlist?')
                if confirmation is True:
                    db.removePlaylist(playlist)
                    updatePlaylistTable()
                    app.destroySubWindow(title)

        app.addButtons(
            ['play now', 'add to queue', 'view songs', 'edit', 'remove'],
            press)
        # maybe don't do make into a tag

    temporaryWindow(title, optionsContent)
Exemplo n.º 7
0
 def press(button):
     if button == 'play now':
         media.forcePlayPlaylist(playlist)
     elif button == 'add to queue':
         media.queuePlaylist(playlist)
     elif button == 'view songs':
         showPlaylistSongs(playlist)
     elif button == 'edit':
         playlistForm(playlist)
         # remember to edit bangericity and includeLogic too
     elif button == 'remove':
         confirmation = app.yesNoBox(
             'remove playlist?',
             'Are you sure you want to remove this playlist?')
         if confirmation is True:
             db.removePlaylist(playlist)
             updatePlaylistTable()
             app.destroySubWindow(title)
def forcePlayPlaylist(playlist):
    playlist = db.getPlaylist(playlist)
    if len(songQueue) == 0:
        queuePlaylist(playlist)
    else:
        songs = pl.buildPlaylist(playlist)
        for song in songs:
            songQueue.insert(songIndex + 1, song)
            # order doesn't matter
        nextSong()
Exemplo n.º 9
0
def tagOptionsWindow(tag):
    tag = db.getTag(tag)
    title = tag.name + ' tag options window'

    def press(button):
        if button == 'view songs':
            songs = tag.songs
            songNames = [song.name for song in songs]
            app.infoBox('songs', '\n'.join(songNames))
        elif button == 'remove':
            if app.yesNoBox('confirmation',
                            'are you sure you want to remove this tag?'):
                db.removeTag(tag)
                updateTagTable()
                app.destroySubWindow(title)

    def optionsContent():
        app.addButtons(['view songs', 'remove'], press)

    temporaryWindow(title, optionsContent)
Exemplo n.º 10
0
                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)
Exemplo n.º 11
0
def addTag():
    name = app.stringBox('create a tag', 'tag name:')
    db.addTag(name)
    updateTagTable()
Exemplo n.º 12
0
def showPlaylistSongs(playlist):
    playlist = db.getPlaylist(playlist)
    songs = list(pl.buildPlaylist(playlist))
    songNames = [song.name for song in songs]
    app.infoBox(playlist.name + ' songs', '\n'.join(songNames))
def queuePlaylist(playlist):
    playlist = db.getPlaylist(playlist)
    songs = pl.buildPlaylist(playlist)
    for song in songs:
        queue(song)
        # source = load(songPath(song))


def initialize():
    t = threading.Thread(target=loop)
    t.start()


if __name__ == '__main__':
    queuePlaylist(db.getPlaylist('test'))
    # queue(pl.buildPlaylist(db.getPlaylist('test')).pop())
    play()
    player.volume = .3
    # songIndex = len(songQueue) - 2
    # nextSong()
    seekRatio(.97)
    initialize()
# play = player.play
# pause = player.pause
# seek = player.seek
# next = player.next_source()

# ### testing eos ###
# queuePlaylist(db.getPlaylist('test'))
# player.play()
Exemplo n.º 14
0
def updateTagTable():
    tags = db.getAllTags()
    tableArr = [[tag.name] for tag in tags]
    tableArr.sort()
    app.replaceAllTableRows('tag table', tableArr)
Exemplo n.º 15
0
    global updateSlider
    while threading.main_thread().is_alive():
        updateSlider()
        updateSongLabel()
        time.sleep(1)


def addTag():
    name = app.stringBox('create a tag', 'tag name:')
    db.addTag(name)
    updateTagTable()


with app.tabbedFrame('tabs'):
    with app.tab('songs'):
        songs = db.getAllSongs()
        tableArr = [[song.name, song.bangericity] for song in songs]
        tableArr.sort()
        app.addTable('song table', [['Name', 'Bangericity']] + tableArr,
                     colspan=3,
                     addRow=addSong,
                     showMenu=True,
                     action=songAction)
    with app.tab('playlists'):
        playlists = db.getAllPlaylists()
        tableArr = [[playlist.name] for playlist in playlists]
        tableArr.sort()
        app.addTable('playlist table', [['Name']] + tableArr,
                     colspan=3,
                     showMenu=True,
                     action=playlistAction,
def queuePlaylist(playlist):
    playlist = db.getPlaylist(playlist)
    songs = pl.buildPlaylist(playlist)
    for song in songs:
        queue(song)
def songPath(song):
    song = db.getSong(song)
    return os.path.join(song_dir, song.name + '.mp3')
Exemplo n.º 18
0
def updateSongTable():
    songs = db.getAllSongs()
    tableArr = [[song.name, song.bangericity] for song in songs]
    tableArr.sort()
    app.replaceAllTableRows('song table', tableArr)
def queue(song):
    song = db.getSong(song)
    songQueue.append(song)
    if len(songQueue) == 1:
        realQueue(song)
Exemplo n.º 20
0
def updatePlaylistTable():
    playlists = db.getAllPlaylists()
    tableArr = [[playlist.name] for playlist in playlists]
    tableArr.sort()
    app.replaceAllTableRows('playlist table', tableArr)
def queuePlaylist(playlist):
    playlist = db.getPlaylist(playlist)
    playlist = list(playlist)
    for song in pl.buildPlaylist(playlist):
        queue(song)
Exemplo n.º 22
0
    def formContents():
        allTags = db.getAllTags()
        includedTags = []
        excludedTags = []
        if playlist is not None:
            includedTags = playlist.includedTags
            excludedTags = playlist.excludedTags
        includedTagDict = {}
        excludedTagDict = {}
        # both going to be {tagname => boolean, ...}
        for tag in allTags:
            includedTagDict[tag.name] = tag in includedTags
            excludedTagDict[tag.name] = tag in excludedTags
        if playlist is None:
            app.addLabel('playlist name:')
            app.entry('name')

        app.properties('included tags', includedTagDict)
        app.properties('excluded tags', excludedTagDict)
        app.addLabel('minimum and maximum bangericity:')
        app.addNumericEntry('minimum bangericity')
        app.addNumericEntry('maximum bangericity')
        min = 0
        max = 100
        if playlist is not None:
            min = playlist.minBangericity
            max = playlist.maxBangericity
        app.setEntry('minimum bangericity', min)
        app.setEntry('maximum bangericity', max)

        app.addCheckBox('use AND logic on includes')
        ticked = True
        if playlist is not None:
            ticked = playlist.andLogic
        app.setCheckBox('use AND logic on includes', ticked=ticked)

        def submit(button):
            if button == 'submit':
                # bangericity
                minBangericity = float(app.getEntry('minimum bangericity'))
                maxBangericity = float(app.getEntry('maximum bangericity'))
                # validate bangericities
                if not minBangericity < maxBangericity:
                    app.errorBox(
                        'invalid bangericities', 'minimum bangericity\
                     must be less than maximum bangericity')
                    return None
                # include logic
                andLogic = app.getCheckBox('use AND logic on includes')
                # tags
                newIncludedTags = []
                newExcludedTags = []
                includedTagDict = app.getProperties('included tags')
                excludedTagDict = app.getProperties('excluded tags')
                ##### left off here investigating bug where you can't edit then add
                # also label entries
                # figure out what the new tags will be
                for tag in includedTagDict:
                    if includedTagDict[tag] is True:
                        newIncludedTags.append(db.getTag(tag))
                    if excludedTagDict[tag] is True:
                        newExcludedTags.append(db.getTag(tag))
                # name
                if playlist is None:
                    name = app.getEntry('name')
                    # validate name
                    if name == '':
                        app.errorBox('invalid name',
                                     'playlist must have a name')
                        return None
                    existingPlaylistNames = [
                        playlist.name for playlist in db.getAllPlaylists()
                    ]
                    if name in existingPlaylistNames:
                        app.errorBox(
                            'duplicate name', 'a playlist with that\
                         name already exists')
                        return None
                    # create playlist
                    db.addPlaylist(name, newIncludedTags, newExcludedTags,
                                   minBangericity, maxBangericity, andLogic)
                    showPlaylistSongs(name)
                    updatePlaylistTable()
                    app.destroySubWindow(title)
                else:
                    # edit playlist
                    playlist.includedTags = newIncludedTags
                    playlist.excludedTags = newExcludedTags
                    playlist.minBangericity = minBangericity
                    playlist.maxBangericity = maxBangericity
                    playlist.andLogic = andLogic
                    showPlaylistSongs(playlist)
                    updatePlaylistTable()
                    app.destroySubWindow(title)

        app.addButton('submit', submit)
Exemplo n.º 23
0
songDir = 'D:\\OneDrive\\Music\\7-7-18 additions'
songNames = os.listdir(songDir)


def songPath(name):
    return os.path.join(songDir, name)


songPaths = [songPath(name) for name in songNames]
i = 0
for songPath in songPaths:
    songName = ntpath.basename(songPath)
    bangericity = bangericities[i]
    i += 1
    db.addSong(songPath, songName, bangericity)
'''
<Song(name="Dear You - Yuduki", bangericity="85.0")>,
 <Song(name="Sendan Life - Hanamori Yumiri", bangericity="87.0")>,
 <Song(name="Asymmetry - Reol", bangericity="92.0")>,
 <Song(name="Imaginary Like the Justice - GUMI", bangericity="90.0")>,
 <Song(name="Bad Apple!!", bangericity="88.0")>,
 <Song(name="Virtual Paradise - AK x LYNX ft. Veela", bangericity="89.0")>,
 <Song(name="Wareta Ringo - Shinsekai Yori ED1", bangericity="88.0")>,
 <Song(name="Koi Wa Chaos No Shimobe Nari full - Haiyore Nyaruko OP", bangericity="90.0")>,
 <Song(name="ひとり full - Darling in the FranXX ED 4", bangericity="90.0")>,
 <Song(name="A Cruel Angel's Thesis - Neon Genesis Evangelion OP", bangericity="85.0")>,
 <Song(name="Parallel Line - Sayuri", bangericity="87.0")>,
 <Song(name="Noushou Sakuretsu Girl - Hatsune Miku", bangericity="90.0")>,
 <Song(name="Sorewa Chiisana Hikari No Youna full - Erased ED", bangericity="90.0")>,
 <Song(name="Hitorigoto - Eromanga Sensei OP1", bangericity="90.0")>,