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:
geoffrey45
2023-05-05 17:49:59 +03:00
parent 5d0b59ea60
commit 51a5502efc
12 changed files with 152 additions and 57 deletions
+7 -4
View File
@@ -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)