示例#1
0
def main():
    path = ''
    while path == '':
        path = askdirectory(title='Please choose path to crawl!')
    crawler = MusicCrawler(path)
    songs = crawler.generate_playlist()
    pname = ''
    print('\n')
    while pname == '':
        pname = input('Please insert playlist name: ')
    playlist = Playlist(pname)
    playlist.add_songs(songs)
    print('\n')
    # print(playlist.playlist1)
    print('\n')
    print(playlist.pprint_playlist())
    print('\n')
    print(playlist.artists())
    print('\n')
    playlist.save()
    playlist.remove_all_songs(playlist.playlist1)
    print(playlist.pprint_playlist())
    print('\n')
    playlist.load(askopenfilename(title='Please choose playlist file to load'))
    print('\n')
    print(playlist.pprint_playlist())
    print('\n')
    print(playlist.artists())
    print('\n')
示例#2
0
def main():
    path = '/home/kolchakov/Desktop/mp3/CD1/'
    crawler = MusicCrawler(path)
    songs = crawler.generate_playlist()
    my_playlist = Playlist('rock')
    my_playlist.add_songs(songs)
    while True:
        command = input("enter command>>")
        if command == "next":
            print (my_playlist.next_song())
class TestMusicCrawler(unittest.TestCase):
    def setUp(self):
        self.my_music_crawler = MusicCrawler("/home/emil/Downloads/Rammstein-GH.2009/CD1/")

    def test_init(self):
        self.assertEqual(self.my_music_crawler.path, "/home/emil/Downloads/Rammstein-GH.2009/CD1/")

    def test_generate_playlist_raw_format(self):
        self.my_music_crawler.generate_playlist()
        self.my_music_crawler.generated_playlist.save("emoemo.json")
示例#4
0
class TestMusicCrawler(unittest.TestCase):
    def setUp(self):
        self.mcw = MusicCrawler('/home/tanija/Music/Metallica')

    def test_get_music_files(self):
        self.assertSequenceEqual(self.mcw.get_music_files(),
                                 [efwef, feje.mp3, cdk])

    def test_generate_palylist(self):
        self.assertEqual(self.mcw.generate_palylist(), {})
示例#5
0
class TestMusicCrawler(unittest.TestCase):
    def setUp(self):
        self.my_music_crawler = MusicCrawler(
            "/home/emil/Downloads/Rammstein-GH.2009/CD1/")

    def test_init(self):
        self.assertEqual(self.my_music_crawler.path,
                         "/home/emil/Downloads/Rammstein-GH.2009/CD1/")

    def test_generate_playlist_raw_format(self):
        self.my_music_crawler.generate_playlist()
        self.my_music_crawler.generated_playlist.save("emoemo.json")
class MusicPlayer():
    def __init__(self, directory):
        self.mc = MusicCrawler(directory)
        self.playlist = self.mc.generate_playlist()

    def playSound(self):
        pass

    @staticmethod
    def loop():
        musicPlayer = MusicPlayer("/home/tony/Music/")

        while True:
            command = input("> ")

            #firstPlay = True
            pygame.init()
            pygame.mixer.music.load(musicPlayer.mc.mp3_files[0])
            pos = 0.0

            if command == "play":
                pygame.mixer.music.set_pos(pos)
                pygame.mixer.music.play()
            elif command == "pause":
                pos = pygame.mixer.music.get_pos()
                pygame.mixer.music.pause()
            elif command == "quit":
                print("bye!")
                break
            else:
                print("Invalid command!")
class MusicPlayer():

    def __init__(self, directory):
        self.mc = MusicCrawler(directory)
        self.playlist = self.mc.generate_playlist()

    def playSound(self):
        pass

    @staticmethod
    def loop():
        musicPlayer = MusicPlayer("/home/tony/Music/")

        while True:
            command = input("> ")

            #firstPlay = True
            pygame.init()
            pygame.mixer.music.load(musicPlayer.mc.mp3_files[0])
            pos = 0.0

            if command == "play":
                pygame.mixer.music.set_pos(pos)
                pygame.mixer.music.play()
            elif command == "pause":
                pos = pygame.mixer.music.get_pos()
                pygame.mixer.music.pause()
            elif command == "quit":
                print("bye!")
                break
            else:
                print("Invalid command!")
 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')
示例#9
0
class Test_MusicCrawler(unittest.TestCase):
    def setUp(self):
        path = '/home/petar-ivanov/Desktop/Music/'
        self.crawler = MusicCrawler(path)

    def test_generate_playlist(self):
        playlist = self.crawler.generate_playlist()

        self.assertEqual(
            str(playlist.songs_list[0]),
            'Alex P. - Belucci (mp3zoneBG.net) from [mp3zoneBG.net] - 0:02:42')
示例#10
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])
示例#11
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])
示例#12
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())
示例#13
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())
示例#14
0
 def setUp(self):
     self.mcw = MusicCrawler('/home/tanija/Music/Metallica')
 def setUp(self):
     self.my_music_crawler = MusicCrawler("/home/emil/Downloads/Rammstein-GH.2009/CD1/")
def menu():
    print("welcome to the best music player ever")
    t = True
    playlist = None
    p = None
    while t:

        print("1. Create new Playlist")
        print("2. Load existing Playlist")
        print("3. Save current playlist")
        print("4. View Playlist")
        print("5. PLay song")
        print("6. Exit")

        choice = input("> ")
        if choice == "1":
            print("Enter name for new Playlist > "),
            name = input()
            print("Enter the filepath to your music > ")
            filepath = input()
            m = MusicCrawler(filepath)
            playlist = m.generate_playlist()
            playlist.name = name
            print("Playlist {}  created".format(playlist.name))

        elif choice == "2":
            print("Enter the filepath to your playlist > ")
            filepath = input()
            playlist = load(filepath)
            if playlist is not None:
                print("Playlist {} loaded".format(playlist.name))

        elif choice == "3":
            if playlist is None:
                print("No playlist loaded")
            else:
                print("Enter filepath to save > ")
                filepath = input()
                playlist.save(filepath)

        elif choice == "4":
            for i, song in enumerate(playlist.songs):
                print("[{}] {}".format(i, song))

        elif choice == "5":
            print("Enter song number > ")
            number = int(input())
            if number < 0 or number >= len(playlist.songs):
                print("song number doesnt exist!")
            else:
                if p is not None:
                    p.terminate()
                    os.system("pkill -9 play")
                p = multiprocessing.Process(target=playSong,
                    args=(playlist.songs, number))
                p.start()
                print()
        elif choice == "6":
            if p is not None:
                p.terminate()
                os.system("pkill -9 play")
            print("Thank you! Come again!")
            sys.exit(0)

        else:
            print("Wrong input! try again")
 def test_generate_playlist(self):
     mc = MusicCrawler('/home/stoyaneft/Music')
     print()
     print(mc.generate_playlist())
示例#18
0
 def add_dir(self):
     crawler = MusicCrawler(self.directory)
     self.playlist = crawler.generate_playlist()
示例#19
0
 def __init__(self, directory):
     self.mc = MusicCrawler(directory)
     self.playlist = self.mc.generate_playlist()
示例#20
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()
def main():
    crawler = MusicCrawler(MUSIC_DIR)
    songs_data = crawler.generate_songs()
    pl = Playlist('Playlist1')
    pl.add_songs(songs_data)
    pl.pprint_playlist()
示例#22
0
 def test_generate_playlist(self):
     mc = MusicCrawler('/home/stoyaneft/Music')
     print()
     print(mc.generate_playlist())
示例#23
0
 def add_song(self, path):
     self._playlist.add_song(MusicCrawler.extract_song(path))
示例#24
0
 def setUp(self):
     self.my_music_crawler = MusicCrawler(
         "/home/emil/Downloads/Rammstein-GH.2009/CD1/")
示例#25
0
 def __init__(self, directory):
     self.mc = MusicCrawler(directory)
     self.playlist = self.mc.generate_playlist()
 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'))
示例#27
0
 def setUp(self):
     path = '/home/petar-ivanov/Desktop/Music/'
     self.crawler = MusicCrawler(path)
示例#28
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)