mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
drop global XDG_CONFIG_DIR and use environment variables
+ handle string explicit flags
This commit is contained in:
@@ -116,5 +116,4 @@ class UserConfig:
|
||||
if key.startswith("_") or not self._config_path:
|
||||
return
|
||||
|
||||
print(f"writing to file: {key}={value}")
|
||||
self.write_to_file(asdict(self))
|
||||
|
||||
+3
-1
@@ -255,7 +255,9 @@ def get_tags(filepath: str, config: UserConfig):
|
||||
)
|
||||
|
||||
metadata["trackhash"] = create_hash(
|
||||
metadata.get("artists", ""), metadata.get("album", ""), metadata.get("title", "")
|
||||
metadata.get("artists", ""),
|
||||
metadata.get("album", ""),
|
||||
metadata.get("title", ""),
|
||||
)
|
||||
|
||||
extra: dict[str, Any] = {
|
||||
|
||||
+8
-1
@@ -84,8 +84,15 @@ class Track:
|
||||
self.og_album = self.album
|
||||
self.folder = self.folder + "/"
|
||||
self.weakhash = create_hash(self.title, self.artists)
|
||||
|
||||
explicit_tag = self.extra.get("explicit", ["0"])
|
||||
self.explicit = int(explicit_tag[0]) == 1
|
||||
if isinstance(explicit_tag, list):
|
||||
explicit_tag = explicit_tag[0] if explicit_tag else "0"
|
||||
if isinstance(explicit_tag, str):
|
||||
explicit_tag = explicit_tag.lower()
|
||||
self.explicit = explicit_tag in ("1", "yes", "true")
|
||||
else:
|
||||
self.explicit = bool(explicit_tag)
|
||||
|
||||
self.image = self.albumhash + ".webp" + "?pathhash=" + self.pathhash
|
||||
# self.extra = {
|
||||
|
||||
+2
-4
@@ -18,7 +18,6 @@ else:
|
||||
|
||||
|
||||
class Paths:
|
||||
XDG_CONFIG_DIR = ""
|
||||
USER_HOME_DIR = os.path.expanduser("~")
|
||||
|
||||
# TODO: Break this down into getter methods for each path
|
||||
@@ -30,9 +29,8 @@ class Paths:
|
||||
@classmethod
|
||||
def get_config_dir(cls):
|
||||
return (
|
||||
cls.XDG_CONFIG_DIR
|
||||
or os.environ.get("SWINGMUSIC_XDG_CONFIG_DIR")
|
||||
or os.path.realpath(".")
|
||||
# cls.XDG_CONFIG_DIR
|
||||
os.environ.get("SWINGMUSIC_XDG_CONFIG_DIR") or os.path.realpath(".")
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user