mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
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:
+5
-3
@@ -221,13 +221,15 @@ def get_artist(artisthash: str):
|
||||
|
||||
genres = list(genres)
|
||||
|
||||
min_stamp = min(t.date for t in tracks)
|
||||
year = datetime.fromtimestamp(min_stamp).year
|
||||
try:
|
||||
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
|
||||
|
||||
year = int(str(year)[:3])
|
||||
|
||||
decade = ""
|
||||
|
||||
if year == 196:
|
||||
|
||||
@@ -149,6 +149,7 @@ mapp = {
|
||||
"clean_album_title": SessionVarKeys.CLEAN_ALBUM_TITLE,
|
||||
"remove_remaster": SessionVarKeys.REMOVE_REMASTER_FROM_TRACK,
|
||||
"merge_albums": SessionVarKeys.MERGE_ALBUM_VERSIONS,
|
||||
"show_albums_as_singles": SessionVarKeys.SHOW_ALBUMS_AS_SINGLES,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ CREATE TABLE IF NOT EXISTS settings (
|
||||
remove_prod integer NOT NULL DEFAULT 1,
|
||||
clean_album_title 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 (
|
||||
|
||||
@@ -149,3 +149,4 @@ def load_settings():
|
||||
SessionVars.CLEAN_ALBUM_TITLE = bool(s[3])
|
||||
SessionVars.REMOVE_REMASTER_FROM_TRACK = bool(s[4])
|
||||
SessionVars.MERGE_ALBUM_VERSIONS = bool(s[5])
|
||||
SessionVars.SHOW_ALBUMS_AS_SINGLES = bool(s[6])
|
||||
|
||||
@@ -296,7 +296,8 @@ class UpdateAppSettingsTable(Migration):
|
||||
remove_prod integer NOT NULL DEFAULT 1,
|
||||
clean_album_title 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
|
||||
);
|
||||
"""
|
||||
|
||||
|
||||
@@ -166,11 +166,20 @@ class Album:
|
||||
Checks if the album is a single.
|
||||
"""
|
||||
keywords = ["single version", "- single"]
|
||||
|
||||
show_albums_as_singles = get_flag(
|
||||
SessionVarKeys.SHOW_ALBUMS_AS_SINGLES
|
||||
)
|
||||
|
||||
for keyword in keywords:
|
||||
if keyword in self.title.lower():
|
||||
self.is_single = True
|
||||
return
|
||||
|
||||
if show_albums_as_singles and len(tracks) == 1:
|
||||
self.is_single = True
|
||||
return
|
||||
|
||||
if (
|
||||
len(tracks) == 1
|
||||
and (
|
||||
|
||||
@@ -176,6 +176,7 @@ class SessionVars:
|
||||
|
||||
MERGE_ALBUM_VERSIONS = False
|
||||
ARTIST_SEPARATORS = set()
|
||||
SHOW_ALBUMS_AS_SINGLES = True
|
||||
|
||||
|
||||
# TODO: Find a way to eliminate this class without breaking typings
|
||||
@@ -188,6 +189,9 @@ class SessionVarKeys:
|
||||
PERIODIC_SCAN_INTERVAL = "PERIODIC_SCAN_INTERVAL"
|
||||
MERGE_ALBUM_VERSIONS = "MERGE_ALBUM_VERSIONS"
|
||||
ARTIST_SEPARATORS = "ARTIST_SEPARATORS"
|
||||
SHOW_ALBUMS_AS_SINGLES = (
|
||||
"SHOW_ALBUMS_AS_SINGLES"
|
||||
)
|
||||
|
||||
|
||||
def get_flag(key: SessionVarKeys) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user