diff options
author | Parker M <contact@pkrm.dev> | 2023-09-17 19:20:26 -0500 |
---|---|---|
committer | Parker M <contact@pkrm.dev> | 2023-09-17 19:20:26 -0500 |
commit | 49a493fd32b545cece7b72b2af94d5f1b6d7765f (patch) | |
tree | 3408388561295a2ff46df1e675c1a9caa2e34bfe /app/initialize_variables.py | |
parent | 04a21c4f0876115acce1c6e25ab20e98d4bd8a2a (diff) |
config changes
Diffstat (limited to 'app/initialize_variables.py')
-rw-r--r-- | app/initialize_variables.py | 83 |
1 files changed, 49 insertions, 34 deletions
diff --git a/app/initialize_variables.py b/app/initialize_variables.py index 6da1c34..4832b9d 100644 --- a/app/initialize_variables.py +++ b/app/initialize_variables.py @@ -4,55 +4,70 @@ import requests supported_sms_services = ['telnyx'] - -radarr_host = os.environ['RADARR_HOST'] -radarr_api_key = os.environ['RADARR_API_KEY'] -try: - home_domain = os.environ['HOME_DOMAIN'] -except: - home_domain = None -api_number = os.environ['API_NUMBER'] -val_nums = os.environ['VALID_SENDERS'] -root_folder_path = os.environ['ROOT_FOLDER_PATH'] -sms_service = os.environ['SMS_SERVICE'] -if sms_service not in supported_sms_services: - print(f'{sms_service} is not a supported SMS service. Please choose from the supported list: {supported_sms_services}') - exit() -sms_api_key = os.environ['SMS_API_KEY'] +sms_service = str(os.environ['SMS_SERVICE']).lower() +radarr_host_url = str(os.environ['RADARR_HOST_URL']) +radarr_api_key = str(os.environ['RADARR_API_KEY']) headers = { 'Content-Type': 'application/json', 'X-Api-Key': radarr_api_key } -numbers_responses = { - '1': 1, 'one': 1, '1.': 1, - '2': 2, 'two': 2, '2.': 2, - '3': 3, 'three': 3, '3.': 3 -} - -# Open the quality_profile_id.yaml file and see if the quality_profile_id is set +# Open the config.yaml file and see if the config is set try: - with open('/data/quality_profile_id.yaml', 'r') as f: + with open('/data/config.yaml', 'r') as f: file = yaml.load(f, Loader=yaml.FullLoader) try: quality_profile_id = int(file['quality_profile_id']) + + if str(file['home_domain']) != 'null': + home_domain = str(file['home_domain']) + + api_number = str(file['api_number']) + val_nums = str(file['valid_senders']) + root_folder_path = str(file['root_folder_path']) + if sms_service not in supported_sms_services: + print(f'{sms_service} is not a supported SMS service. Please choose from the supported list: {supported_sms_services}') + exit() + + if sms_service == 'telnyx': + telnyx_api_key = str(file['telnyx_api_key']) + + value_not_set = False except: - print('quality_profile_id is not set or is invalid. Please edit the quality_profile_id.yaml file and add the quality_profile_id from one of the integer values listed within the file') + print('One or more values are not set or not set correctly within the config.yaml file. Please edit the file or refer to the docs for more information.') exit() + except FileNotFoundError: - # Create the quality_profile_id.yaml file - with open('/data/quality_profile_id.yaml', 'w') as f: - quality_profile_id = None - -if not quality_profile_id: - print('No quality_profile_id found. Please edit the quality_profile_id.yaml file and add the quality_profile_id from one of the integer values listed within the file') - data = requests.get(f'{radarr_host}/api/v3/qualityprofile', headers=headers).json() - # Open quality_profile_id.yaml and write each profile as a comment to the file - with open('/data/quality_profile_id.yaml', 'w') as f: + # Create the config.yaml file + with open('/data/config.yaml', 'w') as f: + value_not_set = True + +if value_not_set: + print('One or more values are not set or not set correctly within the config.yaml file. Please edit the file or refer to the docs for more information.') + data = requests.get(f'{radarr_host_url}/api/v3/qualityprofile', headers=headers).json() + # Open config.yaml and write each profile as a comment to the file + with open('/data/config.yaml', 'w') as f: f.write('# Quality Profile ID\'s\n') for entry in data: f.write(f'# {entry["id"]} - {entry["name"]}\n') f.write("quality_profile_id: ") - exit()
\ No newline at end of file + f.write("\n") + f.write("home_domain: null # Optional: 404/405 errors redirect to this domain, leaving as\n# null means the webserver will just return the error to the browser\n") + f.write("api_number: # International format\n") + f.write("valid_senders: # International format, comma-space separated (eg. +18005263256, +18005428741\n") + f.write("root_folder_path: # Path to the root folder where movies are downloaded to\n") + if sms_service not in supported_sms_services: + print(f'{sms_service} is not a supported SMS service. Please choose from the supported list: {supported_sms_services}') + exit() + + if sms_service == 'telnyx': + f.write("telnyx_api_key: \n") + exit() + +numbers_responses = { + '1': 1, 'one': 1, '1.': 1, + '2': 2, 'two': 2, '2.': 2, + '3': 3, 'three': 3, '3.': 3 +}
\ No newline at end of file |