Fixed Unix Path Import Issues (#32)

Fixed an issue whereby files could not be imported on a unix operating system due to inconsistencies with path capitalisation.

Closes #30, #31

Also fixed issue where added / updated counts were swapped
This commit is contained in:
santiagosayshey
2024-02-06 14:42:46 +10:30
committed by GitHub
parent ff79de7724
commit 895adc9f25
27 changed files with 821 additions and 16 deletions

View File

@@ -18,8 +18,10 @@ def prompt_export_choice():
return [options[choice] for choice in user_choice.split(',') if choice in options]
def create_export_path(export_path, app):
# Create a directory path for the export
dir_path = os.path.join(export_path, 'custom_formats', app)
# Convert app to lowercase
app = app.lower() # Ensure app is in lowercase
# Create a directory path for the export in lowercase
dir_path = os.path.join(export_path, 'custom_formats', app).lower() # Convert entire path to lowercase
# Create the directory if it doesn't exist
os.makedirs(dir_path, exist_ok=True)
@@ -30,7 +32,7 @@ def export_custom_formats(app, instances, config):
for instance in instances:
print_message(f"Exporting Custom Formats for {app} : {instance['name']}", 'blue')
print_message(f"Exporting Custom Formats for {app.capitalize()} : {instance['name']}", 'blue')
url = instance['base_url']
api_key = instance['api_key']
@@ -55,8 +57,7 @@ def export_custom_formats(app, instances, config):
all_custom_formats.append(custom_format)
successful_exports += 1 # Increment the counter if the export was successful
# Hardcode the file name as 'Custom Formats (Radarr).json'
file_name = f"Custom Formats ({app.capitalize()} - {instance['name']}).json"
file_name = f"custom formats ({app.lower()} - {instance['name'].lower()}).json"
# Save all custom formats to a single file in the export directory
try:
@@ -85,7 +86,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} : {instance['name']}...", 'blue')
print_message(f"Exporting Quality Profiles for {app.capitalize()} : {instance['name']}", 'blue')
url = instance['base_url']
api_key = instance['api_key']
@@ -103,7 +104,7 @@ def export_quality_profiles(app, instances, config):
quality_profile.pop('id', None)
# Create a file name from the quality profile name and app
file_name = f"{quality_profile['name']} ({app.capitalize()} - {instance['name']}).json"
file_name = f"{quality_profile['name']} ({app.lower()} - {instance['name'].lower()}).json"
file_name = re.sub(r'[\\/*?:"<>|]', '', file_name) # Remove invalid characters
# Save the quality profile to a file in the export directory

View File

@@ -14,8 +14,8 @@ class Colors:
class Apps:
APP_CHOICES = {
"1": "Radarr",
"2": "Sonarr",
"1": "radarr",
"2": "sonarr",
# Add more apps here as needed
}

View File

