Version bump

This commit is contained in:
Phin 2024-02-11 04:07:37 +05:30
parent 929bfacaef
commit 1a7b7aad58
3 changed files with 182 additions and 168 deletions

10
.github/release-notes/v2.6.0.md vendored Normal file
View 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)

View file

@ -2,7 +2,7 @@ import os
import sys
name = "Discord Rich Presence for Plex"
version = "2.5.0"
version = "2.6.0"
plexClientID = "discord-rich-presence-plex"
discordClientID = "413407336082833418"

View file

@ -86,7 +86,7 @@ class PlexAlertListener(threading.Thread):
except:
pass
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.logger.info("Listening for alerts from user '%s'", self.listenForUser)
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.start()
def handleAlert(self, alert: models.plex.Alert) -> None:
def tryHandleAlert(self, alert: models.plex.Alert) -> None:
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]
state = stateNotification["state"]
sessionKey = int(stateNotification["sessionKey"])
ratingKey = int(stateNotification["ratingKey"])
viewOffset = int(stateNotification["viewOffset"])
self.logger.debug("Received alert: %s", stateNotification)
ratingKey = int(stateNotification["ratingKey"])
assert self.server
item: PlexPartialObject = self.server.fetchItem(ratingKey)
mediaType: str = item.type
if mediaType not in validMediaTypes:
self.logger.debug("Unsupported media type '%s', ignoring", mediaType)
return
state = stateNotification["state"]
sessionKey = int(stateNotification["sessionKey"])
viewOffset = int(stateNotification["viewOffset"])
try:
libraryName: str = item.section().title
except:
@ -244,8 +250,8 @@ class PlexAlertListener(threading.Thread):
thumbUrl = ""
if thumb and config["display"]["posters"]["enabled"]:
thumbUrl = getCacheKey(thumb)
if not thumbUrl:
self.logger.debug("Uploading image to Imgur")
if not thumbUrl or not isinstance(thumbUrl, str):
self.logger.debug("Uploading poster to Imgur")
thumbUrl = uploadToImgur(self.server.url(thumb, True), config["display"]["posters"]["maxSize"])
setCacheKey(thumb, thumbUrl)
activity: models.discord.Activity = {
@ -310,5 +316,3 @@ class PlexAlertListener(threading.Thread):
self.discordIpcService.connect()
if self.discordIpcService.connected:
self.discordIpcService.setActivity(activity)
except:
self.logger.exception("An unexpected error occured in the Plex alert handler")