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 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 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')
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 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')
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())
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())
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')
def test_generate_playlist(self): mc = MusicCrawler('/home/stoyaneft/Music') print() print(mc.generate_playlist())
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 add_dir(self): crawler = MusicCrawler(self.directory) self.playlist = crawler.generate_playlist()
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 test_generate_playlist(self): mc = MusicCrawler('/home/stoyaneft/Music') print() print(mc.generate_playlist())
def load_playlist(self, *, path, name='', repeat=False, shuffle=False): crawler = MusicCrawler(path) self._playlist = crawler.generate_playlist(name=name, repeat=repeat, shuffle=shuffle)