@@ -5,7 +5,7 @@ import json
def get_custom_formats(app):
config = load_config()
import_path = f"{config['settings']['import_path']}/custom_formats/{app}" # Adjusted path
import_path = f"{config['settings']['import_path']}/custom_formats/{app.lower()}" # Adjusted path
for file in os.listdir(import_path):
if fnmatch.fnmatch(file, f'*{app}*'):
return file
@@ -20,7 +20,7 @@ def process_format(format, existing_names_to_id, base_url, api_key):
if response is not None:
print_message(f"Updating custom format '{format_name}'", "yellow", newline=False)
print_message(" : SUCCESS", "green")
return 1, 0
return 0, 1
else:
print_message(f"Updating custom format '{format_name}'", "yellow", newline=False)
print_message(" : FAIL", "red", newline=False)
@@ -29,7 +29,7 @@ def process_format(format, existing_names_to_id, base_url, api_key):
if response is not None:
print_message(f"Adding custom format '{format_name}'", "blue", newline=False)
print_message(" : SUCCESS", "green")
return 0, 1
return 1, 0
else:
print_message(f"Adding custom format '{format_name}'", "blue", newline=False)
print_message(" : FAIL", "red", newline=False)
@@ -52,10 +52,10 @@ def import_custom_formats(app, instances):
continue
added_count, updated_count = 0, 0
with open(f"{config['settings']['import_path']}/custom_formats/{app}/{app_file}", 'r') as import_file:
with open(f"{config['settings']['import_path']}/custom_formats/{app.lower()}/{app_file}", 'r') as import_file:
import_formats = json.load(import_file)
print_message(f"Importing custom formats to {app} : {instance['name']}", "purple")
print_message(f"Importing custom formats to {app.capitalize()} : {instance['name']}", "purple")
print()
for format in import_formats:
@@ -188,7 +188,7 @@ def import_quality_profiles(app, instances):
print()
for profile_file in selected_profiles_names:
with open(f"{config['settings']['import_path']}/quality_profiles/{app}/{profile_file}", 'r') as file:
with open(f"{config['settings']['import_path']}/quality_profiles/{app.lower()}/{profile_file}", 'r') as file:
try:
quality_profiles = json.load(file)
except json.JSONDecodeError as e:

View File

