From 4ee6fd213703573e49f6f17d4e652fc83e46bdee Mon Sep 17 00:00:00 2001 From: Kur01234 Date: Mon, 10 Jun 2024 12:23:12 +0200 Subject: [PATCH] feat:a lot of nonsences --- music_kraken/download/page_attributes.py | 7 ++++++- music_kraken/objects/artwork.py | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/music_kraken/download/page_attributes.py b/music_kraken/download/page_attributes.py index 320192f..03f8de9 100644 --- a/music_kraken/download/page_attributes.py +++ b/music_kraken/download/page_attributes.py @@ -198,7 +198,12 @@ class Pages: img.save(target.file_path, main_settings["image_format"]) - + def remove_artwork_duplicates(self) -> None: + """ + This will eliminate duplicates within the given threshold + """ + + pass def _fetch_artist_artwork(self, artist: Artist, naming: dict): naming: Dict[str, List[str]] = defaultdict(list, naming) diff --git a/music_kraken/objects/artwork.py b/music_kraken/objects/artwork.py index dc9a91c..1423c3c 100644 --- a/music_kraken/objects/artwork.py +++ b/music_kraken/objects/artwork.py @@ -80,9 +80,9 @@ class ArtworkCollection: def __init__( self, - *data: List[Union[Artwork, ArtworkVariant, dict]], + *data: List[Artwork], parent_artworks: Set[ArtworkCollection] = None, - crop_images: bool = True + crop_images: bool = True, ) -> None: # this is used for the song artwork, to fall back to the song artwork self.parent_artworks: Set[ArtworkCollection] = parent_artworks or set() @@ -91,6 +91,8 @@ class ArtworkCollection: self._data = [] self.extend(data) + + def search_artwork(self, url: str) -> Optional[ArtworkVariant]: for artwork in self._data: if url in artwork: @@ -104,7 +106,7 @@ class ArtworkCollection: def _create_new_artwork(self, **kwargs) -> Tuple[Artwork, dict]: kwargs["artwork_type"] = kwargs.get("artwork_type", self.artwork_type) - return create_dataclass_instance(Artwork, **kwargs) + return create_dataclass_instance(ArtworkVariant, dict(**kwargs)) def add_data(self, url: str, **kwargs) -> None: kwargs["url"] = url @@ -112,12 +114,16 @@ class ArtworkCollection: artwork = self.search_artwork(url) if artwork is None: - artwork, kwargs = self._create_new_artwork(url=url, **kwargs) + artwork, kwargs = self._create_new_artwork(url=url) self._data.append(artwork) artwork.add_data(url, **kwargs) def append(self, value: Union[Artwork, ArtworkVariant, dict], **kwargs): + """ + You can append the types Artwork, ArtworkVariant or dict + the best option would be to use Artwork and avoid the other options. + """ if isinstance(value, dict): kwargs.update(value) value, kwargs = create_dataclass_instance(ArtworkVariant, kwargs) @@ -135,6 +141,12 @@ class ArtworkCollection: self.append(value, **kwargs) def compile(self) -> None: + """ + This will make the artworks ready for download + """ + for artwork in self._data: + for variants in artwork.variants: + pass pass def __merge__(self, other: ArtworkCollection, **kwargs) -> None: