diff --git a/core/config.py b/core/config.py index 837d6d9..9fa0daf 100644 --- a/core/config.py +++ b/core/config.py @@ -18,7 +18,7 @@ config: models.config.Config = { "album": True, "year": True, "statusIcon": False, - "remainingTime": False, + "progressMode": "bar", "paused": False, "posters": { "enabled": False, @@ -66,8 +66,11 @@ def loadConfig() -> None: config["display"]["duration"] = not config["display"]["hideTotalTime"] del config["display"]["hideTotalTime"] if "useRemainingTime" in config["display"]: - config["display"]["remainingTime"] = config["display"]["useRemainingTime"] del config["display"]["useRemainingTime"] + if "remainingTime" in config["display"]: + del config["display"]["remainingTime"] + if config["display"]["progressMode"] not in ["off", "elapsed", "remaining", "bar"]: + config["display"]["progressMode"] = "bar" saveConfig() class YamlSafeDumper(yaml.SafeDumper): diff --git a/core/plex.py b/core/plex.py index ead5c90..9836859 100644 --- a/core/plex.py +++ b/core/plex.py @@ -279,7 +279,7 @@ class PlexAlertListener(threading.Thread): title = shortTitle = item.title thumb = item.thumb if state != "playing" and mediaType != "track": - if config["display"]["remainingTime"]: + if config["display"]["progressMode"] == "remaining": stateStrings.append(f"{formatSeconds((item.duration - viewOffset) / 1000, ':')} left") else: stateStrings.append(f"{formatSeconds(viewOffset / 1000, ':')} elapsed") @@ -351,10 +351,15 @@ class PlexAlertListener(threading.Thread): activity["buttons"] = buttons[:2] if state == "playing": currentTimestamp = int(time.time() * 1000) - if config["display"]["remainingTime"]: - activity["timestamps"] = { "end": round(currentTimestamp + (item.duration - viewOffset)) } - else: - activity["timestamps"] = { "start": round(currentTimestamp - viewOffset) } + match config["display"]["progressMode"]: + case "elapsed": + activity["timestamps"] = { "start": round(currentTimestamp - viewOffset) } + case "remaining": + activity["timestamps"] = { "end": round(currentTimestamp + (item.duration - viewOffset)) } + case "bar": + activity["timestamps"] = { "start": round(currentTimestamp - viewOffset), "end": round(currentTimestamp + (item.duration - viewOffset)) } + case _: + pass if not self.discordIpcService.connected: self.discordIpcService.connect() if self.discordIpcService.connected: diff --git a/models/config.py b/models/config.py index a556cc3..2f3c947 100644 --- a/models/config.py +++ b/models/config.py @@ -20,7 +20,7 @@ class Display(TypedDict): album: bool year: bool statusIcon: bool - remainingTime: bool + progressMode: str paused: bool posters: Posters buttons: list[Button]