Exemplo n.º 1
0
 def make_choice(self):
     self.welcome()
     while True:
         choise = input("Enter command: ")
         if choise.split()[0] == "play" and choise.split()[1] == "from":
             current_crawler = MusicCrawler(choise.split()[2])
             current_playlist = MusicCrawler(
                 choise.split()[2]).generate_playlist()
             for song in current_playlist.songs:
                 self.playlist.songs.append(song)
             print(self.playlist)
             num_song = input(
                 "Enter the number of the song you want to play: ")
             print()
             song_to_play = current_crawler.get_raw_playlist()[int(num_song)
                                                               - 1]
             self.play(song_to_play)
         elif choise == "list":
             print(self.playlist)
         elif choise == "exit":
             break
         elif choise.split()[0] == "save" and choise.split()[1] == "to":
             Playlist("New Playlist").save(choise.split()[2])
 def test_generate_playlist(self):
     crawler = MusicCrawler(self.songs_path)
     # should have only two identical songs from different formats - .ogg & .mp3
     playlist = crawler.generate_playlist()
     song_count = 2
     for idx in range(song_count):
         with self.subTest(song_idx=idx):
             song_DRAKE_WORST_BEHAVIOUR = playlist.next_song()
             self.assertEqual(song_DRAKE_WORST_BEHAVIOUR.title,
                              'Worst Behavior')
             self.assertEqual(song_DRAKE_WORST_BEHAVIOUR.artist, 'Drake')
             self.assertEqual(song_DRAKE_WORST_BEHAVIOUR.album,
                              'Nothing Was The Same')
             self.assertEqual(song_DRAKE_WORST_BEHAVIOUR.length, '4:37')
             self.assertEqual(song_DRAKE_WORST_BEHAVIOUR.timedelta_length,
                              timedelta(hours=0, minutes=4, seconds=37))
             self.assertEqual(
                 str(song_DRAKE_WORST_BEHAVIOUR),
                 'Drake - Worst Behavior from Nothing Was The Same - 4:37')
Exemplo n.º 3
0
def main():
    file_names = {}
    print("Welcome to buggy console Audio Player!")
    print("You can use the following commands:")
    print('-------------------------------------------')
    print("load <directory> - makes new playslist\n"
          "load <playlist> - load existing playlist"
          " /*json extensions only*/\n"
          "save <file name> - saves loaded playlist\n"
          "show - shows the current playlist\n"
          "play --<song> - plays the given song\n"
          "qiut or exit - closes the player\n")

    while True:
        selection = input('Enter a command > ')

        if selection == 'exit' or selection == 'quit':
            exit()
        elif selection.startswith('load'):
            params = selection.split(' ')
            if params[1].endswith('.json'):
                my_playlist = Playlist.load(params[1])
            else:
                my_playlist = MusicCrawler(params[1])
                my_playlist.generate_playlist()
                file_names = my_playlist.file_names
                my_playlist = my_playlist.playlist
            print(my_playlist.to_string())
        elif selection.startswith('play'):
            params = selection.split('--')
            print('Now playng ' + params[1])
            print('Press "n" to stop song\n'
                  '"m" to Mute or Unmute song\n'
                  '"*"" or "/" to Increase/Decrease Volume')
            # The player in quiet mode with Keys control
            call(['mpg123', file_names[params[1]], '-qK'])
            print(my_playlist.to_string())
Exemplo n.º 4
0
 def setUp(self):
     path = '/home/petar-ivanov/Desktop/Music/'
     self.crawler = MusicCrawler(path)
Exemplo n.º 5
0
 def add_dir(self):
     crawler = MusicCrawler(self.directory)
     self.playlist = crawler.generate_playlist()
Exemplo n.º 6
0
    process.kill()


print(10 * '-')
print("Menu:")
print("1. Generate songs from a directory and make a playlist.")
print("2. PPrint playlist.")
print("3. Get next song.")
print("4. Play song.")
print("5. Stop song.")
print("0. Exit.")

while True:
    choice = input("Enter your choice: ")

    if choice is '1':
        directory = input("Type your directory: ")
        crawler = MusicCrawler(directory)
        new_playlist = crawler.generate_playlist()
    elif choice is '2':
        new_playlist.pprint_playlist()
    elif choice is '3':
        current_song = new_playlist.next_song()
        print("The next song is: {}".format(current_song))
    elif choice is '4':
        bam = play(current_song.title + '.mp3')
    elif choice is '5':
        stop(bam)
    else:
        sys.exit()
Exemplo n.º 7
0
 def setUp(self):
     self.my_music_crawler = MusicCrawler(
         "/home/emil/Downloads/Rammstein-GH.2009/CD1/")
 def test_crawl(self):
     """ Crawl the directories and test if the songs list has the expected mp3 files """
     crawler = MusicCrawler(self.songs_path)
     # our songs list contain the absolute paths to the songs
     drake_song = crawler.songs[0]  # our path has only one music file
     self.assertTrue(drake_song.endswith('Drake - Worst Behavior.mp3'))
Exemplo n.º 9
0
 def test_generate_playlist(self):
     mc = MusicCrawler('/home/stoyaneft/Music')
     print()
     print(mc.generate_playlist())
def main():
    crawler = MusicCrawler(MUSIC_DIR)
    songs_data = crawler.generate_songs()
    pl = Playlist('Playlist1')
    pl.add_songs(songs_data)
    pl.pprint_playlist()
Exemplo n.º 11
0
 def __init__(self, directory):
     self.mc = MusicCrawler(directory)
     self.playlist = self.mc.generate_playlist()
Exemplo n.º 12
0
 def setUp(self):
     self.mcw = MusicCrawler('/home/tanija/Music/Metallica')
Exemplo n.º 13
0
 def load_playlist(self, *, path, name='', repeat=False, shuffle=False):
     crawler = MusicCrawler(path)
     self._playlist = crawler.generate_playlist(name=name,
                                                repeat=repeat,
                                                shuffle=shuffle)