mirror of
https://github.com/phin05/discord-rich-presence-plex
synced 2024-11-22 01:23: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,
|
"album": True,
|
||||||
"year": True,
|
"year": True,
|
||||||
"statusIcon": False,
|
"statusIcon": False,
|
||||||
"remainingTime": False,
|
"progressMode": "bar",
|
||||||
"paused": False,
|
"paused": False,
|
||||||
"posters": {
|
"posters": {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
|
@ -66,8 +66,11 @@ def loadConfig() -> None:
|
||||||
config["display"]["duration"] = not config["display"]["hideTotalTime"]
|
config["display"]["duration"] = not config["display"]["hideTotalTime"]
|
||||||
del config["display"]["hideTotalTime"]
|
del config["display"]["hideTotalTime"]
|
||||||
if "useRemainingTime" in config["display"]:
|
if "useRemainingTime" in config["display"]:
|
||||||
config["display"]["remainingTime"] = config["display"]["useRemainingTime"]
|
|
||||||
del 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()
|
saveConfig()
|
||||||
|
|
||||||
class YamlSafeDumper(yaml.SafeDumper):
|
class YamlSafeDumper(yaml.SafeDumper):
|
||||||
|
|
13
core/plex.py
13
core/plex.py
|
@ -279,7 +279,7 @@ class PlexAlertListener(threading.Thread):
|
||||||
title = shortTitle = item.title
|
title = shortTitle = item.title
|
||||||
thumb = item.thumb
|
thumb = item.thumb
|
||||||
if state != "playing" and mediaType != "track":
|
if state != "playing" and mediaType != "track":
|
||||||
if config["display"]["remainingTime"]:
|
if config["display"]["progressMode"] == "remaining":
|
||||||
stateStrings.append(f"{formatSeconds((item.duration - viewOffset) / 1000, ':')} left")
|
stateStrings.append(f"{formatSeconds((item.duration - viewOffset) / 1000, ':')} left")
|
||||||
else:
|
else:
|
||||||
stateStrings.append(f"{formatSeconds(viewOffset / 1000, ':')} elapsed")
|
stateStrings.append(f"{formatSeconds(viewOffset / 1000, ':')} elapsed")
|
||||||
|
@ -351,10 +351,15 @@ class PlexAlertListener(threading.Thread):
|
||||||
activity["buttons"] = buttons[:2]
|
activity["buttons"] = buttons[:2]
|
||||||
if state == "playing":
|
if state == "playing":
|
||||||
currentTimestamp = int(time.time() * 1000)
|
currentTimestamp = int(time.time() * 1000)
|
||||||
if config["display"]["remainingTime"]:
|
match config["display"]["progressMode"]:
|
||||||
activity["timestamps"] = { "end": round(currentTimestamp + (item.duration - viewOffset)) }
|
case "elapsed":
|
||||||
else:
|
|
||||||
activity["timestamps"] = { "start": round(currentTimestamp - viewOffset) }
|
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:
|
if not self.discordIpcService.connected:
|
||||||
self.discordIpcService.connect()
|
self.discordIpcService.connect()
|
||||||
if self.discordIpcService.connected:
|
if self.discordIpcService.connected:
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Display(TypedDict):
|
||||||
album: bool
|
album: bool
|
||||||
year: bool
|
year: bool
|
||||||
statusIcon: bool
|
statusIcon: bool
|
||||||
remainingTime: bool
|
progressMode: str
|
||||||
paused: bool
|
paused: bool
|
||||||
posters: Posters
|
posters: Posters
|
||||||
buttons: list[Button]
|
buttons: list[Button]
|
||||||
|
|
Loading…
Reference in a new issue