本文整理汇总了Python中playlist.Playlist.load方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.load方法的具体用法?Python Playlist.load怎么用?Python Playlist.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.load方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
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: PlaylistTest
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
class PlaylistTest(unittest.TestCase):
def setUp(self):
self.song1 = Song("Title1", "Artist1", "Album1", 2, 192, 128)
self.song2 = Song("Title2", "Artist2", "Album2", 2, 183, 1024)
self.playlist = Playlist("PlaylistTitle")
self.playlist.songs.append(self.song1)
self.playlist.songs.append(self.song2)
def test_init(self):
self.assertEqual(self.playlist.name, "PlaylistTitle")
self.assertEqual(self.playlist.songs, [self.song1, self.song2])
def test_add_song(self):
self.song3 = Song("Title3", "Artist3", "Album3", 2, 201, 128)
self.playlist.add_song(self.song3)
self.assertEqual(
self.playlist.songs, [self.song1, self.song2, self.song3])
def test_remove_song(self):
self.song3 = Song("Title3", "Artist3", "Album3", 4, 194, 1024)
self.playlist.add_song(self.song3)
self.playlist.remove_song("Title3")
self.assertEqual(self.playlist.songs, [self.song1, self.song2])
def test_total_length(self):
self.assertEqual(self.playlist.total_length(), 375)
def test_remove_disrated(self):
self.song3 = Song("Title3", "Artist3", "Album3", 4, 206, 1024)
self.playlist.add_song(self.song3)
self.playlist.remove_disrated(3)
self.assertEqual(self.playlist.songs, [self.song3])
def test_remove_bad_quality(self):
self.song3 = Song("Title3", "Artist3", "Album3", 4, 206, 1024)
self.playlist.add_song(self.song3)
self.playlist.remove_bad_quality(1000)
self.assertEqual(self.playlist.songs, [self.song2, self.song3])
def test_show_artists(self):
self.song3 = Song("Title3", "Artist2", "Album3", 4, 206, 1024)
self.playlist.add_song(self.song3)
self.assertEqual(self.playlist.show_artists(), ["Artist1", "Artist2"])
# def test_str(self):
# test = self.playlist.str()
# self.assertEqual(
# "Artist1 Title1 - 3:12\nArtist2 Title2 - 3:03\n", test)
def test_save(self):
self.playlist.save("pesho.txt")
def test_load(self):
self.playlist.load("pesho.txt")
示例3: options
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
def options(self, args):
if (self.choice == 1):
self.playlist = MusicCrawler(args[0]).generate_playlist()
elif(self.choice == 2):
self.playlist = Playlist(args[0])
elif(self.choice == 3):
self.playlist = Playlist.load(args[0])
elif(self.choice == 4):
self.playlist.save(args[0])
elif(self.choice == 5):
song = Song(args[0], args[1], args[2], int(
args[3]), int(args[4]), int(args[5]))
self.playlist.add_song(song)
elif(self.choice == 6):
song = Song(args[0], args[1], args[2], int(
args[3]), int(args[4]), int(args[5]))
self.playlist.remove_song(song)
elif(self.choice == 7):
self.playlist.remove_disrated(int(args[0]))
elif(self.choice == 8):
self.playlist.remove_bad_quality()
elif(self.choice == 9):
print(self.playlist.show_artist())
elif(self.choice == 10):
print(self.playlist)
elif(self.choice == 11):
self.list_options()
else:
print("Enter a valid command")
示例4: main
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
def main():
#new_songs_arr = []
print(start_message())
print(songs_to_add())
new_playlist = Playlist("my_playlist")
while True:
command = split_command_str(input("Enter command>"))
if the_command(command, "generate"):
new_crawler = Music_crawler(command[1])
new_playlist = new_crawler.generate_playlist()
print(new_playlist.str_func())
elif the_command(command, "remove_disrated"):
new_playlist.remove_disrated(int(command[1]))
print(new_playlist.str_func())
elif the_command(command, "remove_bad_quality"):
new_playlist.remove_bad_quality()
print(new_playlist.str_func())
elif the_command(command, "remove"):
new_playlist.remove_song(command[1])
print(new_playlist.str_func())
elif the_command(command, "add"):
for song in songs_arr:
if command[1] == song.title:
new_playlist.add_song(song)
break
print(new_playlist.str_func())
elif the_command(command, "load"):
new_playlist.load(command[1])
print(new_playlist.str_func())
elif the_command(command, "save"):
new_playlist.save(command[1])
elif the_command(command, "finish"):
print("GoodBye. Thank you for using the player")
break
else:
print(unknown_command())
示例5: __init__
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
class MusicPlayer:
def __init__(self):
self.playlist = Playlist("Playlist")
def print_messages(self):
print("Hello, welcome to the music player interface!\n")
print("Load your playlist!")
def get_input(self):
command = input("Enter command> ")
command = command.split(" ")
return command
def interface(self):
command = self.get_input()
while command[0] != "exit":
if command[0] == "load_dir":
folder = MusicCrawler(command[1])
self.playlist = folder.generate_playlist()
command = self.get_input()
elif command[0] == "remove_song":
self.playlist.remove_song(command[1])
print("Songs removed.")
command = self.get_input()
elif command[0] == "total_length":
print(self.playlist.total_length())
command = self.get_input()
elif command[0] == "remove_disrated":
self.playlist.remove_disrated(command[1])
command = self.get_input()
elif command[0] == "remove_song":
self.playlist.remove_song(command[1])
command = self.get_input()
elif command[0] == "remove_bad_quality":
self.playlist.remove_bad_quality()
print("Songs removed.")
command = self.get_input()
elif command[0] == "show_artists":
print(self.playlist.show_artists())
command = self.get_input()
elif command[0] == "remove_song":
self.playlist.remove_song(command[1])
command = self.get_input()
elif command[0] == "save":
self.playlist.save(command[1])
command = self.get_input()
elif command[0] == "load":
self.playlist = self.playlist.load(command[1])
command = self.get_input()
elif command[0] == "print_playlist":
print(self.playlist)
command = self.get_input()
else:
print("Bad input!")
command = self.get_input()
else:
print("Goodbye!")
示例6: test_load
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
def test_load(self):
self.playlist.add_song(self.song)
self.playlist.add_song(self.song_2)
file_name = str(uuid4())
self.playlist.save(file_name)
loaded_playlist = Playlist.load(file_name)
remove(file_name)
self.assertEqual(str(self.playlist), str(loaded_playlist))
示例7: main
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
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())
示例8: test_save_and_load
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
def test_save_and_load(self):
self.playlist.add_song(self.song1)
self.playlist.add_song(self.song2)
self.playlist.save("test_file")
self.assertEqual(self.playlist.str(), Playlist.load("test_file").str())
示例9: test_load
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
def test_load(self):
# pass
plst = Playlist.load('playlist.json')
print(plst.to_string)
示例10: test_load
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import load [as 别名]
def test_load(self):
self.playlist.save("test_playlist.txt")
new_playlist = Playlist.load("test_playlist.txt")
self.assertListEqual(str(new_playlist),
str(self.playlist))
remove("test_playlist.txt")