diff --git a/plexpy/config.py b/plexpy/config.py index 3e9862ff..1e45a234 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -487,6 +487,11 @@ class Config(object): """ Cast any value in the config to the right type or use the default """ key, definition_type, section, ini_key, default = self._define(key) self.check_section(section) + my_val = self._from_env(key, definition_type) + if my_val: + self._config[section][ini_key] = my_val + return my_val + try: my_val = definition_type(self._config[section][ini_key]) except Exception: @@ -494,6 +499,15 @@ class Config(object): self._config[section][ini_key] = my_val return my_val + def _from_env(self, key, definition_type): + """ Get key from environment variables, if it exists """ + val = os.environ.get(key) + try: + if val: + return definition_type(val) + except Exception: + return None + def write(self): """ Make a copy of the stored config and write it to the configured file """ new_config = ConfigObj(encoding="UTF-8")