Esempio n. 1
0
def choice_c(moods, db):
    print "Choose a mood from the options below:"
    for mood in moods:
        print mood

    chosenMood = raw_input('Enter choice: ')
    while chosenMood not in moods:
        chosenMood = raw_input('Please enter one of the options above: ')

    print "Max length of your playlist: "
    x = True
    while x:
        maxlen = raw_input("> ")
        try:
            maxlen = int(maxlen)
            x = False
        except:
            print "Cannot be converted to integer, try again."
    # make playlist
    p = Playlist(db, moods)
    p.add_mood(chosenMood)
    p.generate_list_mood()

    plist = p.get_list(maxlen)
    for s in plist:
        print str(s)

    print "Save as .m3u? y/n"
    save = raw_input("> ")
    if save == "y":
        m3u = open("playlist.m3u", "wb")
        for song in plist:
            print >> m3u, song
Esempio n. 2
0
def choice_c(moods, db):
    print "Choose a mood from the options below:"
    for mood in moods:
        print mood

    chosenMood = raw_input('Enter choice: ')
    while chosenMood not in moods:
        chosenMood = raw_input('Please enter one of the options above: ')

    print "Max length of your playlist: "
    x = True
    while x:
        maxlen = raw_input("> ")
        try:
            maxlen = int(maxlen)
            x = False
        except:
            print "Cannot be converted to integer, try again."
    # make playlist
    p = Playlist(db, moods)
    p.add_mood(chosenMood)
    p.generate_list_mood()
        
    plist = p.get_list(maxlen)
    for s in plist:
        print str(s)

    print "Save as .m3u? y/n"
    save = raw_input("> ")
    if save == "y":
        m3u = open("playlist.m3u","wb")
        for song in plist:
            print>>m3u, song
Esempio n. 3
0
def run_sandbox():
    print "****************\nWelcome to the sandboxed MoodMusic\n****************"
    print "\nYou are using our DB of thousands of songs so that you can test our machine learning algorithms\n"

    #Makes the DB_Helper use Tom's Sandbox DB
    db = DB_Helper()

    print "Choose a mood from the options below:"
    moods = DB_Helper().all_moods()
    for mood in moods:
        print mood

    chosenMood = raw_input('Enter choice: ')
    while chosenMood not in moods:
        chosenMood = raw_input('Please enter one of the options above: ')

    print "Max length of your playlist: "
    x = True
    while x:
        maxlen = raw_input("> ")
        try:
            maxlen = int(maxlen)
            x = False
        except:
            print "Cannot be converted to integer, try again."
    # make playlist
    p = Playlist(db, moods)
    p.add_mood(chosenMood)
    p.generate_list_mood()

    plist = p.get_list(maxlen)
    for s in plist:
        print str(s)

    print "Save as .m3u? y/n"
    save = raw_input("> ")
    if save == "y":
        m3u = open("playlist.m3u", "wb")
        for song in plist:
            print >> m3u, song
Esempio n. 4
0
def run_sandbox():
    print "****************\nWelcome to the sandboxed MoodMusic\n****************"
    print "\nYou are using our DB of thousands of songs so that you can test our machine learning algorithms\n"

    #Makes the DB_Helper use Tom's Sandbox DB
    db = DB_Helper()

    print "Choose a mood from the options below:"
    moods = DB_Helper().all_moods()
    for mood in moods:
        print mood

    chosenMood = raw_input('Enter choice: ')
    while chosenMood not in moods:
        chosenMood = raw_input('Please enter one of the options above: ')

    print "Max length of your playlist: "
    x = True
    while x:
        maxlen = raw_input("> ")
        try:
            maxlen = int(maxlen)
            x = False
        except:
            print "Cannot be converted to integer, try again."
    # make playlist
    p = Playlist(db, moods)
    p.add_mood(chosenMood)
    p.generate_list_mood()
    
    plist = p.get_list(maxlen)
    for s in plist:
        print str(s)

    print "Save as .m3u? y/n"
    save = raw_input("> ")
    if save == "y":
        m3u = open("playlist.m3u","wb")
        for song in plist:
            print>>m3u, song
