add setting to show albums with single track as singles

+ add the above setting to db queries file and migration
This commit is contained in:
mungai-njoroge
2023-09-04 19:46:46 +03:00
parent 83bbe69550
commit 6c0024f699
7 changed files with 24 additions and 5 deletions
+5 -3
View File
@@ -221,13 +221,15 @@ def get_artist(artisthash: str):
genres = list(genres) genres = list(genres)
min_stamp = min(t.date for t in tracks) try:
year = datetime.fromtimestamp(min_stamp).year min_stamp = min(t.date for t in tracks)
year = datetime.fromtimestamp(min_stamp).year
except ValueError:
year = 0
# TODO: Find a way to round a number to the nearest lower 10, and just add an "s" to get the decade # TODO: Find a way to round a number to the nearest lower 10, and just add an "s" to get the decade
year = int(str(year)[:3]) year = int(str(year)[:3])
decade = "" decade = ""
if year == 196: if year == 196:
+1
View File
@@ -149,6 +149,7 @@ mapp = {
"clean_album_title": SessionVarKeys.CLEAN_ALBUM_TITLE, "clean_album_title": SessionVarKeys.CLEAN_ALBUM_TITLE,
"remove_remaster": SessionVarKeys.REMOVE_REMASTER_FROM_TRACK, "remove_remaster": SessionVarKeys.REMOVE_REMASTER_FROM_TRACK,
"merge_albums": SessionVarKeys.MERGE_ALBUM_VERSIONS, "merge_albums": SessionVarKeys.MERGE_ALBUM_VERSIONS,
"show_albums_as_singles": SessionVarKeys.SHOW_ALBUMS_AS_SINGLES,
} }
+2 -1
View File
@@ -31,7 +31,8 @@ CREATE TABLE IF NOT EXISTS settings (
remove_prod integer NOT NULL DEFAULT 1, remove_prod integer NOT NULL DEFAULT 1,
clean_album_title integer NOT NULL DEFAULT 1, clean_album_title integer NOT NULL DEFAULT 1,
remove_remaster integer NOT NULL DEFAULT 1, remove_remaster integer NOT NULL DEFAULT 1,
merge_albums integer NOT NULL DEFAULT 0 merge_albums integer NOT NULL DEFAULT 0,
show_albums_as_singles NOT NULL DEFAULT 0
); );
CREATE TABLE IF NOT EXISTS lastfm_similar_artists ( CREATE TABLE IF NOT EXISTS lastfm_similar_artists (
+1
View File
@@ -149,3 +149,4 @@ def load_settings():
SessionVars.CLEAN_ALBUM_TITLE = bool(s[3]) SessionVars.CLEAN_ALBUM_TITLE = bool(s[3])
SessionVars.REMOVE_REMASTER_FROM_TRACK = bool(s[4]) SessionVars.REMOVE_REMASTER_FROM_TRACK = bool(s[4])
SessionVars.MERGE_ALBUM_VERSIONS = bool(s[5]) SessionVars.MERGE_ALBUM_VERSIONS = bool(s[5])
SessionVars.SHOW_ALBUMS_AS_SINGLES = bool(s[6])
+2 -1
View File
@@ -296,7 +296,8 @@ class UpdateAppSettingsTable(Migration):
remove_prod integer NOT NULL DEFAULT 1, remove_prod integer NOT NULL DEFAULT 1,
clean_album_title integer NOT NULL DEFAULT 1, clean_album_title integer NOT NULL DEFAULT 1,
remove_remaster integer NOT NULL DEFAULT 1, remove_remaster integer NOT NULL DEFAULT 1,
merge_albums integer NOT NULL DEFAULT 0 merge_albums integer NOT NULL DEFAULT 0,
show_albums_as_singles NOT NULL DEFAULT 0
); );
""" """
+9
View File
@@ -166,11 +166,20 @@ class Album:
Checks if the album is a single. Checks if the album is a single.
""" """
keywords = ["single version", "- single"] keywords = ["single version", "- single"]
show_albums_as_singles = get_flag(
SessionVarKeys.SHOW_ALBUMS_AS_SINGLES
)
for keyword in keywords: for keyword in keywords:
if keyword in self.title.lower(): if keyword in self.title.lower():
self.is_single = True self.is_single = True
return return
if show_albums_as_singles and len(tracks) == 1:
self.is_single = True
return
if ( if (
len(tracks) == 1 len(tracks) == 1
and ( and (
+4
View File
@@ -176,6 +176,7 @@ class SessionVars:
MERGE_ALBUM_VERSIONS = False MERGE_ALBUM_VERSIONS = False
ARTIST_SEPARATORS = set() ARTIST_SEPARATORS = set()
SHOW_ALBUMS_AS_SINGLES = True
# TODO: Find a way to eliminate this class without breaking typings # TODO: Find a way to eliminate this class without breaking typings
@@ -188,6 +189,9 @@ class SessionVarKeys:
PERIODIC_SCAN_INTERVAL = "PERIODIC_SCAN_INTERVAL" PERIODIC_SCAN_INTERVAL = "PERIODIC_SCAN_INTERVAL"
MERGE_ALBUM_VERSIONS = "MERGE_ALBUM_VERSIONS" MERGE_ALBUM_VERSIONS = "MERGE_ALBUM_VERSIONS"
ARTIST_SEPARATORS = "ARTIST_SEPARATORS" ARTIST_SEPARATORS = "ARTIST_SEPARATORS"
SHOW_ALBUMS_AS_SINGLES = (
"SHOW_ALBUMS_AS_SINGLES"
)
def get_flag(key: SessionVarKeys) -> bool: def get_flag(key: SessionVarKeys) -> bool: