feat: Adds jellyfin external URL and timeout gh-13
- Adds Jellyfin external URL config option - URL to send to users if different from server URL. - Adds Jellyfin server setup timeout after 5 seconds, and response delaying so discord bot doesn't timeout task: gh-13
This commit is contained in:
@@ -90,6 +90,14 @@ try:
|
||||
except:
|
||||
USE_PLEX = False
|
||||
|
||||
try:
|
||||
JELLYFIN_EXTERNAL_URL = config.get(BOT_SECTION, "jellyfin_external_url")
|
||||
if not JELLYFIN_EXTERNAL_URL:
|
||||
JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL
|
||||
except:
|
||||
JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL
|
||||
print("Could not get Jellyfin external url. Defaulting to server url.")
|
||||
|
||||
if USE_PLEX and plex_configured:
|
||||
try:
|
||||
print("Connecting to Plex......")
|
||||
@@ -296,7 +304,7 @@ class app(commands.Cog):
|
||||
db.save_user_jellyfin(str(after.id), username)
|
||||
await asyncio.sleep(5)
|
||||
await embedcustom(after, "You have been added to Jellyfin!", {'Username': username, 'Password': f"||{password}||"})
|
||||
await embedinfo(after, f"Go to {JELLYFIN_SERVER_URL} to log in!")
|
||||
await embedinfo(after, f"Go to {JELLYFIN_EXTERNAL_URL} to log in!")
|
||||
else:
|
||||
await embedinfo(after, 'There was an error adding this user to Jellyfin. Message Server Admin.')
|
||||
jellyfin_processed = True
|
||||
|
||||
@@ -12,7 +12,7 @@ config = configparser.ConfigParser()
|
||||
CONFIG_KEYS = ['username', 'password', 'discord_bot_token', 'plex_user', 'plex_pass',
|
||||
'plex_roles', 'plex_server_name', 'plex_libs', 'owner_id', 'channel_id',
|
||||
'auto_remove_user', 'jellyfin_api_key', 'jellyfin_server_url', 'jellyfin_roles',
|
||||
'jellyfin_libs', 'plex_enabled', 'jellyfin_enabled']
|
||||
'jellyfin_libs', 'plex_enabled', 'jellyfin_enabled', 'jellyfin_external_url']
|
||||
|
||||
# settings
|
||||
Discord_bot_token = ""
|
||||
@@ -96,6 +96,14 @@ except:
|
||||
print("Could not load Jellyfin config")
|
||||
jellyfin_configured = False
|
||||
|
||||
try:
|
||||
JELLYFIN_EXTERNAL_URL = config.get(BOT_SECTION, "jellyfin_external_url")
|
||||
if not JELLYFIN_EXTERNAL_URL:
|
||||
JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL
|
||||
except:
|
||||
JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL
|
||||
print("Could not get Jellyfin external url. Defaulting to server url.")
|
||||
|
||||
# Get Jellyfin roles config
|
||||
try:
|
||||
jellyfin_roles = config.get(BOT_SECTION, 'jellyfin_roles')
|
||||
|
||||
@@ -164,12 +164,12 @@ def get_config(jellyfin_url, jellyfin_api_key):
|
||||
url = f"{jellyfin_url}/System/Configuration"
|
||||
|
||||
querystring = {"api_key":jellyfin_api_key}
|
||||
response = requests.request("GET", url, params=querystring)
|
||||
response = requests.request("GET", url, params=querystring, timeout=5)
|
||||
return response.json()
|
||||
|
||||
def get_status(jellyfin_url, jellyfin_api_key):
|
||||
url = f"{jellyfin_url}/System/Configuration"
|
||||
|
||||
querystring = {"api_key":jellyfin_api_key}
|
||||
response = requests.request("GET", url, params=querystring)
|
||||
response = requests.request("GET", url, params=querystring, timeout=5)
|
||||
return response.status_code
|
||||
@@ -18,11 +18,11 @@ async def embedcustom(recipient, title, fields, ephemeral=True):
|
||||
async def send_info(recipient, message, ephemeral=True):
|
||||
if isinstance(recipient, discord.InteractionResponse):
|
||||
await recipient.send_message(message, ephemeral=ephemeral)
|
||||
elif isinstance(recipient, discord.User) or isinstance(recipient, discord.member.Member):
|
||||
elif isinstance(recipient, discord.User) or isinstance(recipient, discord.member.Member) or isinstance(recipient, discord.Webhook):
|
||||
await recipient.send(message)
|
||||
|
||||
async def send_embed(recipient, embed, ephemeral=True):
|
||||
if isinstance(recipient, discord.User) or isinstance(recipient, discord.member.Member):
|
||||
if isinstance(recipient, discord.User) or isinstance(recipient, discord.member.Member) or isinstance(recipient, discord.Webhook):
|
||||
await recipient.send(embed=embed)
|
||||
elif isinstance(recipient, discord.InteractionResponse):
|
||||
await recipient.send_message(embed=embed, ephemeral = ephemeral)
|
||||
Reference in New Issue
Block a user