Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    def search(self):
        """Searches recursive ultrastar songs"""
#        print (self.directory.name)
        for entry in os.walk(self.directory.name):
            root = entry[0]
            file_names = entry[2]
            for file_name in file_names:
                lower_file = file_name.lower()
                if lower_file == "desc.txt":
                    pass
                elif lower_file.endswith('.txt'):
                    reader = UltraStarFile(root, file_name)
                    song = Song(directory = Directory(root), reader=reader)
                    song.read(mode="headers")
#                    file_names = unicode_encode_list(file_names)
                    self.songs.append(song)
        self.browsable_items = self.get_entries(self.dir_pos)
Exemplo n.º 3
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)
Exemplo n.º 4
0
 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))
Exemplo 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':

        # 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)
Exemplo n.º 6
0
 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))