diff --git a/README.md b/README.md index c9d7b58..a669a27 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,7 @@ Deleting Quality Profile (2160p Optimal (Single Grab)) : SUCCESS PS Z:\Profilarr> ``` + ### Radarr and Sonarr Compatibility - You are only able to import / sync files to the app that is included in the file name (e.g. `Radarr` or `Sonarr`). @@ -308,6 +309,9 @@ PS Z:\Profilarr> - **User Interface (UI):** Development of a graphical user interface (GUI) for easier and more intuitive interaction with Profilarr. This UI will cater to users who prefer graphical over command-line interactions. - **Automatic Updates:** Implement an auto-update mechanism for Profilarr, ensuring users always have access to the latest features, improvements, and bug fixes without manual intervention. +## Known Issues +- You may encounter a `JSON Encode Error`. This occurs when the base_url is entered incorrectly. Measures have been taken to prevent this, but if you encounter this error, please check your base_url in the config.yml file. + ## Contributing - I've added a docker compose file for testing custom formats / quality profiles. Run `docker-compose up -d` to start the Radarr/ Sonarr test containers. Add your API keys to the `config.yml` file and begin testing! diff --git a/deletarr.py b/deletarr.py index 6052c69..5ded1f2 100644 --- a/deletarr.py +++ b/deletarr.py @@ -56,7 +56,7 @@ def delete_custom_formats_or_profiles(app, instance, item_type, config): Deletes either custom formats or quality profiles based on the item_type. """ api_key = instance['api_key'] - base_url = instance['base_url'] + base_url = get_url(instance) resource_type = item_type # 'customformat' or 'qualityprofile' if item_type == 'customformat': diff --git a/exportarr.py b/exportarr.py index b03c04c..d8323f4 100644 --- a/exportarr.py +++ b/exportarr.py @@ -34,7 +34,7 @@ def export_custom_formats(app, instances, config): for instance in instances: print_message(f"Exporting Custom Formats for {app.capitalize()} : {instance['name']}", 'blue') - url = instance['base_url'] + url = get_url(instance) api_key = instance['api_key'] # Get the export path from the config @@ -87,7 +87,7 @@ def create_quality_profiles_export_path(app, config): def export_quality_profiles(app, instances, config): for instance in instances: print_message(f"Exporting Quality Profiles for {app.capitalize()} : {instance['name']}", 'blue') - url = instance['base_url'] + url = get_url(instance) api_key = instance['api_key'] # Create the export directory diff --git a/helpers.py b/helpers.py index 13cadda..f1d1cdd 100644 --- a/helpers.py +++ b/helpers.py @@ -4,6 +4,7 @@ import requests from requests.exceptions import ConnectionError, Timeout, TooManyRedirects import json import sys +import re class Colors: GREEN = '\033[92m' @@ -20,6 +21,11 @@ class Apps: # Add more apps here as needed } +def get_url(instance): + url = instance['base_url'] + normalized_url = re.sub(r'/$', '', url) + return normalized_url + def print_message(message, message_type='', newline=True): config = load_config() ansi_colors = config['settings']['ansi_colors'] diff --git a/importarr.py b/importarr.py index cd6eee5..03a34e8 100644 --- a/importarr.py +++ b/importarr.py @@ -41,7 +41,7 @@ def import_custom_formats(app, instances): for instance in instances: api_key = instance['api_key'] - base_url = instance['base_url'] + base_url = get_url(instance) existing_formats = make_request('get', base_url, api_key, 'customformat') existing_names_to_id = {format['name']: format['id'] for format in existing_formats} @@ -90,7 +90,7 @@ def get_existing_profiles(base_url, api_key): def cf_import_sync(instances): for instance in instances: api_key = instance['api_key'] - base_url = instance['base_url'] + base_url = get_url(instance) resource_type = 'customformat' response = make_request('get', base_url, api_key, resource_type) @@ -179,7 +179,7 @@ def import_quality_profiles(app, instances): selected_profiles_names = user_select_profiles(all_profiles) for instance in instances: - base_url = instance['base_url'] + base_url = get_url(instance) api_key = instance['api_key'] custom_formats = instance.get('custom_formats', {}) existing_profiles = get_existing_profiles(base_url, api_key) # Retrieve existing profiles