def _to_list(self, songs): '''converts list of hashes to list of filepaths''' files = [] for x in songs: files.append(Song.song_from_filepath(self._db.hash_to_file(x))) # shuffle(files) self._list = files
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)
def convert_hash_to_song(self, has): ''' return a song object associated with the given hash ''' return Song.song_from_filepath(self._db.hash_to_file(has))
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)