def get_album(self, name, albumartist): try: return Album.get( Album.Name == name, peewee.fn.lower(Album.Artist) == albumartist.lower()) except peewee.DoesNotExist: return None
def __init__(self, album=None, song_path=None): if album: self.album = album elif song_path: song = Song.get(Song.Path == song_path) self.album = Album.get( Album.Name == song.Album, peewee.fn.lower(Album.Artist) == song.AlbumArtist.lower())
def get_playlist(self, name): try: x = Artist.get(Artist.Name == name) return playlists.ArtistPlaylist(x) except peewee.DoesNotExist: pass try: x = Album.get(Album.Name == name) return playlists.AlbumPlaylist(x) except peewee.DoesNotExist: pass return None