mirror of
https://github.com/phin05/discord-rich-presence-plex
synced 2024-11-22 01:23:02 +00:00
Tweaks
This commit is contained in:
parent
52c13511a8
commit
90ee52a265
4 changed files with 17 additions and 17 deletions
16
README.md
16
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
A Python script that displays your [Plex](https://www.plex.tv) status on [Discord](https://discord.com) using [Rich Presence](https://discord.com/developers/docs/rich-presence/how-to).
|
||||
|
||||
Current Version: 2.1.0
|
||||
Current Version: 2.1.1
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
@ -22,16 +22,16 @@ The script must be running on the same machine as your Discord client.
|
|||
### Reference
|
||||
|
||||
* `logging`
|
||||
* `debug` (default: `true`) - Outputs additional debug-helpful information to the console if enabled.
|
||||
* `debug` (boolean, default: `true`) - Outputs additional debug-helpful information to the console if enabled.
|
||||
* `display`
|
||||
* `useRemainingTime` (default: `false`) - Displays your media's remaining time instead of elapsed time in your Rich Presence if enabled.
|
||||
* `useRemainingTime` (boolean, default: `false`) - Displays your media's remaining time instead of elapsed time in your Rich Presence if enabled.
|
||||
* `users` (list)
|
||||
* `token` - An access token associated with your Plex account. ([X-Plex-Token](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token), [Authenticating with Plex](https://forums.plex.tv/t/authenticating-with-plex/609370))
|
||||
* `token` (string) - An access token associated with your Plex account. ([X-Plex-Token](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token), [Authenticating with Plex](https://forums.plex.tv/t/authenticating-with-plex/609370))
|
||||
* `servers` (list)
|
||||
* `name` - Name of the Plex Media Server you wish to connect to.
|
||||
* `listenForUser` (optional) - The script will respond to alerts originating only from this username. Defaults to the parent user's username if not set.
|
||||
* `blacklistedLibraries` (optional list) - Alerts originating from libraries in this list are ignored.
|
||||
* `whitelistedLibraries` (optional list) - If set, alerts originating from libraries that are not in this list are ignored.
|
||||
* `name` (string) - Name of the Plex Media Server you wish to connect to.
|
||||
* `listenForUser` (string, optional) - The script will respond to alerts originating only from this username. Defaults to the parent user's username if not set.
|
||||
* `blacklistedLibraries` (list, optional) - Alerts originating from libraries in this list are ignored.
|
||||
* `whitelistedLibraries` (list, optional) - If set, alerts originating from libraries that are not in this list are ignored.
|
||||
|
||||
### Example
|
||||
|
||||
|
|
7
main.py
7
main.py
|
@ -23,9 +23,9 @@ if len(config["users"]) == 0:
|
|||
}).json()
|
||||
logger.info("Open the below URL in your web browser and sign in:")
|
||||
logger.info("https://app.plex.tv/auth#?clientID=%s&code=%s&context%%5Bdevice%%5D%%5Bproduct%%5D=%s", plexClientID, response["code"], urllib.parse.quote(name))
|
||||
for _ in range(10):
|
||||
time.sleep(5)
|
||||
logger.info("Checking whether authentication was successful...")
|
||||
time.sleep(5)
|
||||
logger.info("Checking whether authentication is successful...")
|
||||
for _ in range(120):
|
||||
authCheckResponse = requests.get(f"https://plex.tv/api/v2/pins/{response['id']}.json?code={response['code']}", headers = {
|
||||
"X-Plex-Client-Identifier": plexClientID,
|
||||
}).json()
|
||||
|
@ -35,6 +35,7 @@ if len(config["users"]) == 0:
|
|||
config["users"].append({ "token": authCheckResponse["authToken"], "servers": [{ "name": serverName }] })
|
||||
configService.saveConfig()
|
||||
break
|
||||
time.sleep(5)
|
||||
else:
|
||||
logger.info("Authentication failed.")
|
||||
exit()
|
||||
|
|
|
@ -156,13 +156,12 @@ class PlexAlertListener:
|
|||
self.logger.debug("%s, Session Key: %s, Usernames: %s", session, session.sessionKey, session.usernames)
|
||||
if session.sessionKey == sessionKey:
|
||||
self.logger.debug("Session found")
|
||||
sessionUsername = session.usernames[0].lower()
|
||||
if sessionUsername == self.listenForUser:
|
||||
sessionUsername = session.usernames[0]
|
||||
if sessionUsername.lower() == self.listenForUser.lower():
|
||||
self.logger.debug("Username \"%s\" matches \"%s\", continuing", sessionUsername, self.listenForUser)
|
||||
break
|
||||
else:
|
||||
self.logger.debug("Username \"%s\" doesn't match \"%s\", ignoring", sessionUsername, self.listenForUser)
|
||||
return
|
||||
self.logger.debug("Username \"%s\" doesn't match \"%s\", ignoring", sessionUsername, self.listenForUser)
|
||||
return
|
||||
else:
|
||||
self.logger.debug("No matching session found, ignoring")
|
||||
return
|
||||
|
|
|
@ -2,7 +2,7 @@ import sys
|
|||
import os
|
||||
|
||||
name = "Discord Rich Presence for Plex"
|
||||
version = "2.1.0"
|
||||
version = "2.1.1"
|
||||
plexClientID = "discord-rich-presence-plex"
|
||||
isUnix = sys.platform in ["linux", "darwin"]
|
||||
processID = os.getpid()
|
||||
|
|
Loading…
Reference in a new issue