diff --git a/src/music_kraken/objects/parents.py b/src/music_kraken/objects/parents.py index c7d8385..f231bfd 100644 --- a/src/music_kraken/objects/parents.py +++ b/src/music_kraken/objects/parents.py @@ -63,6 +63,9 @@ class OuterProxy: _default_factories: dict = {} _outer_attribute: Set[str] = {"options", "metadata", "indexing_values"} + DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple() + UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple() + def __init__(self, _id: int = None, dynamic: bool = False, **kwargs): _automatic_id: bool = False @@ -112,7 +115,7 @@ class OuterProxy: :return: """ - if __name.startswith("_") or __name in self._outer_attribute: + if __name.startswith("_") or __name in self._outer_attribute or __name.isupper(): return object.__getattribute__(self, __name) _inner: InnerData = super().__getattribute__("_inner") diff --git a/src/music_kraken/objects/song.py b/src/music_kraken/objects/song.py index c20b5b9..a113c6f 100644 --- a/src/music_kraken/objects/song.py +++ b/src/music_kraken/objects/song.py @@ -78,8 +78,6 @@ class Song(Base): main_artist_list=main_artist_list, feature_artist_list=feature_artist_list, album_list=album_list, **kwargs) - - UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection", "main_artist_collection", "feature_artist_collection") def __init_collections__(self) -> None: @@ -152,8 +150,6 @@ class Song(Base): f"by Artist({OPTION_STRING_DELIMITER.join(artist.name for artist in self.main_artist_collection)}) " \ f"feat. Artist({OPTION_STRING_DELIMITER.join(artist.name for artist in self.feature_artist_collection)})" - - @property def options(self) -> List[P]: options = self.main_artist_collection.shallow_list @@ -225,7 +221,7 @@ class Album(Base): source_list=source_list, artist_list=artist_list, song_list=song_list, label_list=label_list, **kwargs) - DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("song_collection", ) + DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("song_collection",) UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("artist_collection", "label_collection") def __init_collections__(self): @@ -364,7 +360,7 @@ class Album(Base): :return: """ return len(self.artist_collection) > 1 - + @property def album_type_string(self) -> str: return self.album_type.value @@ -425,7 +421,7 @@ class Artist(Base): **kwargs) DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("feature_song_collection", "main_album_collection") - UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection", ) + UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",) def __init_collections__(self): self.feature_song_collection.append_object_to_attribute = { @@ -435,7 +431,7 @@ class Artist(Base): self.main_album_collection.append_object_to_attribute = { "artist_collection": self } - + self.label_collection.append_object_to_attribute = { "current_artist_collection": self } @@ -585,7 +581,6 @@ Label class Label(Base): COLLECTION_STRING_ATTRIBUTES = ("album_collection", "current_artist_collection") - DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = COLLECTION_STRING_ATTRIBUTES name: str @@ -628,5 +623,5 @@ class Label(Base): options = [self] options.extend(self.current_artist_collection.shallow_list) options.extend(self.album_collection.shallow_list) - + return options diff --git a/src/music_kraken/pages/abstract.py b/src/music_kraken/pages/abstract.py index 2a42bde..da15133 100644 --- a/src/music_kraken/pages/abstract.py +++ b/src/music_kraken/pages/abstract.py @@ -1,6 +1,7 @@ import logging import random from copy import copy +from pathlib import Path from typing import Optional, Union, Type, Dict, Set, List, Tuple from string import Formatter @@ -363,8 +364,10 @@ class Page: file_parts = Formatter().parse(main_settings["download_file"]) new_target = Target( relative_to_music_dir=True, - path=main_settings["download_path"].format(**{part[1]: naming_dict[part[1]] for part in path_parts}), - file=main_settings["download_file"].format(**{part[1]: naming_dict[part[1]] for part in file_parts}) + file_path=Path( + main_settings["download_path"].format(**{part[1]: naming_dict[part[1]] for part in path_parts}), + main_settings["download_file"].format(**{part[1]: naming_dict[part[1]] for part in file_parts}) + ) ) @@ -376,8 +379,11 @@ class Page: return DownloadResult(error_message=f"No source found for {song.title} as {self.__class__.__name__}.") temp_target: Target = Target( - path=main_settings["temp_directory"], - file=str(random.randint(0, 999999)) + relative_to_music_dir=False, + file_path=Path( + main_settings["temp_directory"], + str(song.id) + ) ) r = DownloadResult(1)