mirror of
https://github.com/phin05/discord-rich-presence-plex
synced 2024-11-21 17:13:04 +00:00
Fixed issues with non-interactive environments
This commit is contained in:
parent
0194d5cf16
commit
7323b205cc
3 changed files with 9 additions and 3 deletions
|
@ -108,6 +108,10 @@ During runtime, the following dynamic URL placeholders will get replaced with re
|
|||
}
|
||||
```
|
||||
|
||||
## Configuration - Environment Variables
|
||||
|
||||
* `PLEX_SERVER_NAME` - Name of the Plex Media Server you wish to connect to. Used only during the initial setup (when the config file isn't present) for adding a server to the config after authentication. If this isn't set, the user is prompted for an input. In non-interactive environments, "ServerName" is used as a placeholder when this variable isn't set.
|
||||
|
||||
## Configuration - Discord
|
||||
|
||||
The "Display current activity as a status message" setting must be enabled in Discord Settings → Activity Settings → Activity Privacy.
|
||||
|
|
6
main.py
6
main.py
|
@ -51,7 +51,9 @@ try:
|
|||
}).json()
|
||||
if authCheckResponse["authToken"]:
|
||||
logger.info("Authentication successful.")
|
||||
serverName = input("Enter the name of the Plex Media Server you wish to connect to: ")
|
||||
serverName = os.environ.get("PLEX_SERVER_NAME")
|
||||
if not serverName:
|
||||
serverName = input("Enter the name of the Plex Media Server you wish to connect to: ") if sys.stdin.isatty() else "ServerName"
|
||||
config["users"].append({ "token": authCheckResponse["authToken"], "servers": [{ "name": serverName }] })
|
||||
saveConfig()
|
||||
break
|
||||
|
@ -60,7 +62,7 @@ try:
|
|||
logger.info("Authentication failed.")
|
||||
exit()
|
||||
plexAlertListeners = [PlexAlertListener(user["token"], server) for user in config["users"] for server in user["servers"]]
|
||||
if sys.stdin:
|
||||
if sys.stdin.isatty():
|
||||
while True:
|
||||
userInput = input()
|
||||
if userInput in ["exit", "quit"]:
|
||||
|
|
|
@ -2,7 +2,7 @@ import os
|
|||
import sys
|
||||
|
||||
name = "Discord Rich Presence for Plex"
|
||||
version = "2.3.3"
|
||||
version = "2.3.4"
|
||||
|
||||
plexClientID = "discord-rich-presence-plex"
|
||||
discordClientID = "413407336082833418"
|
||||
|
|
Loading…
Reference in a new issue