本文整理汇总了Python中playlist.Playlist类的典型用法代码示例。如果您正苦于以下问题:Python Playlist类的具体用法?Python Playlist怎么用?Python Playlist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Playlist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_song
def test_remove_song(self):
song = Song(title="Odin", artist="Manowar", album="The Sons of Odin", length="1:30:44")
code_songs = Playlist(name="Code", repeat=False, shuffle=False)
code_songs.add_song(song)
self.assertTrue(song in code_songs.song_list)
code_songs.remove_song(song)
self.assertTrue(song not in code_songs.song_list)
示例2: options
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")
示例3: __init__
def __init__(self, dogvibes, id):
self.dogvibes = dogvibes
self.pipeline = gst.Pipeline("amppipeline" + id)
# create the tee element
self.tee = gst.element_factory_make("tee", "tee")
self.pipeline.add(self.tee)
# listen for EOS
self.bus = self.pipeline.get_bus()
self.bus.add_signal_watch()
self.bus.connect('message', self.pipeline_message)
# Create amps playqueue
if Playlist.name_exists(dogvibes.ampdbname + id) == False:
self.dogvibes.API_createPlaylist(dogvibes.ampdbname + id)
tqplaylist = Playlist.get_by_name(dogvibes.ampdbname + id)
self.tmpqueue_id = tqplaylist.id
self.active_playlist_id = self.tmpqueue_id
if (tqplaylist.length() > 0):
self.active_playlists_track_id = tqplaylist.get_track_nbr(0).ptid
else:
self.active_playlists_track_id = -1
self.fallback_playlist_id = -1
self.fallback_playlists_track_id = -1
# sources connected to the amp
self.sources = []
# the gstreamer source that is currently used for playback
self.src = None
self.needs_push_update = False
示例4: test_total_length
def test_total_length(self):
new_playlist = Playlist("my_playlist")
harvester_song = Song("Harvester of sorrow", "Metallica", "...And justice for all", 3, 300, 192)
enter_song = Song("Enter sandman", "Metallica", "Balck album", 2, 300, 192)
new_playlist.songs.append(harvester_song)
new_playlist.songs.append(enter_song)
self.assertEqual(new_playlist.total_length(), 600)
示例5: API_renamePlaylist
def API_renamePlaylist(self, playlist_id, name, request):
try:
Playlist.rename(playlist_id, name)
except ValueError as e:
raise
self.needs_push_update = True
request.finish()
示例6: test_total_length
def test_total_length(self):
playlist = Playlist("TestPlaylist")
song1 = Song("Thunderstruck", "ACDC", "The Razors Edge", 5, 271.8, 320)
song2 = Song("Thunderstruck", "ACDC", "The Razors Edge", 5, 200, 320)
playlist.add_song(song1)
playlist.add_song(song2)
self.assertEqual(playlist.total_length(), 471.8)
示例7: generate_playlist
def generate_playlist(self, playlist_name):
output_playlist = Playlist(playlist_name)
files = self._get_audio_files(self.__path)
for filename in files:
audio_obj = MP3(filename)
song = self._create_song(audio_obj)
output_playlist.add(song)
return output_playlist
示例8: test_remove_bad_quality
def test_remove_bad_quality(self):
new_playlist = Playlist("my_playlist")
enter_song = Song("Enter sandman", "Metallica", "Balck album", 2, 300, 192000)
harvester_song = Song("Harvester of sorrow", "Metallica", "...And justice for all", 3, 300, 150000)
new_playlist.songs.append(harvester_song)
new_playlist.songs.append(enter_song)
new_playlist.remove_bad_quality()
self.assertEqual(len(new_playlist.songs), 1)
示例9: generate_playlist
def generate_playlist(self):
result = Playlist("Rock'n'roll")
music_files = [f for f in os.listdir(self.path) if f.endswith('.mp3') or f.endswith('.MP3')]
for song in music_files:
audio = MP3(self.path + "/" + song)
print(audio)
my_new_song = Song(audio["TIT2"], audio["TPE1"], audio["TALB"], 0, int(audio.info.length), audio.info.bitrate)
result.add_song(my_new_song)
return result
示例10: test_str
def test_str(self):
new_playlist = Playlist("my_playlist")
enter_song = Song("Enter sandman", "Metallica", "Balck album", 2, 300, 192)
harvester_song = Song("Harvester of sorrow", "Metallica", "...And justice for all",3 , 300, 150)
new_playlist = Playlist("my_playlist")
new_playlist.songs.append(harvester_song)
new_playlist.songs.append(enter_song)
expected_string = "Metallica - Harvester of sorrow 300\nMetallica - Enter sandman 300\n"
self.assertEqual(expected_string, new_playlist.str_func())
示例11: cwd
def cwd(self, arg=None, menuw=None):
"""
make a menu item for each file in the directory
"""
logger.log( 9, 'cwd(arg=%r, menuw=%r)', arg, menuw)
play_items = []
number = len(self.info['tracks'])
if hasattr(self.info, 'mixed'):
number -= 1
for i in range(0, number):
title=self.info['tracks'][i]['title']
item = AudioItem('cdda://%d' % (i+1), self, title, scan=False)
# XXX FIXME: set also all the other info here if AudioInfo
# XXX will be based on mmpython
#item.set_info('', self.name, title, i+1, self.disc_id[1], '')
item.info = self.info['tracks'][i]
item.length = item.info['length']
if config.MPLAYER_ARGS.has_key('cd'):
item.mplayer_options += (' ' + config.MPLAYER_ARGS['cd'])
if self.devicename:
item.mplayer_options += ' -cdrom-device %s' % self.devicename
play_items.append(item)
# add all playable items to the playlist of the directory
# to play one files after the other
self.playlist = play_items
# all items together
items = []
# random playlist (only active for audio)
if 'audio' in config.DIRECTORY_ADD_RANDOM_PLAYLIST and len(play_items) > 1:
pl = Playlist(_('Random Playlist'), play_items, self, random=True)
pl.autoplay = True
items += [ pl ]
items += play_items
if hasattr(self.info, 'mixed'):
d = DirItem(self.media.mountdir, self)
d.name = _('Data files on disc')
items.append(d)
self.play_items = play_items
title = self.name
if title[0] == '[' and title[-1] == ']':
title = self.name[1:-1]
item_menu = menu.Menu(title, items, item_types = self.display_type)
if menuw:
menuw.pushmenu(item_menu)
return items
示例12: test_save
def test_save(self):
playlist = Playlist("TestPlaylist")
song1 = Song("Thunderstruck", "ACDC", "The Razors Edge", 5, 271.8, 320)
song2 = Song("Thunderstruck", "ACDC", "The Razors Edge", 5, 200, 320)
playlist.add_song(song1)
playlist.add_song(song2)
self.playlist.save("json.txt")
示例13: generate_playlist
def generate_playlist(self):
playlist = Playlist("myPlaylist")
files = get_files(self.path)
for each_file in files:
audio = MP3('music/' + str(each_file))
song = Song(str(audio['TIT2']), str(audio['TPE1']), str(
audio['TALB']), 5, int(audio.info.length), audio.info.bitrate)
playlist.add_song(song)
return playlist
示例14: generate_playlist
def generate_playlist(self, name):
output_playlist = Playlist(name)
files = self._get_mp3_files(self.__crawlDir)
for filename in files:
filename = self.__crawlDir + filename
audio_obj = MP3(filename)
song = self._create_song(audio_obj)
output_playlist.add_song(song)
return output_playlist
示例15: test_show_artists
def test_show_artists(self):
new_playlist = Playlist("my_playlist")
enter_song = Song("Enter sandman", "Metallica", "Balck album", 2, 300, 192)
harvester_song = Song("Harvester of sorrow", "Metallica", "...And justice for all",3 , 300, 150)
hells_song = Song("Hells Bells", "Ac/DC", "Back in Black",2 , 240, 256)
new_playlist = Playlist("my_playlist")
new_playlist.songs.append(harvester_song)
new_playlist.songs.append(enter_song)
new_playlist.songs.append(hells_song)
self.assertEqual(len(new_playlist.show_artists()), 2)