当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.show_artist方法代码示例

本文整理汇总了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())
开发者ID:dsspasov,项目名称:HackBulgaria,代码行数:67,代码来源:playlist_test.py

示例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)
开发者ID:dsspasov,项目名称:HackBulgaria,代码行数:67,代码来源:MusicPlayer.py


注:本文中的playlist.Playlist.show_artist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。