From 6b496971c9d2980d58da5547d2f6f68d9860cf3e Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Mon, 23 Jan 2023 15:52:50 +0100 Subject: [PATCH] implemented abstract class --- src/music_kraken/pages/abstract.py | 64 +++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/music_kraken/pages/abstract.py b/src/music_kraken/pages/abstract.py index 9c7cd20..53af81c 100644 --- a/src/music_kraken/pages/abstract.py +++ b/src/music_kraken/pages/abstract.py @@ -53,7 +53,67 @@ class Page: if it is true it fetches only the most important information (only one level) if an Artist is passed in, it fetches only the discography of the artist, and not the tracklist of every album of the artist. - :return detailed_music_object: + :return detailed_music_object: IT MODIFIES THE INPUT OBJ """ - raise NotImplementedError + if type(music_object) == Song: + return cls.fetch_song_details(music_object, simple=simple) + + if type(music_object) == Album: + return cls.fetch_album_details(music_object, simple=simple) + + if type(music_object) == Artist: + return cls.fetch_artist_details(music_object, simple=simple) + + raise NotImplementedError(f"MusicObject {type(music_object)} has not been implemented yet") + + def fetch_song_details(cls, song: Song, simple: bool = False) -> Song: + """ + for a general description check cls.fetch_details + + :param song: song without much data + :param simple: + when True it only fetches the artist and the album, and the attributes of those, + who can be gotten with one api request + when False it fetches everything including, but not limited to: + - Lyrics + - Album + Tracklist (for tracksort) + + :return detailed_song: it modifies the input song + """ + + raise NotImplementedError() + + def fetch_album_details(cls, album: Album, simple: bool = False) -> Album: + """ + for a general description check cls.fetch_details + + :param album: album without much data + :param simple: + when True it only fetches the artist and the tracklist, and the attributes of those, + which can be gotten with one api request + when False it fetches everything including, but not limited to: + - Lyrics of every song + - Artist, Album, Tracklist + - every attribute of those + + :return detailed_artist: it modifies the input artist + """ + + raise NotImplementedError() + + def fetch_artist_details(cls, artist: Artist, simple: bool = False) -> Artist: + """ + for a general description check cls.fetch_details + + :param artist: artist without much data + :param simple: + when True it only fetches the discographie, meaning every album, but not every tracklist + when False it fetches everything including, but not limited to: + - the whole discography + - the tracklist of every album in the discography + + :return detailed_artist: it modifies the input artist + """ + + raise NotImplementedError()