Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from LizardByte/nightly
Browse files Browse the repository at this point in the history
Pulling nightly into master
  • Loading branch information
ReenigneArcher authored Oct 15, 2022
2 parents 90587f4 + fc10760 commit 84fdd32
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.0.5] - 2022-10-15
### Fixed
- changing timeout no longer requires a Plex Media Server restart

## [0.0.4] - 2022-10-14
### Fixed
- issue with timeout not being respected
Expand Down
31 changes: 6 additions & 25 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

# standard imports
import os
import re
import sys

Expand Down Expand Up @@ -31,8 +30,10 @@
# local imports
if sys.version_info.major < 3:
from default_prefs import default_prefs
from plex_api_helper import add_themes
else:
from .default_prefs import default_prefs
from .plex_api_helper import add_themes


def process_youtube(url):
Expand Down Expand Up @@ -89,26 +90,6 @@ def process_youtube(url):
return audio_url # return None or url found


def set_environment(key, value):
# type: (str, str) -> None
"""
Set an environment variable key to a specified value.
Parameters
----------
key : str
The variable name.
value : str
The variable value.
Examples
--------
>>> set_environment(key='plexapi_plexapi_timeout', value='180')
...
"""
os.environ[key.upper()] = value


def ValidatePrefs():
# type: () -> MessageContainer
"""
Expand Down Expand Up @@ -153,9 +134,10 @@ def ValidatePrefs():
Log.Error("Setting '%s' must be True or False; Value '%s'" % (key, Prefs[key]))
error_message += "Setting '%s' must be True or False; Value '%s'<br/>" % (key, Prefs[key])

plexapi_key = key.split('_', 1)[-1]
if plexapi_key.startswith('plexapi_'):
set_environment(key=plexapi_key, value=Prefs[key])
# special cases
if key == 'int_plexapi_plexapi_timeout' and int(Prefs[key]) <= 0:
Log.Error("Setting '%s' must be greater than 0; Value '%s'" % (key, Prefs[key]))
error_message += "Setting '%s' must be greater than 0; Value '%s'<br/>" % (key, Prefs[key])

if error_message != '':
return MessageContainer(header='Error', message=error_message)
Expand Down Expand Up @@ -376,7 +358,6 @@ def update(metadata, media, lang, force):
theme_url = process_youtube(url=yt_video_url)

if theme_url:
from plex_api_helper import add_themes # import here to allow environment variable to be fully setup
add_themes(rating_key=rating_key, theme_urls=[theme_url])

return metadata
5 changes: 3 additions & 2 deletions Contents/Code/plex_api_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import requests
from typing import Optional
import urllib3
from plexapi.server import PlexServer
import plexapi.server


def setup_plexapi():
Expand Down Expand Up @@ -47,7 +47,8 @@ def setup_plexapi():
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Disable the insecure request warning

# create the plex server object
plex = PlexServer(baseurl=plex_url, token=plex_token, session=sess)
plexapi.server.TIMEOUT = int(Prefs['int_plexapi_plexapi_timeout'])
plex = plexapi.server.PlexServer(baseurl=plex_url, token=plex_token, session=sess)

return plex

Expand Down
2 changes: 1 addition & 1 deletion Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": "int_plexapi_plexapi_timeout",
"type": "text",
"label": "PlexAPI Timeout, in seconds (requires a Plex Media Server restart)",
"label": "PlexAPI Timeout, in seconds (min: 1)",
"default": "180",
"secure": "false"
},
Expand Down
3 changes: 3 additions & 0 deletions docs/source/about/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Description
Default
``180``

Minimum
``1``

YouTube Username
^^^^^^^^^^^^^^^^

Expand Down

0 comments on commit 84fdd32

Please sign in to comment.