Add media_management
This commit is contained in:
parent
4798feb1c3
commit
a7cb04eea4
7 changed files with 262 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ import yaml
|
|||
from utils.custom_formats import collect_custom_formats
|
||||
from utils.regex_patterns import collect_regex_patterns
|
||||
from utils.profiles import collect_profiles
|
||||
from utils.media_management import collect_media_management
|
||||
|
||||
# Prevent aliases from showing up
|
||||
yaml.Dumper.ignore_aliases = lambda *args: True
|
||||
|
|
@ -46,6 +47,10 @@ def main():
|
|||
os.makedirs(profiles_dir, exist_ok=True)
|
||||
clear_output_dir(profiles_dir)
|
||||
|
||||
media_management_dir = os.path.join(output_dir, "media_management")
|
||||
os.makedirs(media_management_dir, exist_ok=True)
|
||||
clear_output_dir(media_management_dir)
|
||||
|
||||
for service in ["radarr", "sonarr"]:
|
||||
trash_custom_formats_dir = os.path.join(input_dir, f"{service}/cf")
|
||||
if not os.path.exists(trash_custom_formats_dir):
|
||||
|
|
@ -83,6 +88,8 @@ def main():
|
|||
trash_id_to_scoring_mapping,
|
||||
)
|
||||
|
||||
collect_media_management(input_dir, media_management_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
4
scripts/utils/mappings/misc_media_management.py
Normal file
4
scripts/utils/mappings/misc_media_management.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
MISC_MEDIA_MANAGEMENT = {
|
||||
"radarr": {"propersRepacks": "doNotPrefer", "enableMediaInfo": True},
|
||||
"sonarr": {"propersRepacks": "doNotPrefer", "enableMediaInfo": True},
|
||||
}
|
||||
113
scripts/utils/media_management.py
Normal file
113
scripts/utils/media_management.py
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
import os
|
||||
import json
|
||||
import yaml
|
||||
|
||||
from utils.mappings.misc_media_management import MISC_MEDIA_MANAGEMENT
|
||||
|
||||
BASE_NAMING_CONFIG = {
|
||||
"radarr": {
|
||||
"rename": True,
|
||||
"movieFormat": "",
|
||||
"movieFolderFormat": "",
|
||||
"replaceIllegalCharacters": False,
|
||||
"colonReplacementFormat": "smart",
|
||||
},
|
||||
"sonarr": {
|
||||
"rename": True,
|
||||
"standardEpisodeFormat": "",
|
||||
"dailyEpisodeFormat": "",
|
||||
"animeEpisodeFormat": "",
|
||||
"seriesFolderFormat": "",
|
||||
"seasonFolderFormat": "",
|
||||
"replaceIllegalCharacters": False,
|
||||
"colonReplacementFormat": 4,
|
||||
"customColonReplacementFormat": "",
|
||||
"multiEpisodeStyle": 5,
|
||||
},
|
||||
}
|
||||
BASE_QUALITY_DEFINITIONS = {"radarr": {}, "sonarr": {}}
|
||||
|
||||
|
||||
def collect_misc_config(output_dir):
|
||||
output_file = os.path.join(output_dir, "misc.yml")
|
||||
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
yaml.dump(MISC_MEDIA_MANAGEMENT, f, sort_keys=False, allow_unicode=True)
|
||||
|
||||
print(f"Generated: {output_file}")
|
||||
|
||||
|
||||
def collect_naming_formats(input_dir, output_dir):
|
||||
output_file = os.path.join(output_dir, f"naming.yml")
|
||||
new_config = BASE_NAMING_CONFIG.copy()
|
||||
|
||||
radarr_input_file_path = os.path.join(
|
||||
input_dir, "radarr", "naming", "radarr-naming.json"
|
||||
)
|
||||
with open(radarr_input_file_path, "r", encoding="utf-8") as f:
|
||||
input_json = json.load(f)
|
||||
new_config["radarr"]["movieFormat"] = input_json["file"]["standard"]
|
||||
new_config["radarr"]["movieFolderFormat"] = input_json["folder"]["default"]
|
||||
|
||||
sonarr_input_file_path = os.path.join(
|
||||
input_dir, "sonarr", "naming", "sonarr-naming.json"
|
||||
)
|
||||
with open(sonarr_input_file_path, "r", encoding="utf-8") as f:
|
||||
input_json = json.load(f)
|
||||
standard_episode_format = input_json["episodes"]["standard"]["default"]
|
||||
daily_episode_format = input_json["episodes"]["daily"]["default"]
|
||||
anime_episode_format = input_json["episodes"]["anime"]["default"]
|
||||
new_config["sonarr"]["standardEpisodeFormat"] = standard_episode_format
|
||||
new_config["sonarr"]["dailyEpisodeFormat"] = daily_episode_format
|
||||
new_config["sonarr"]["animeEpisodeFormat"] = anime_episode_format
|
||||
new_config["sonarr"]["seriesFolderFormat"] = input_json["series"]["default"]
|
||||
new_config["sonarr"]["seasonFolderFormat"] = input_json["season"]["default"]
|
||||
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
yaml.dump(new_config, sort_keys=False, allow_unicode=True, width=1000000)
|
||||
)
|
||||
|
||||
print(f"Generated: {output_file}")
|
||||
|
||||
|
||||
def collect_quality_definitions(input_dir, output_dir):
|
||||
output_structure = BASE_QUALITY_DEFINITIONS.copy()
|
||||
output_file = os.path.join(output_dir, "quality_definitions.yml")
|
||||
|
||||
radarr_input_file_path = os.path.join(
|
||||
input_dir, "radarr", "quality-size", "movie.json"
|
||||
)
|
||||
with open(radarr_input_file_path, "r", encoding="utf-8") as f:
|
||||
radarr_data = json.load(f)
|
||||
for quality in reversed(radarr_data["qualities"]):
|
||||
profilarr_quality = {
|
||||
"max": quality["max"],
|
||||
"min": quality["min"],
|
||||
"preferred": quality["preferred"],
|
||||
}
|
||||
output_structure["radarr"][quality["quality"]] = profilarr_quality
|
||||
|
||||
sonarr_input_file_path = os.path.join(
|
||||
input_dir, "sonarr", "quality-size", "series.json"
|
||||
)
|
||||
with open(sonarr_input_file_path, "r", encoding="utf-8") as f:
|
||||
sonarr_data = json.load(f)
|
||||
for quality in reversed(sonarr_data["qualities"]):
|
||||
profilarr_quality = {
|
||||
"max": quality["max"],
|
||||
"min": quality["min"],
|
||||
"preferred": quality["preferred"],
|
||||
}
|
||||
output_structure["sonarr"][quality["quality"]] = profilarr_quality
|
||||
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
yaml.dump(output_structure, f, sort_keys=False, allow_unicode=True)
|
||||
|
||||
print(f"Generated: {output_file}")
|
||||
|
||||
|
||||
def collect_media_management(input_dir, output_dir):
|
||||
collect_misc_config(output_dir)
|
||||
collect_naming_formats(input_dir, output_dir)
|
||||
collect_quality_definitions(input_dir, output_dir)
|
||||
Loading…
Add table
Add a link
Reference in a new issue