本文整理汇总了Python中playlist.Playlist.show_artist方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.show_artist方法的具体用法?Python Playlist.show_artist怎么用?Python Playlist.show_artist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.show_artist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPlaylist
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import show_artist [as 别名]
class TestPlaylist(unittest.TestCase):
def setUp(self):
self.playlist = Playlist("MyPlaylist")
def tearDown(self):
pass
def test_add_song(self):
song = Song("Sweet Child O'mine", "Guns N' Roses",
"Appetite for Destruction", 5, 356, 320)
self.playlist.add_song(song)
self.assertTrue(song in self.playlist.collection)
def test_remove_song(self):
song = Song("Sweet Child O'mine", "Guns N' Roses",
"Appetite for Destruction", 5, 356, 320)
song1 = Song("Sweet Child O'mine1", "Guns N' Roses1",
"Appetite for Destruction1", 4, 300, 120)
self.playlist.add_song(song)
self.playlist.add_song(song)
self.playlist.add_song(song)
self.playlist.add_song(song1)
self.playlist.remove_song(song)
self.assertTrue(song not in self.playlist.collection)
self.assertTrue(song1 in self.playlist.collection)
def test_total_length(self): # in seconds
song = Song("Sweet Child O'mine", "Guns N' Roses",
"Appetite for Destruction", 5, 360, 320)
song1 = Song("Sweet Child O'mine1", "Guns N' Roses1",
"Appetite for Destruction1", 4, 306, 120)
self.playlist.add_song(song)
self.playlist.add_song(song1)
result = self.playlist.total_length()
self.assertEqual(666, result)
def test_remove_disrated(self):
song = Song("Sweet Child O'mine", "Guns N' Roses",
"Appetite for Destruction", 5, 360, 320)
song1 = Song("Sweet Child O'mine1", "Guns N' Roses1",
"Appetite for Destruction1", 2, 306, 120)
self.playlist.add_song(song)
self.playlist.add_song(song1)
self.playlist.remove_disrated(3)
self.assertTrue(song1 not in self.playlist.collection)
def test_remove_bad_quality(self):
song = Song("Sweet Child O'mine", "Guns N' Roses",
"Appetite for Destruction", 5, 360, 320)
song1 = Song("Sweet Child O'mine1", "Guns N' Roses1",
"Appetite for Destruction1", 2, 306, 120)
self.playlist.add_song(song)
self.playlist.add_song(song1)
self.playlist.remove_bad_quality()
self.assertTrue(song1 not in self.playlist.collection)
def test_show_artist(self):
song = Song("Sweet Child O'mine", "Guns N' Roses",
"Appetite for Destruction", 5, 360, 320)
song1 = Song("Sweet Child O'mine1", "Guns N' Roses",
"Appetite for Destruction1", 2, 306, 120)
self.playlist.add_song(song)
self.playlist.add_song(song1)
self.assertEqual(["Guns N' Roses"], self.playlist.show_artist())
示例2: __init__
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import show_artist [as 别名]
class MusicPlayer:
def __init__(self):
self.playlist = Playlist("myPlaylist")
self.choice = 0
def list_options(self):
options = ["craw a directory (<path_to_the_files>)",
"create empty playlist(<name_of_the_playlist>)",
"load a playlist(<name_of_the file_to_load_from>)",
"save a playlist(<name_of_the_file_to_save_in>)",
"add song to a playlist(<song>)",
"remove song from the playlist()(<song>)",
"remove disrated songs(<rating>)",
"remove songs with bad quality",
"show artists",
"print",
"list options",
"finish"]
for index, value in enumerate(options):
print (index + 1, value)
print("<song> is <title> <artist> <album> <rating> <length> <bitrate>")
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")
def user_decision(self):
self.list_options()
while True:
command = input("Enter command>")
command = command.split(" ")
self.choice = int(command[0])
arguments = command[1:]
if self.choice == 12:
break
else:
self.options(arguments)