swingmusic/app/models/artist.py
mungai-njoroge 83bbe69550 show artist decade in genres
+ assign default artist separators if db is empty
+ add instrumental to album version
+ check if album is a single by checking og_title and current title
+ hard code juice wrld artist name in model
+ set album aritst to first artist if track has no album artist
+ rewrite get_base_album_title regex to use existing album versions
+ misc
2023-09-04 11:01:03 +03:00

54 lines
1.2 KiB
Python

import dataclasses
from dataclasses import dataclass
from app.utils.hashing import create_hash
@dataclass(slots=True)
class ArtistMinimal:
"""
ArtistMinimal class
"""
name: str
artisthash: str = ""
image: str = ""
def __init__(self, name: str):
self.name = name
self.artisthash = create_hash(self.name, decode=True)
self.image = self.artisthash + ".webp"
# hack to override all the variations from unreleased files (sorry guys!)
if self.artisthash == "5a37d5315e":
self.name = "Juice WRLD"
@dataclass(slots=True)
class Artist(ArtistMinimal):
"""
Artist class
"""
name: str = ""
trackcount: int = 0
albumcount: int = 0
duration: int = 0
colors: list[str] = dataclasses.field(default_factory=list)
is_favorite: bool = False
def __post_init__(self):
super(Artist, self).__init__(self.name)
def set_trackcount(self, count: int):
self.trackcount = count
def set_albumcount(self, count: int):
self.albumcount = count
def set_duration(self, duration: int):
self.duration = duration
def set_colors(self, colors: list[str]):
self.colors = colors