feat: implemented cover artwork taggin

This commit is contained in:
2024-04-10 18:18:52 +02:00
parent 28ad5311f2
commit 0c367884e3
11 changed files with 73 additions and 28 deletions

View File

@@ -22,4 +22,6 @@ from .contact import Contact
from .parents import OuterProxy
from .artwork import Artwork
DatabaseObject = TypeVar('T', bound=OuterProxy)

View File

@@ -33,7 +33,7 @@ class Artwork:
def _calculate_deviation(*dimensions: List[int]) -> float:
return sum(abs(d - main_settings["preferred_artwork_resolution"]) for d in dimensions) / len(dimensions)
def append(self, url: str, width: int, height: int) -> None:
def append(self, url: str, width: int, height: int, **kwargs) -> None:
self._variant_mapping[hash_url(url=url)] = {
"url": url,
"width": width,
@@ -43,6 +43,8 @@ class Artwork:
@property
def best_variant(self) -> ArtworkVariant:
if len(self._variant_mapping) == 0:
return None
return min(self._variant_mapping.values(), key=lambda x: x["deviation"])
def __merge__(self, other: Artwork, override: bool = False) -> None:

View File

@@ -16,7 +16,7 @@ class FormattedText:
@property
def is_empty(self) -> bool:
return self.doc is None
return self.html == ""
def __eq__(self, other) -> False:
if type(other) != type(self):

View File

@@ -3,11 +3,12 @@ from __future__ import annotations
from pathlib import Path
from typing import List, Tuple, TextIO, Union
import logging
import random
import requests
from tqdm import tqdm
from .parents import OuterProxy
from ..utils.shared import HIGHEST_ID
from ..utils.config import main_settings, logging_settings
from ..utils.string_processing import fit_to_file_system
@@ -29,6 +30,10 @@ class Target(OuterProxy):
_default_factories = {
}
@classmethod
def temp(cls, name: str = str(random.randint(0, HIGHEST_ID))) -> P:
return cls(main_settings["temp_directory"] / name)
# This is automatically generated
def __init__(self, file_path: Union[Path, str], relative_to_music_dir: bool = False, **kwargs) -> None:
if not isinstance(file_path, Path):
@@ -106,3 +111,6 @@ class Target(OuterProxy):
def delete(self):
self.file_path.unlink(missing_ok=True)
def read_bytes(self) -> bytes:
return self.file_path.read_bytes()