Esempio n. 5
0
def run(runBackgroundImporter=True):
    print "****************\nWelcome to MoodMusic!\n****************\n"

    atexit.register(FetchData.removePID)

    if not os.path.isfile('config.pkl'):
        __make_config_file()

    __check_db()

    daemon = None
    if runBackgroundImporter:
        #Starts background daemon
        daemon = FetchData()
        daemon.start()

    #Start CLI
    application = CLI(daemon)

    #Init Database Chatter
    db = DB_Helper()

    print "\nPlease choose an option:\n"
    print "a -> Enter song to play"

    moods = db.all_moods()
    if len(moods) > 0:
        print "b -> Enter mood to play"
        print "c -> Generate a playlist from mood (without playing)"
    print "d -> Add song to mood (without playing)"

    choice = raw_input('\nEnter your choice: ')
    while (choice not in ['a', 'b', 'c', 'd']):
        choice = raw_input('Please enter an option above: ')

    if choice == 'a':

        print "\nHow would you like to select a song?\n"
        print "l -> Search your Library"
        print "f -> Enter a filepath"

        selection = raw_input('> ')
        while (selection not in ['l', 'f']):
            selection = raw_input('Please enter an option above: ')
        if selection == 'l':
            songFile = song_search(
                Config().get_attr('MUSIC_LIBRARY_FILE_PATH'))
        elif selection == 'f':
            #User enters a filepath
            songFile = raw_input('Enter song file: ')

        if songFile != None:
            chosenSong = Song.song_from_filepath(songFile)
            application.play_song(chosenSong)

    elif choice == 'b':
        #User enters a mood
        print "Choose a mood from the options below:"
        for mood in moods:
            print mood

        chosenMood = raw_input('Enter choice: ')
        while chosenMood not in moods:
            chosenMood = raw_input('Please enter one of the options above: ')

        # make playlist
        p = Playlist(db, moods)
        p.add_mood(chosenMood)
        p.generate_list_mood()
        application.set_list(p)

        application.play_song()

    elif choice == 'c':
        choice_c(moods, db)
    elif choice == 'd':
        choice_d(moods, db)
Esempio n. 6
0
def run(runBackgroundImporter = True):    
    print "****************\nWelcome to MoodMusic!\n****************\n"

    atexit.register(FetchData.removePID)

    if not os.path.isfile('config.pkl'):
        __make_config_file()

    __check_db()

    daemon = None
    if runBackgroundImporter:
        #Starts background daemon
        daemon = FetchData()
        daemon.start()

    #Start CLI
    application = CLI(daemon)

    #Init Database Chatter
    db = DB_Helper()

    print "\nPlease choose an option:\n"
    print "a -> Enter song to play"

    moods = db.all_moods()
    if len(moods) > 0:
        print "b -> Enter mood to play"
        print "c -> Generate a playlist from mood (without playing)"
    print "d -> Add song to mood (without playing)"

    choice = raw_input('\nEnter your choice: ')
    while(choice not in ['a', 'b', 'c', 'd']):
        choice = raw_input('Please enter an option above: ')

    
    if choice == 'a':

        # User enters a filepath for a song to play
        print "\nHow would you like to select a song?\n"
        print "l -> Search your Library"
        print "f -> Enter a filepath"

        selection = raw_input('> ')
        while (selection not in ['l', 'f']):
            selection = raw_input('Please enter an option above: ')

        # searh the user library for a song and return the filepath
        if selection == 'l':
            songFile = song_search(Config().get_attr('MUSIC_LIBRARY_FILE_PATH'))
        elif selection == 'f':
            #User enters a filepath
            songFile = raw_input('Enter song file: ')

        # if a song was found, play it 
        if songFile != None:
            chosenSong = Song.song_from_filepath(songFile)
            application.play_song(chosenSong)
        
    elif choice == 'b':
        #User enters a mood to generate a playlist and play
        print "Choose a mood from the options below:"
        for mood in moods:
            print mood

        chosenMood = raw_input('Enter choice: ')
        while chosenMood not in moods:
            chosenMood = raw_input('Please enter one of the options above: ')

        # make playlist
        p = Playlist(db, moods)
        p.add_mood(chosenMood)
        p.generate_list_mood()
        application.set_list(p)

        application.play_song()

    elif choice == 'c':
        choice_c(moods, db)
    elif choice == 'd':
        choice_d(db)