From 4e52c0478aa9133e8da11f6c4ea03f15cb53d9b9 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Wed, 10 Apr 2024 10:25:05 +0200 Subject: [PATCH] feat: added trace --- .vscode/settings.json | 3 ++- development/actual_donwload.py | 5 ++--- music_kraken/objects/parents.py | 6 ++++++ music_kraken/objects/song.py | 8 +++++++- music_kraken/pages/abstract.py | 4 ++++ music_kraken/utils/__init__.py | 8 ++++++-- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d33da75..2ccb4e5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,6 +17,7 @@ "python.formatting.provider": "none", "cSpell.words": [ "Bandcamp", - "levenshtein" + "levenshtein", + "OKBLUE" ] } \ No newline at end of file diff --git a/development/actual_donwload.py b/development/actual_donwload.py index ccb7610..4b242ed 100644 --- a/development/actual_donwload.py +++ b/development/actual_donwload.py @@ -6,9 +6,8 @@ logging.getLogger().setLevel(logging.DEBUG) if __name__ == "__main__": commands = [ - "s: #a PTK", - "26", - "d: 1", + "s: #a Toxoplasma", + "d: 16", ] diff --git a/music_kraken/objects/parents.py b/music_kraken/objects/parents.py index 6079062..6f28a43 100644 --- a/music_kraken/objects/parents.py +++ b/music_kraken/objects/parents.py @@ -67,6 +67,8 @@ class OuterProxy: DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple() UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple() + TITEL = "id" + def __init__(self, _id: int = None, dynamic: bool = False, **kwargs): _automatic_id: bool = False @@ -218,3 +220,7 @@ class OuterProxy: def __repr__(self): return f"{type(self).__name__}({', '.join(key + ': ' + str(val) for key, val in self.indexing_values)})" + + @property + def title_string(self) -> str: + return str(self.__getattribute__(self.TITEL)) diff --git a/music_kraken/objects/song.py b/music_kraken/objects/song.py index ef38191..7f9a056 100644 --- a/music_kraken/objects/song.py +++ b/music_kraken/objects/song.py @@ -79,6 +79,7 @@ class Song(Base): Base.__init__(**locals()) UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection", "main_artist_collection", "feature_artist_collection") + TITEL = "title" def __init_collections__(self) -> None: self.album_collection.contain_given_in_attribute = { @@ -214,9 +215,10 @@ class Album(Base): "artist_collection": Collection, "song_collection": Collection, "label_collection": Collection, - } + TITEL = "title" + # This is automatically generated def __init__(self, title: str = None, unified_title: str = None, album_status: AlbumStatus = None, album_type: AlbumType = None, language: Language = None, date: ID3Timestamp = None, @@ -430,6 +432,8 @@ class Artist(Base): "label_collection": Collection, } + TITEL = "name" + # This is automatically generated def __init__(self, name: str = "", unified_name: str = None, country: Country = None, formed_in: ID3Timestamp = None, notes: FormattedText = None, lyrical_themes: List[str] = None, @@ -643,6 +647,8 @@ class Label(Base): "unified_name": lambda: None, } + TITEL = "name" + def __init__(self, name: str = None, unified_name: str = None, notes: FormattedText = None, source_list: List[Source] = None, contact_list: List[Contact] = None, album_list: List[Album] = None, current_artist_list: List[Artist] = None, **kwargs) -> None: diff --git a/music_kraken/pages/abstract.py b/music_kraken/pages/abstract.py index b36c1f8..0261d07 100644 --- a/music_kraken/pages/abstract.py +++ b/music_kraken/pages/abstract.py @@ -28,6 +28,7 @@ from ..utils.config import main_settings from ..utils.support_classes.query import Query from ..utils.support_classes.download_result import DownloadResult from ..utils.string_processing import fit_to_file_system +from ..utils import trace INDEPENDENT_DB_OBJECTS = Union[Label, Album, Artist, Song] INDEPENDENT_DB_TYPES = Union[Type[Song], Type[Album], Type[Artist], Type[Label]] @@ -235,6 +236,8 @@ class Page: :return detailed_music_object: IT MODIFIES THE INPUT OBJ """ + trace(f"fetching {type(music_object).__name__} ({music_object.title_string})") + # creating a new object, of the same type new_music_object: Optional[DatabaseObject] = None @@ -332,6 +335,7 @@ class Page: def _download(self, music_object: DatabaseObject, naming_dict: NamingDict, download_all: bool = False, skip_details: bool = False, process_metadata_anyway: bool = False) -> DownloadResult: + trace(f"downloading {type(music_object).__name__} ({music_object.title_string})") skip_next_details = skip_details # Skips all releases, that are defined in shared.ALBUM_TYPE_BLACKLIST, if download_all is False diff --git a/music_kraken/utils/__init__.py b/music_kraken/utils/__init__.py index ed707b8..66e5479 100644 --- a/music_kraken/utils/__init__.py +++ b/music_kraken/utils/__init__.py @@ -8,8 +8,6 @@ from .config import config, read_config, write_config from .enums.colors import BColors from .path_manager import LOCATIONS -DEBUG = False - """ IO functions """ @@ -48,6 +46,12 @@ def dump_to_file(file_name: str, payload: str, is_json: bool = False, exit_after exit() +def trace(msg: str): + if DEBUG_LOGGING: + logging.debug(msg) + + output("trace: " + msg, BColors.OKBLUE) + """ misc functions