From 81dc790a0c5aa76c4e33eab0e02546383f540674 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 5 Jan 2022 10:53:25 -0800 Subject: [PATCH] Revert "Remove get_settings API command" This reverts commit c39f89356c235820362c461e0d3e7809d430541f. --- plexpy/api2.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/plexpy/api2.py b/plexpy/api2.py index cb2b862e..b6733019 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -271,6 +271,51 @@ class API2(object): return templog + def get_settings(self, key=''): + """ Gets all settings from the config file. + + ``` + Required parameters: + None + + Optional parameters: + key (str): Name of a config section to return + + Returns: + json: + {"General": {"api_enabled": true, ...} + "Advanced": {"cache_sizemb": "32", ...}, + ... + } + ``` + """ + + interface_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/') + interface_list = [name for name in os.listdir(interface_dir) if + os.path.isdir(os.path.join(interface_dir, name))] + + conf = plexpy.CONFIG._config + config = {} + + # Truthify the dict + for k, v in conf.items(): + if isinstance(v, dict): + d = {} + for kk, vv in v.items(): + if vv == '0' or vv == '1': + d[kk] = bool(vv) + else: + d[kk] = vv + config[k] = d + if k == 'General': + config[k]['interface'] = interface_dir + config[k]['interface_list'] = interface_list + + if key: + return config.get(key) + + return config + def sql(self, query=''): """ Query the Tautulli database with raw SQL. Automatically makes a backup of the database if the latest backup is older then 24h. `api_sql` must be