mirror of
https://github.com/phin05/discord-rich-presence-plex
synced 2024-11-24 18:43:02 +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
|
## Configuration - Discord
|
||||||
|
|
||||||
The "Display current activity as a status message" setting must be enabled in Discord Settings → Activity Settings → Activity Privacy.
|
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()
|
}).json()
|
||||||
if authCheckResponse["authToken"]:
|
if authCheckResponse["authToken"]:
|
||||||
logger.info("Authentication successful.")
|
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 }] })
|
config["users"].append({ "token": authCheckResponse["authToken"], "servers": [{ "name": serverName }] })
|
||||||
saveConfig()
|
saveConfig()
|
||||||
break
|
break
|
||||||
|
@ -60,7 +62,7 @@ try:
|
||||||
logger.info("Authentication failed.")
|
logger.info("Authentication failed.")
|
||||||
exit()
|
exit()
|
||||||
plexAlertListeners = [PlexAlertListener(user["token"], server) for user in config["users"] for server in user["servers"]]
|
plexAlertListeners = [PlexAlertListener(user["token"], server) for user in config["users"] for server in user["servers"]]
|
||||||
if sys.stdin:
|
if sys.stdin.isatty():
|
||||||
while True:
|
while True:
|
||||||
userInput = input()
|
userInput = input()
|
||||||
if userInput in ["exit", "quit"]:
|
if userInput in ["exit", "quit"]:
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
name = "Discord Rich Presence for Plex"
|
name = "Discord Rich Presence for Plex"
|
||||||
version = "2.3.3"
|
version = "2.3.4"
|
||||||
|
|
||||||
plexClientID = "discord-rich-presence-plex"
|
plexClientID = "discord-rich-presence-plex"
|
||||||
discordClientID = "413407336082833418"
|
discordClientID = "413407336082833418"
|
||||||
|
|
Loading…
Reference in a new issue