mirror of
https://github.com/phin05/discord-rich-presence-plex
synced 2024-11-24 18:43:02 +00:00
Added support for progress bar display
This commit is contained in:
parent
3816db4204
commit
969a924488
3 changed files with 16 additions and 8 deletions
|
@ -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):
|
||||
|
|
15
core/plex.py
15
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:
|
||||
|
|
|
@ -20,7 +20,7 @@ class Display(TypedDict):
|
|||
album: bool
|
||||
year: bool
|
||||
statusIcon: bool
|
||||
remainingTime: bool
|
||||
progressMode: str
|
||||
paused: bool
|
||||
posters: Posters
|
||||
buttons: list[Button]
|
||||
|
|
Loading…
Reference in a new issue