feat: renamed artwork
This commit is contained in:
@@ -1,27 +1,16 @@
|
||||
from typing_extensions import TypeVar
|
||||
|
||||
from .artwork import ArtworkCollection
|
||||
from .collection import Collection
|
||||
from .contact import Contact
|
||||
from .country import Country
|
||||
from .formatted_text import FormattedText
|
||||
from .metadata import ID3Timestamp
|
||||
from .metadata import Mapping as ID3Mapping
|
||||
from .metadata import Metadata
|
||||
from .option import Options
|
||||
|
||||
from .metadata import Metadata, Mapping as ID3Mapping, ID3Timestamp
|
||||
|
||||
from .parents import OuterProxy
|
||||
from .song import Album, Artist, Label, Lyrics, Song, Target
|
||||
from .source import Source, SourceType
|
||||
|
||||
from .song import (
|
||||
Song,
|
||||
Album,
|
||||
Artist,
|
||||
Target,
|
||||
Lyrics,
|
||||
Label
|
||||
)
|
||||
|
||||
from .formatted_text import FormattedText
|
||||
from .collection import Collection
|
||||
|
||||
from .country import Country
|
||||
from .contact import Contact
|
||||
|
||||
from .parents import OuterProxy
|
||||
|
||||
from .artwork import Artwork
|
||||
|
||||
DatabaseObject = OuterProxy
|
||||
|
||||
@@ -10,6 +10,7 @@ from .metadata import Mapping as id3Mapping
|
||||
from .metadata import Metadata
|
||||
from .parents import OuterProxy as Base
|
||||
|
||||
|
||||
class ArtworkVariant(TypedDict):
|
||||
url: str
|
||||
width: int
|
||||
@@ -17,10 +18,10 @@ class ArtworkVariant(TypedDict):
|
||||
deviation: float
|
||||
|
||||
|
||||
class Artwork:
|
||||
def __init__(self, *variants: List[ArtworkVariant], parent_artworks: Set[Artwork] = None, crop_images: bool = True) -> None:
|
||||
class ArtworkCollection:
|
||||
def __init__(self, *variants: List[ArtworkVariant], parent_artworks: Set[ArtworkCollection] = None, crop_images: bool = True) -> None:
|
||||
self.crop_images: bool = crop_images
|
||||
self.parent_artworks: Set[Artwork] = parent_artworks or set()
|
||||
self.parent_artworks: Set[ArtworkCollection] = parent_artworks or set()
|
||||
|
||||
self._variant_mapping: Dict[str, ArtworkVariant] = {}
|
||||
|
||||
@@ -58,7 +59,7 @@ class Artwork:
|
||||
def get_variant_name(self, variant: ArtworkVariant) -> str:
|
||||
return f"artwork_{variant['width']}x{variant['height']}_{hash_url(variant['url']).replace('/', '_')}"
|
||||
|
||||
def __merge__(self, other: Artwork, **kwargs) -> None:
|
||||
def __merge__(self, other: ArtworkCollection, **kwargs) -> None:
|
||||
self.parent_artworks.update(other.parent_artworks)
|
||||
|
||||
for key, value in other._variant_mapping.items():
|
||||
@@ -68,11 +69,11 @@ class Artwork:
|
||||
def __hash__(self) -> int:
|
||||
return id(self)
|
||||
|
||||
def __eq__(self, other: Artwork) -> bool:
|
||||
def __eq__(self, other: ArtworkCollection) -> bool:
|
||||
if hash(self) == hash(other):
|
||||
return True
|
||||
|
||||
if not isinstance(other, Artwork):
|
||||
if not isinstance(other, ArtworkCollection):
|
||||
return False
|
||||
return any(a == b for a, b in zip(self._variant_mapping.keys(), other._variant_mapping.keys()))
|
||||
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import random
|
||||
from collections import defaultdict
|
||||
from typing import List, Optional, Dict, Tuple, Type, Union
|
||||
import copy
|
||||
from typing import Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
import pycountry
|
||||
|
||||
from ..utils.enums.album import AlbumType, AlbumStatus
|
||||
from .collection import Collection, AppendHookArguments
|
||||
from .formatted_text import FormattedText
|
||||
from .lyrics import Lyrics
|
||||
from .contact import Contact
|
||||
from .artwork import Artwork
|
||||
from .metadata import (
|
||||
Mapping as id3Mapping,
|
||||
ID3Timestamp,
|
||||
Metadata
|
||||
)
|
||||
from .option import Options
|
||||
from .parents import OuterProxy, P
|
||||
from .source import Source, SourceCollection
|
||||
from .target import Target
|
||||
from .country import Language, Country
|
||||
from ..utils.config import main_settings
|
||||
from ..utils.enums.album import AlbumStatus, AlbumType
|
||||
from ..utils.enums.colors import BColors
|
||||
from ..utils.shared import DEBUG_PRINT_ID
|
||||
from ..utils.string_processing import unify
|
||||
|
||||
from .artwork import ArtworkCollection
|
||||
from .collection import AppendHookArguments, Collection
|
||||
from .contact import Contact
|
||||
from .country import Country, Language
|
||||
from .formatted_text import FormattedText
|
||||
from .lyrics import Lyrics
|
||||
from .metadata import ID3Timestamp
|
||||
from .metadata import Mapping as id3Mapping
|
||||
from .metadata import Metadata
|
||||
from .option import Options
|
||||
from .parents import OuterProxy
|
||||
from .parents import OuterProxy as Base
|
||||
|
||||
from ..utils.config import main_settings
|
||||
from ..utils.enums.colors import BColors
|
||||
from .parents import P
|
||||
from .source import Source, SourceCollection
|
||||
from .target import Target
|
||||
|
||||
"""
|
||||
All Objects dependent
|
||||
@@ -89,7 +86,7 @@ class Song(Base):
|
||||
genre: str
|
||||
note: FormattedText
|
||||
tracksort: int
|
||||
artwork: Artwork
|
||||
artwork: ArtworkCollection
|
||||
|
||||
source_collection: SourceCollection
|
||||
target_collection: Collection[Target]
|
||||
@@ -105,7 +102,7 @@ class Song(Base):
|
||||
"source_collection": SourceCollection,
|
||||
"target_collection": Collection,
|
||||
"lyrics_collection": Collection,
|
||||
"artwork": Artwork,
|
||||
"artwork": ArtworkCollection,
|
||||
|
||||
"album_collection": Collection,
|
||||
"artist_collection": Collection,
|
||||
@@ -133,7 +130,7 @@ class Song(Base):
|
||||
feature_artist_list: List[Artist] = None,
|
||||
album_list: List[Album] = None,
|
||||
tracksort: int = 0,
|
||||
artwork: Optional[Artwork] = None,
|
||||
artwork: Optional[ArtworkCollection] = None,
|
||||
**kwargs
|
||||
) -> None:
|
||||
real_kwargs = copy.copy(locals())
|
||||
@@ -258,7 +255,7 @@ class Album(Base):
|
||||
albumsort: int
|
||||
notes: FormattedText
|
||||
|
||||
artwork: Artwork
|
||||
artwork: ArtworkCollection
|
||||
source_collection: SourceCollection
|
||||
|
||||
song_collection: Collection[Song]
|
||||
@@ -278,7 +275,7 @@ class Album(Base):
|
||||
"date": ID3Timestamp,
|
||||
"notes": FormattedText,
|
||||
|
||||
"artwork": lambda: Artwork(crop_images=False),
|
||||
"artwork": lambda: ArtworkCollection(crop_images=False),
|
||||
"source_collection": SourceCollection,
|
||||
|
||||
"song_collection": Collection,
|
||||
@@ -301,7 +298,7 @@ class Album(Base):
|
||||
barcode: str = None,
|
||||
albumsort: int = None,
|
||||
notes: FormattedText = None,
|
||||
artwork: Artwork = None,
|
||||
artwork: ArtworkCollection = None,
|
||||
source_list: List[Source] = None,
|
||||
artist_list: List[Artist] = None,
|
||||
song_list: List[Song] = None,
|
||||
@@ -498,7 +495,7 @@ class Artist(Base):
|
||||
general_genre: str
|
||||
unformatted_location: str
|
||||
|
||||
artwork: Artwork
|
||||
artwork: ArtworkCollection
|
||||
|
||||
source_collection: SourceCollection
|
||||
contact_collection: Collection[Contact]
|
||||
@@ -516,7 +513,7 @@ class Artist(Base):
|
||||
"lyrical_themes": list,
|
||||
"general_genre": lambda: "",
|
||||
|
||||
"artwork": Artwork,
|
||||
"artwork": ArtworkCollection,
|
||||
|
||||
"source_collection": SourceCollection,
|
||||
"album_collection": Collection,
|
||||
@@ -536,7 +533,7 @@ class Artist(Base):
|
||||
notes: FormattedText = None,
|
||||
lyrical_themes: List[str] = None,
|
||||
general_genre: str = None,
|
||||
artwork: Artwork = None,
|
||||
artwork: ArtworkCollection = None,
|
||||
unformatted_location: str = None,
|
||||
source_list: List[Source] = None,
|
||||
contact_list: List[Contact] = None,
|
||||
|
||||
Reference in New Issue
Block a user