@@ -12945,5 +12945,360 @@
]
}
]
},
{
"name": "Freeleech100",
"includeCustomFormatWhenRenaming": false,
"specifications": [
{
"name": "Freeleech100",
"implementation": "IndexerFlagSpecification",
"implementationName": "Indexer Flag",
"infoLink": "https://wiki.servarr.com/radarr/settings#custom-formats-2",
"negate": false,
"required": true,
"fields": [
{
"order": 0,
"name": "value",
"label": "Flag",
"value": 1,
"type": "select",
"advanced": false,
"selectOptions": [
{
"value": 1,
"name": "G Freeleech",
"order": 1,
"dividerAfter": false
},
{
"value": 2,
"name": "G Halfleech",
"order": 2,
"dividerAfter": false
},
{
"value": 4,
"name": "G DoubleUpload",
"order": 4,
"dividerAfter": false
},
{
"value": 8,
"name": "PTP Golden",
"order": 8,
"dividerAfter": false
},
{
"value": 16,
"name": "PTP Approved",
"order": 16,
"dividerAfter": false
},
{
"value": 32,
"name": "G Internal",
"order": 32,
"dividerAfter": false
},
{
"value": 128,
"name": "G Scene",
"order": 128,
"dividerAfter": false
},
{
"value": 256,
"name": "G Freeleech75",
"order": 256,
"dividerAfter": false
},
{
"value": 512,
"name": "G Freeleech25",
"order": 512,
"dividerAfter": false
}
],
"privacy": "normal",
"isFloat": false
}
]
}
]
},
{
"name": "Freeleech75",
"includeCustomFormatWhenRenaming": false,
"specifications": [
{
"name": "Freeleech75",
"implementation": "IndexerFlagSpecification",
"implementationName": "Indexer Flag",
"infoLink": "https://wiki.servarr.com/radarr/settings#custom-formats-2",
"negate": false,
"required": true,
"fields": [
{
"order": 0,
"name": "value",
"label": "Flag",
"value": 256,
"type": "select",
"advanced": false,
"selectOptions": [
{
"value": 1,
"name": "G Freeleech",
"order": 1,
"dividerAfter": false
},
{
"value": 2,
"name": "G Halfleech",
"order": 2,
"dividerAfter": false
},
{
"value": 4,
"name": "G DoubleUpload",
"order": 4,
"dividerAfter": false
},
{
"value": 8,
"name": "PTP Golden",
"order": 8,
"dividerAfter": false
},
{
"value": 16,
"name": "PTP Approved",
"order": 16,
"dividerAfter": false
},
{
"value": 32,
"name": "G Internal",
"order": 32,
"dividerAfter": false
},
{
"value": 128,
"name": "G Scene",
"order": 128,
"dividerAfter": false
},
{
"value": 256,
"name": "G Freeleech75",
"order": 256,
"dividerAfter": false
},
{
"value": 512,
"name": "G Freeleech25",
"order": 512,
"dividerAfter": false
}
],
"privacy": "normal",
"isFloat": false
}
]
}
]
},
{
"name": "Freeleech50",
"includeCustomFormatWhenRenaming": false,
"specifications": [
{
"name": "Freeleech50",
"implementation": "IndexerFlagSpecification",
"implementationName": "Indexer Flag",
"infoLink": "https://wiki.servarr.com/radarr/settings#custom-formats-2",
"negate": false,
"required": true,
"fields": [
{
"order": 0,
"name": "value",
"label": "Flag",
"value": 2,
"type": "select",
"advanced": false,
"selectOptions": [
{
"value": 1,
"name": "G Freeleech",
"order": 1,
"dividerAfter": false
},
{
"value": 2,
"name": "G Halfleech",
"order": 2,
"dividerAfter": false
},
{
"value": 4,
"name": "G DoubleUpload",
"order": 4,
"dividerAfter": false
},
{
"value": 8,
"name": "PTP Golden",
"order": 8,
"dividerAfter": false
},
{
"value": 16,
"name": "PTP Approved",
"order": 16,
"dividerAfter": false
},
{
"value": 32,
"name": "G Internal",
"order": 32,
"dividerAfter": false
},
{
"value": 128,
"name": "G Scene",
"order": 128,
"dividerAfter": false
},
{
"value": 256,
"name": "G Freeleech75",
"order": 256,
"dividerAfter": false
},
{
"value": 512,
"name": "G Freeleech25",
"order": 512,
"dividerAfter": false
}
],
"privacy": "normal",
"isFloat": false
}
]
}
]
},
{
"name": "Freeleech25",
"includeCustomFormatWhenRenaming": false,
"specifications": [
{
"name": "Freeleech25",
"implementation": "IndexerFlagSpecification",
"implementationName": "Indexer Flag",
"infoLink": "https://wiki.servarr.com/radarr/settings#custom-formats-2",
"negate": false,
"required": true,
"fields": [
{
"order": 0,
"name": "value",
"label": "Flag",
"value": 512,
"type": "select",
"advanced": false,
"selectOptions": [
{
"value": 1,
"name": "G Freeleech",
"order": 1,
"dividerAfter": false
},
{
"value": 2,
"name": "G Halfleech",
"order": 2,
"dividerAfter": false
},
{
"value": 4,
"name": "G DoubleUpload",
"order": 4,
"dividerAfter": false
},
{
"value": 8,
"name": "PTP Golden",
"order": 8,
"dividerAfter": false
},
{
"value": 16,
"name": "PTP Approved",
"order": 16,
"dividerAfter": false
},
{
"value": 32,
"name": "G Internal",
"order": 32,
"dividerAfter": false
},
{
"value": 128,
"name": "G Scene",
"order": 128,
"dividerAfter": false
},
{
"value": 256,
"name": "G Freeleech75",
"order": 256,
"dividerAfter": false
},
{
"value": 512,
"name": "G Freeleech25",
"order": 512,
"dividerAfter": false
}
],
"privacy": "normal",
"isFloat": false
}
]
}
]
},
{
"name": "jennaortegaUHD",
"includeCustomFormatWhenRenaming": false,
"specifications": [
{
"name": "jennaortegaUHD",
"implementation": "ReleaseGroupSpecification",
"implementationName": "Release Group",
"infoLink": "https://wiki.servarr.com/radarr/settings#custom-formats-2",
"negate": false,
"required": true,
"fields": [
{
"order": 0,
"name": "value",
"label": "Regular Expression",
"helpText": "Custom Format RegEx is Case Insensitive",
"value": "(?<=^|[\\s.-])jennaortegaUHD\\b",
"type": "textbox",
"advanced": false,
"privacy": "normal",
"isFloat": false
}
]
}
]
}
]

