mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
rewrite remove duplicates to support removing duplicates in albums tracks efficiently
+ remove flags added to client settings page + misc
This commit is contained in:
+9
-9
@@ -1,13 +1,13 @@
|
||||
import dataclasses
|
||||
from dataclasses import dataclass
|
||||
import datetime
|
||||
from dataclasses import dataclass
|
||||
|
||||
from app.settings import SessionVarKeys, get_flag
|
||||
|
||||
from .track import Track
|
||||
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 get_flag, ParserFlags
|
||||
from ..utils.parsers import get_base_title_and_versions, parse_feat_from_title
|
||||
from .artist import Artist
|
||||
from .track import Track
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -44,7 +44,7 @@ class Album:
|
||||
self.image = self.albumhash + ".webp"
|
||||
|
||||
# Fetch album artists from title
|
||||
if get_flag(ParserFlags.EXTRACT_FEAT):
|
||||
if get_flag(SessionVarKeys.EXTRACT_FEAT):
|
||||
featured, self.title = parse_feat_from_title(self.title)
|
||||
|
||||
if len(featured) > 0:
|
||||
@@ -58,8 +58,8 @@ class Album:
|
||||
TrackStore.append_track_artists(self.albumhash, featured, self.title)
|
||||
|
||||
# Handle album version data
|
||||
if get_flag(ParserFlags.CLEAN_ALBUM_TITLE):
|
||||
get_versions = not get_flag(ParserFlags.MERGE_ALBUM_VERSIONS)
|
||||
if get_flag(SessionVarKeys.CLEAN_ALBUM_TITLE):
|
||||
get_versions = not get_flag(SessionVarKeys.MERGE_ALBUM_VERSIONS)
|
||||
|
||||
self.title, self.versions = get_base_title_and_versions(
|
||||
self.title, get_versions=get_versions
|
||||
|
||||
+10
-6
@@ -1,6 +1,6 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from app.settings import ParserFlags, get_flag
|
||||
from app.settings import SessionVarKeys, get_flag
|
||||
from app.utils.hashing import create_hash
|
||||
from app.utils.parsers import (
|
||||
clean_title,
|
||||
@@ -41,6 +41,10 @@ class Track:
|
||||
artist_hashes: str = ""
|
||||
is_favorite: bool = False
|
||||
|
||||
# temporary attributes
|
||||
_pos: int = 0 # for sorting tracks by disc and track number
|
||||
_ati: str = "" # (album track identifier) for removing duplicates when merging album versions
|
||||
|
||||
og_title: str = ""
|
||||
og_album: str = ""
|
||||
|
||||
@@ -53,31 +57,31 @@ class Track:
|
||||
artists = split_artists(self.artists)
|
||||
new_title = self.title
|
||||
|
||||
if get_flag(ParserFlags.EXTRACT_FEAT):
|
||||
if get_flag(SessionVarKeys.EXTRACT_FEAT):
|
||||
featured, new_title = parse_feat_from_title(self.title)
|
||||
original_lower = "-".join([create_hash(a) for a in artists])
|
||||
artists.extend(
|
||||
[a for a in featured if create_hash(a) not in original_lower]
|
||||
)
|
||||
|
||||
if get_flag(ParserFlags.REMOVE_PROD):
|
||||
if get_flag(SessionVarKeys.REMOVE_PROD):
|
||||
new_title = remove_prod(new_title)
|
||||
|
||||
# if track is a single
|
||||
if self.og_title == self.album:
|
||||
self.rename_album(new_title)
|
||||
|
||||
if get_flag(ParserFlags.REMOVE_REMASTER_FROM_TRACK):
|
||||
if get_flag(SessionVarKeys.REMOVE_REMASTER_FROM_TRACK):
|
||||
new_title = clean_title(new_title)
|
||||
|
||||
self.title = new_title
|
||||
|
||||
if get_flag(ParserFlags.CLEAN_ALBUM_TITLE):
|
||||
if get_flag(SessionVarKeys.CLEAN_ALBUM_TITLE):
|
||||
self.album, _ = get_base_title_and_versions(
|
||||
self.album, get_versions=False
|
||||
)
|
||||
|
||||
if get_flag(ParserFlags.MERGE_ALBUM_VERSIONS):
|
||||
if get_flag(SessionVarKeys.MERGE_ALBUM_VERSIONS):
|
||||
self.recreate_albumhash()
|
||||
|
||||
self.artist_hashes = "-".join(create_hash(a, decode=True) for a in artists)
|
||||
|
||||
Reference in New Issue
Block a user