mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
add parsers to clean track titles .ie. remove remaster info
+ use getters to read flags + use the largest limit to get recent favorites + misc
This commit is contained in:
+8
-3
@@ -6,7 +6,7 @@ from .artist import Artist
|
||||
from ..utils.hashing import create_hash
|
||||
from ..utils.parsers import parse_feat_from_title, get_base_title_and_versions
|
||||
|
||||
from app.settings import FromFlags
|
||||
from app.settings import get_flag, ParserFlags
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -27,12 +27,14 @@ class Album:
|
||||
date: str = ""
|
||||
|
||||
og_title: str = ""
|
||||
base_title: str = ""
|
||||
is_soundtrack: bool = False
|
||||
is_compilation: bool = False
|
||||
is_single: bool = False
|
||||
is_EP: bool = False
|
||||
is_favorite: bool = False
|
||||
is_live: bool = False
|
||||
|
||||
genres: list[str] = dataclasses.field(default_factory=list)
|
||||
versions: list[str] = dataclasses.field(default_factory=list)
|
||||
|
||||
@@ -40,7 +42,7 @@ class Album:
|
||||
self.og_title = self.title
|
||||
self.image = self.albumhash + ".webp"
|
||||
|
||||
if FromFlags.EXTRACT_FEAT:
|
||||
if get_flag(ParserFlags.EXTRACT_FEAT):
|
||||
featured, self.title = parse_feat_from_title(self.title)
|
||||
|
||||
if len(featured) > 0:
|
||||
@@ -50,11 +52,14 @@ class Album:
|
||||
from ..store.tracks import TrackStore
|
||||
TrackStore.append_track_artists(self.albumhash, featured, self.title)
|
||||
|
||||
if FromFlags.REMOVE_REMASTER:
|
||||
if get_flag(ParserFlags.CLEAN_ALBUM_TITLE):
|
||||
# if FromFlags.CLEAN_ALBUM_TITLE:
|
||||
self.title, self.versions = get_base_title_and_versions(self.title)
|
||||
|
||||
if "super_deluxe" in self.versions:
|
||||
self.versions.remove("deluxe")
|
||||
else:
|
||||
self.base_title = get_base_title_and_versions(self.title, get_versions=False)[0]
|
||||
|
||||
self.albumartists_hashes = "-".join(a.artisthash for a in self.albumartists)
|
||||
|
||||
|
||||
+7
-4
@@ -1,10 +1,10 @@
|
||||
import dataclasses
|
||||
from dataclasses import dataclass
|
||||
|
||||
from app.settings import FromFlags
|
||||
from app.settings import FromFlags, get_flag, ParserFlags
|
||||
from .artist import ArtistMinimal
|
||||
from app.utils.hashing import create_hash
|
||||
from app.utils.parsers import split_artists, remove_prod, parse_feat_from_title
|
||||
from app.utils.parsers import split_artists, remove_prod, parse_feat_from_title, clean_title
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -42,18 +42,21 @@ class Track:
|
||||
artists = split_artists(self.artist)
|
||||
new_title = self.title
|
||||
|
||||
if FromFlags.EXTRACT_FEAT:
|
||||
if get_flag(ParserFlags.EXTRACT_FEAT):
|
||||
featured, new_title = parse_feat_from_title(self.title)
|
||||
original_lower = "-".join([a.lower() for a in artists])
|
||||
artists.extend([a for a in featured if a.lower() not in original_lower])
|
||||
|
||||
if FromFlags.REMOVE_PROD:
|
||||
if get_flag(ParserFlags.REMOVE_PROD):
|
||||
new_title = remove_prod(new_title)
|
||||
|
||||
# if track is a single
|
||||
if self.og_title == self.album:
|
||||
self.album = new_title
|
||||
|
||||
if get_flag(ParserFlags.REMOVE_REMASTER_FROM_TRACK):
|
||||
new_title = clean_title(new_title)
|
||||
|
||||
self.title = new_title
|
||||
|
||||
self.artist_hashes = "-".join(create_hash(a, decode=True) for a in artists)
|
||||
|
||||
Reference in New Issue
Block a user