-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.py
More file actions
28 lines (22 loc) · 828 Bytes
/
library.py
File metadata and controls
28 lines (22 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from playlist import Playlist
class Library:
def __init__(self):
self.playlists = {}
self.favorites = Playlist("Favorites")
def add_song(self, song):
self.favorites.add_song(song)
genre = song.genre
if genre not in self.playlists:
self.playlists[genre] = Playlist(genre)
playlist = self.playlists[genre]
playlist.add_song(song)
if song.mood_tags:
playlist.sort_by_mood_and_attributes(song.mood_tags[0])
def remove_song(self, song):
if song.genre in self.playlists:
self.playlists[song.genre].remove_song(song)
self.favorites.remove_song(song)
def display_all_playlists(self):
for playlist in self.playlists.values():
playlist.display()
self.favorites.display()