View File

@@ -6937,6 +6937,68 @@
"isFloat": false
}
]
},
{
"name": "WEB",
"implementation": "SourceSpecification",
"implementationName": "Source",
"infoLink": "https://wiki.servarr.com/sonarr/settings#custom-formats-2",
"negate": true,
"required": false,
"fields": [
{
"order": 0,
"name": "value",
"label": "Source",
"value": 3,
"type": "select",
"advanced": false,
"selectOptions": [
{
"value": 0,
"name": "Unknown",
"order": 0
},
{
"value": 1,
"name": "Television",
"order": 1
},
{
"value": 2,
"name": "TelevisionRaw",
"order": 2
},
{
"value": 3,
"name": "Web",
"order": 3
},
{
"value": 4,
"name": "WebRip",
"order": 4
},
{
"value": 5,
"name": "DVD",
"order": 5
},
{
"value": 6,
"name": "Bluray",
"order": 6
},
{
"value": 7,
"name": "BlurayRaw",
"order": 7
}
],
"privacy": "normal",
"isFloat": false
}
]
}
]
},
@@ -7281,7 +7343,7 @@
"name": "value",
"label": "Language",
"helpText": "Custom Format RegEx is Case Insensitive",
"value": "\\b(FraMeSToR|HQMUX|SiCFoI|playBD|RYU|ElNeekster|CiNEPHiLES|3L|EDV|Kenobi|TRiToN|HDH|NTb|Flights)\\b",
"value": "\\b(FraMeSToR|HQMUX|SiCFoI|playBD|RYU|ElNeekster|CiNEPHiLES|3L|EDV|Kenobi|TRiToN|HDH|Flights)\\b",
"type": "textbox",
"advanced": false,
"privacy": "normal",
@@ -11139,5 +11201,32 @@
]
}
]
},
{
"name": "HR",
"includeCustomFormatWhenRenaming": true,
"specifications": [
{
"name": "HR",
"implementation": "ReleaseGroupSpecification",
"implementationName": "Release Group",
"infoLink": "https://wiki.servarr.com/sonarr/settings#custom-formats-2",
"negate": false,
"required": true,
"fields": [
{
"order": 0,
"name": "value",
"label": "Language",
"helpText": "Custom Format RegEx is Case Insensitive",
"value": "(?<=^|[\\s.-])HR\\b",
"type": "textbox",
"advanced": false,
"privacy": "normal",
"isFloat": false
}
]
}
]
}
]

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 500,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -359,6 +359,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -359,6 +359,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 1000,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 140,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 500,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -366,6 +366,31 @@
"minFormatScore": 0,
"cutoffFormatScore": 1000,
"formatItems": [
{
"format": 344,
"name": "jennaortegaUHD",
"score": 0
},
{
"format": 342,
"name": "Freeleech25",
"score": 0
},
{
"format": 341,
"name": "Freeleech50",
"score": 0
},
{
"format": 340,
"name": "Freeleech75",
"score": 0
},
{
"format": 339,
"name": "Freeleech100",
"score": 0
},
{
"format": 338,
"name": "TEST FLAC",

View File

@@ -232,6 +232,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -232,6 +232,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 500,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -218,6 +218,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 0
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -218,6 +218,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 1000,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 0
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -239,6 +239,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 140,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -239,6 +239,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -239,6 +239,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 500,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -232,6 +232,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 500,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",

View File

@@ -232,6 +232,21 @@
"minFormatScore": 0,
"cutoffFormatScore": 0,
"formatItems": [
{
"format": 229,
"name": "HR",
"score": 30
},
{
"format": 228,
"name": "MAX",
"score": 0
},
{
"format": 227,
"name": "h265 (4k)",
"score": 0
},
{
"format": 226,
"name": "PCM",