* added AMiABLE and PiGNUS to scene groups (#25)

* Major Code Refactor (#27)

Description
Reimplemented Profilarr from the ground up to be more reusable, in addition to implemented a few improvements. Works almost identically to before, but will be much easier to develop for going forward.

Improvements
Implements feature mentioned in Issue #11.
- Custom Formats are now automatically imported before quality profiles are imported.

* fixed 2160 remux bug (#28)

Fixed bug that was incorrectly prioritising WEBs in 2160p optimal profiles.
This commit is contained in:
santiagosayshey
2024-02-05 17:20:59 +10:30
committed by GitHub
parent 2e5cabe7ab
commit ff79de7724
33 changed files with 1124 additions and 835 deletions

View File

@@ -1,47 +1,22 @@
import yaml
import json
import shutil
import os
import exportarr # Assuming this module contains the export functions
import importarr # Assuming this module contains the import functions
from exportarr import export_custom_formats, export_quality_profiles
from importarr import import_custom_formats, import_quality_profiles
from helpers import load_config, get_app_choice
def sync_data(sync_mode=False):
# Load configuration from YAML file
with open('config.yml', 'r') as config_file:
config = yaml.safe_load(config_file)
def main():
app = get_app_choice().lower() # Convert to lowercase
config = load_config() # Load the entire configuration
# Specify the temporary path where files will be saved
temp_cf_path = './temp_directory/custom_formats'
temp_qf_path = './temp_directory/quality_profiles'
# Now app will be 'radarr' or 'sonarr', matching the keys in the config dictionary
master_instance = next((inst for inst in config['instances'][app] if inst['name'] == 'Master'), None)
extra_instances = [inst for inst in config['instances'][app] if inst['name'] != 'Master']
# Get user choice for app (radarr/sonarr)
app_choice = input("Select the app you want to sync:\n1. Radarr\n2. Sonarr\nEnter your choice (1 or 2): ").strip()
while app_choice not in ["1", "2"]:
print("Invalid input. Please enter 1 for Radarr or 2 for Sonarr.")
app_choice = input("Enter your choice (1 or 2): ").strip()
app_choice = "radarr" if app_choice == "1" else "sonarr"
instance_name = "temp"
exportarr.export_cf(app_choice, instance_name, save_path=temp_cf_path)
exportarr.export_qf(app_choice, instance_name, save_path=temp_qf_path)
# Sync with each extra installation of the chosen app
for extra_instance in config['instances'].get('extras', {}).get(app_choice, []):
print(f"Importing to instance: {extra_instance['name']}")
# Import custom formats and quality profiles to each extra instance
extra_instance['app_name'] = app_choice
importarr.import_custom_formats(extra_instance, import_path=temp_cf_path, selected_files=None, sync_mode=sync_mode)
importarr.import_quality_profiles(extra_instance, import_path=temp_qf_path, selected_files=None, sync_mode=sync_mode)
# Delete the temporary directories after the sync is complete
temp_directory = './temp_directory'
if os.path.exists(temp_directory):
shutil.rmtree(temp_directory)
print(f"Deleted temporary directory: {temp_directory}")
if master_instance:
export_custom_formats(app, [master_instance], config)
export_quality_profiles(app, [master_instance], config)
if extra_instances:
import_custom_formats(app, extra_instances)
import_quality_profiles(app, extra_instances)
if __name__ == "__main__":
# Set sync_mode to True to enable automatic selection of all files during import
sync_data(sync_mode=True)
main()