mirror of
https://github.com/phin05/discord-rich-presence-plex
synced 2025-02-16 13:48:26 +00:00
Version bump
This commit is contained in:
parent
929bfacaef
commit
1a7b7aad58
3 changed files with 182 additions and 168 deletions
10
.github/release-notes/v2.6.0.md
vendored
Normal file
10
.github/release-notes/v2.6.0.md
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
### Release Notes
|
||||||
|
|
||||||
|
* Added dynamic button URL placeholders for TheTVDB, Trakt, Letterboxd and MusicBrainz (#53, #68, #79)
|
||||||
|
* Added optional config property `mediaTypes` for buttons to restrict their display to specific media types (#53)
|
||||||
|
* Added support for artist/music videos (#27)
|
||||||
|
|
||||||
|
### Installation Instructions
|
||||||
|
|
||||||
|
* [Regular](https://github.com/phin05/discord-rich-presence-plex/blob/v2.6.0/README.md#installation)
|
||||||
|
* [Docker](https://github.com/phin05/discord-rich-presence-plex/blob/v2.6.0/README.md#run-with-docker)
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
name = "Discord Rich Presence for Plex"
|
name = "Discord Rich Presence for Plex"
|
||||||
version = "2.5.0"
|
version = "2.6.0"
|
||||||
|
|
||||||
plexClientID = "discord-rich-presence-plex"
|
plexClientID = "discord-rich-presence-plex"
|
||||||
discordClientID = "413407336082833418"
|
discordClientID = "413407336082833418"
|
||||||
|
|
26
core/plex.py
26
core/plex.py
|
@ -86,7 +86,7 @@ class PlexAlertListener(threading.Thread):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.logger.info("Connected to %s '%s'", self.productName, resource.name)
|
self.logger.info("Connected to %s '%s'", self.productName, resource.name)
|
||||||
self.alertListener = AlertListener(self.server, self.handleAlert, self.reconnect)
|
self.alertListener = AlertListener(self.server, self.tryHandleAlert, self.reconnect)
|
||||||
self.alertListener.start()
|
self.alertListener.start()
|
||||||
self.logger.info("Listening for alerts from user '%s'", self.listenForUser)
|
self.logger.info("Listening for alerts from user '%s'", self.listenForUser)
|
||||||
self.connectionTimeoutTimer = threading.Timer(self.connectionTimeoutTimerInterval, self.connectionTimeout)
|
self.connectionTimeoutTimer = threading.Timer(self.connectionTimeoutTimerInterval, self.connectionTimeout)
|
||||||
|
@ -143,21 +143,27 @@ class PlexAlertListener(threading.Thread):
|
||||||
self.connectionTimeoutTimer = threading.Timer(self.connectionTimeoutTimerInterval, self.connectionTimeout)
|
self.connectionTimeoutTimer = threading.Timer(self.connectionTimeoutTimerInterval, self.connectionTimeout)
|
||||||
self.connectionTimeoutTimer.start()
|
self.connectionTimeoutTimer.start()
|
||||||
|
|
||||||
def handleAlert(self, alert: models.plex.Alert) -> None:
|
def tryHandleAlert(self, alert: models.plex.Alert) -> None:
|
||||||
try:
|
try:
|
||||||
if alert["type"] == "playing" and "PlaySessionStateNotification" in alert:
|
self.handleAlert(alert)
|
||||||
|
except:
|
||||||
|
self.logger.exception("An unexpected error occured in the Plex alert handler")
|
||||||
|
|
||||||
|
def handleAlert(self, alert: models.plex.Alert) -> None:
|
||||||
|
if alert["type"] != "playing" or "PlaySessionStateNotification" not in alert:
|
||||||
|
return
|
||||||
stateNotification = alert["PlaySessionStateNotification"][0]
|
stateNotification = alert["PlaySessionStateNotification"][0]
|
||||||
state = stateNotification["state"]
|
|
||||||
sessionKey = int(stateNotification["sessionKey"])
|
|
||||||
ratingKey = int(stateNotification["ratingKey"])
|
|
||||||
viewOffset = int(stateNotification["viewOffset"])
|
|
||||||
self.logger.debug("Received alert: %s", stateNotification)
|
self.logger.debug("Received alert: %s", stateNotification)
|
||||||
|
ratingKey = int(stateNotification["ratingKey"])
|
||||||
assert self.server
|
assert self.server
|
||||||
item: PlexPartialObject = self.server.fetchItem(ratingKey)
|
item: PlexPartialObject = self.server.fetchItem(ratingKey)
|
||||||
mediaType: str = item.type
|
mediaType: str = item.type
|
||||||
if mediaType not in validMediaTypes:
|
if mediaType not in validMediaTypes:
|
||||||
self.logger.debug("Unsupported media type '%s', ignoring", mediaType)
|
self.logger.debug("Unsupported media type '%s', ignoring", mediaType)
|
||||||
return
|
return
|
||||||
|
state = stateNotification["state"]
|
||||||
|
sessionKey = int(stateNotification["sessionKey"])
|
||||||
|
viewOffset = int(stateNotification["viewOffset"])
|
||||||
try:
|
try:
|
||||||
libraryName: str = item.section().title
|
libraryName: str = item.section().title
|
||||||
except:
|
except:
|
||||||
|
@ -244,8 +250,8 @@ class PlexAlertListener(threading.Thread):
|
||||||
thumbUrl = ""
|
thumbUrl = ""
|
||||||
if thumb and config["display"]["posters"]["enabled"]:
|
if thumb and config["display"]["posters"]["enabled"]:
|
||||||
thumbUrl = getCacheKey(thumb)
|
thumbUrl = getCacheKey(thumb)
|
||||||
if not thumbUrl:
|
if not thumbUrl or not isinstance(thumbUrl, str):
|
||||||
self.logger.debug("Uploading image to Imgur")
|
self.logger.debug("Uploading poster to Imgur")
|
||||||
thumbUrl = uploadToImgur(self.server.url(thumb, True), config["display"]["posters"]["maxSize"])
|
thumbUrl = uploadToImgur(self.server.url(thumb, True), config["display"]["posters"]["maxSize"])
|
||||||
setCacheKey(thumb, thumbUrl)
|
setCacheKey(thumb, thumbUrl)
|
||||||
activity: models.discord.Activity = {
|
activity: models.discord.Activity = {
|
||||||
|
@ -310,5 +316,3 @@ class PlexAlertListener(threading.Thread):
|
||||||
self.discordIpcService.connect()
|
self.discordIpcService.connect()
|
||||||
if self.discordIpcService.connected:
|
if self.discordIpcService.connected:
|
||||||
self.discordIpcService.setActivity(activity)
|
self.discordIpcService.setActivity(activity)
|
||||||
except:
|
|
||||||
self.logger.exception("An unexpected error occured in the Plex alert handler")
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue