Better tags and fix Sonarr custom_format urls

This commit is contained in:
Johan van Eck 2025-07-27 15:04:10 +03:00
parent c9629e8b3d
commit f8026fc849
415 changed files with 3695 additions and 3438 deletions

View file

@ -7,14 +7,14 @@ from markdownify import markdownify
from utils.strings import get_name
IMPLEMENTATION_TO_TAG_MAPPING = {
"ReleaseTitleSpecification": ["Release Title"],
"ResolutionSpecification": ["Resolution"],
"SourceSpecification": ["Source"],
"LanguageSpecification": ["Language"],
"ReleaseGroupSpecification": ["Release Group"],
"IndexerFlagSpecification": ["Indexer Flag"],
"QualityModifierSpecification": ["Quality Modifier"],
"ReleaseTypeSpecification": ["Release Type"],
"ReleaseTitleSpecification": "Release Title",
"ResolutionSpecification": "Resolution",
"SourceSpecification": "Source",
"LanguageSpecification": "Language",
"ReleaseGroupSpecification": "Release Group",
"IndexerFlagSpecification": "Indexer Flag",
"QualityModifierSpecification": "Quality Modifier",
"ReleaseTypeSpecification": "Release Type",
}
IMPLEMENTATION_TO_TYPE_MAPPING = {
@ -28,9 +28,15 @@ IMPLEMENTATION_TO_TYPE_MAPPING = {
"ReleaseTypeSpecification": "release_type",
}
SERVICE_TO_TRASH_GUIDES_URL = {
"radarr": "https://trash-guides.info/Radarr/Radarr-collection-of-custom-formats",
"sonarr": "https://trash-guides.info/Sonarr/sonarr-collection-of-custom-formats",
}
def collect_custom_format(service, file_name, input_json, output_dir):
conditions = []
implementation_tags = set()
for spec in input_json.get("specifications", []):
condition = {
"name": get_name(service, spec.get("name", "")),
@ -42,8 +48,11 @@ def collect_custom_format(service, file_name, input_json, output_dir):
}
implementation = spec.get("implementation")
implementation_tags.add(IMPLEMENTATION_TO_TAG_MAPPING[implementation])
if implementation in ["ReleaseTitleSpecification", "ReleaseGroupSpecification"]:
condition["pattern"] = spec.get("name", "")
condition["pattern"] = get_name(service, spec.get("name", ""))
elif implementation in ["ResolutionSpecification"]:
condition["resolution"] = f"{spec.get('fields', {}).get('value')}p"
elif implementation in ["SourceSpecification"]:
@ -64,10 +73,10 @@ def collect_custom_format(service, file_name, input_json, output_dir):
name = input_json.get("name", "")
yml_data = {
"name": get_name(service, name),
"description": f"""[Custom format from TRaSH-Guides.](https://trash-guides.info/{service.capitalize()}/{service.capitalize()}-collection-of-custom-formats/#{file_name})
"description": f"""[Custom format from TRaSH-Guides.]({SERVICE_TO_TRASH_GUIDES_URL[service]}#{file_name})
{markdownify(input_json.get('description', ''))}""".strip(),
"tags": [*IMPLEMENTATION_TO_TAG_MAPPING[implementation], service.capitalize()],
"tags": [service.capitalize(), *implementation_tags],
"conditions": conditions,
"tests": [],
}

View file

@ -6,6 +6,7 @@ from utils.strings import get_name
# TODO: prevent duplicates by only writing unique regex patterns to files
# In some cases negations will result in a new regex pattern as of now
# NOTE: would need to keep track of all duplicate patterns so that trash_id can still be matched
def collect_regex_pattern(service, file_name, input_json, output_dir):