From 11e9c5cb9757bc6b3c9719df70ca97324fd4e92d Mon Sep 17 00:00:00 2001 From: Profilarr Date: Mon, 6 Apr 2026 22:06:09 +0200 Subject: [PATCH] update --- scripts/utils/mappings/qualities.py | 116 +++++++++++++++++----------- scripts/utils/profiles.py | 30 ++++--- uv.lock | 18 ++--- 3 files changed, 99 insertions(+), 65 deletions(-) diff --git a/scripts/utils/mappings/qualities.py b/scripts/utils/mappings/qualities.py index 4ff4d12..945ae5c 100644 --- a/scripts/utils/mappings/qualities.py +++ b/scripts/utils/mappings/qualities.py @@ -1,212 +1,236 @@ +SERVICE_QUALITY_TO_PROFILARR_QUALITY = { + "sonarr": { + "Bluray-1080p Remux": "Remux-1080p", + "Bluray-2160p Remux": "Remux-2160p", + }, + "radarr": {}, +} + + QUALITIES = [ { "id": 1, "name": "Raw-HD", "description": "Uncompressed, high definition recorded video from airing", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 2, "name": "BR-Disk", "description": "Complete Blu-ray disc image", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 3, "name": "Remux-2160p", - "description": "4K Ultra HD Blu-ray disc content remuxed into a playable file format", + "description": + "4K Ultra HD Blu-ray disc content remuxed into a playable file format", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 4, "name": "Bluray-2160p", "description": "4K Ultra HD Blu-ray video encoded with lossy compression", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 5, "name": "WEBDL-2160p", - "description": "4K web download, untouched as released by the streaming service", + "description": + "4K web download, untouched as released by the streaming service", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 6, "name": "WEBRip-2160p", - "description": "4K web rip, either captured from a 4K WEB-DL using a capture card or re-encoded from a 4K WEB-DL", + "description": + "4K web rip, either captured from a 4K WEB-DL using a capture card or re-encoded from a 4K WEB-DL", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 7, "name": "HDTV-2160p", "description": "4K high-definition digital television capture", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 8, "name": "Remux-1080p", - "description": "1080p Blu-ray disc content remuxed into a playable file format", + "description": + "1080p Blu-ray disc content remuxed into a playable file format", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 9, "name": "WEBDL-1080p", - "description": "1080p web download, untouched as released by the streaming service", + "description": + "1080p web download, untouched as released by the streaming service", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 10, "name": "Bluray-1080p", "description": "1080p Blu-ray video encoded with lossy compression", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 11, "name": "WEBRip-1080p", - "description": "1080p web rip, either captured using a capture card or re-encoded from a WEB-DL of equal or higher resolution", + "description": + "1080p web rip, either captured using a capture card or re-encoded from a WEB-DL of equal or higher resolution", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 12, "name": "HDTV-1080p", "description": "1080p high-definition digital television capture", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 13, "name": "Bluray-720p", "description": "720p Blu-ray video encoded with lossy compression", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 14, "name": "WEBDL-720p", - "description": "720p web download, untouched as released by the streaming service", + "description": + "720p web download, untouched as released by the streaming service", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 15, "name": "WEBRip-720p", - "description": "720p web rip, either captured using a capture card or re-encoded from a WEB-DL of equal or higher resolution", + "description": + "720p web rip, either captured using a capture card or re-encoded from a WEB-DL of equal or higher resolution", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 16, "name": "HDTV-720p", "description": "720p high-definition digital television capture", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 17, "name": "Bluray-576p", "description": "576p Blu-ray video encoded with lossy compression", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 18, "name": "Bluray-480p", "description": "480p Blu-ray video encoded with lossy compression", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 19, "name": "WEBDL-480p", - "description": "480p web download, untouched as released by the streaming service", + "description": + "480p web download, untouched as released by the streaming service", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 20, "name": "WEBRip-480p", - "description": "480p web rip, either captured using a capture card or re-encoded from a WEB-DL of equal or higher resolution", + "description": + "480p web rip, either captured using a capture card or re-encoded from a WEB-DL of equal or higher resolution", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 21, "name": "DVD-R", "description": "DVD-Video disc image", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 22, "name": "DVD", "description": "Standard DVD video, usually encoded at 480p", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 23, "name": "DVDSCR", "description": "DVD screener, usually a lower quality early release", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 24, "name": "SDTV", - "description": "Standard-definition digital television capture, typically 480p or lower", + "description": + "Standard-definition digital television capture, typically 480p or lower", "radarr": True, - "sonarr": True, + "sonarr": True }, { "id": 25, "name": "Telecine", - "description": "Movie captured from a film print using a telecine machine", + "description": + "Movie captured from a film print using a telecine machine", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 26, "name": "Telesync", - "description": "Filmed in a movie theater using a professional camera, often with external audio", + "description": + "Filmed in a movie theater using a professional camera, often with external audio", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 27, "name": "REGIONAL", "description": "A release intended for a specific geographic region", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 28, "name": "WORKPRINT", - "description": "An unfinished version of a movie, often with incomplete special effects", + "description": + "An unfinished version of a movie, often with incomplete special effects", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 29, "name": "CAM", - "description": "Filmed in a movie theater using a camcorder or mobile phone", + "description": + "Filmed in a movie theater using a camcorder or mobile phone", "radarr": True, - "sonarr": False, + "sonarr": False }, { "id": 30, "name": "Unknown", "description": "Quality or source is unknown or unspecified", "radarr": True, - "sonarr": True, - }, + "sonarr": True + } ] diff --git a/scripts/utils/profiles.py b/scripts/utils/profiles.py index da99b90..19292b8 100644 --- a/scripts/utils/profiles.py +++ b/scripts/utils/profiles.py @@ -4,7 +4,7 @@ import yaml from markdownify import markdownify from utils.file_utils import iterate_json_files -from utils.mappings.qualities import QUALITIES +from utils.mappings.qualities import QUALITIES, SERVICE_QUALITY_TO_PROFILARR_QUALITY from utils.strings import get_name @@ -29,36 +29,46 @@ def _collect_profile_formats( ) -def _get_quality_id(quality_name): +def _get_quality_id(service, quality_name): + safe_quality_name = SERVICE_QUALITY_TO_PROFILARR_QUALITY[service].get( + quality_name, quality_name + ) return next( - (quality["id"] for quality in QUALITIES if quality["name"] == quality_name), - None, + ( + quality["id"] + for quality in QUALITIES + if quality["name"] == safe_quality_name + ) ) -def _collect_qualities(items): +def _collect_qualities(service, items): qualities = [] quality_collection_id = -1 for item in items: if item.get("allowed", False) is False: continue + quality_id = ( + _get_quality_id(service, item.get("name", "")) + if item.get("items") is None + else quality_collection_id + ) quality = { - "id": _get_quality_id(item.get("name", "")), + "id": quality_id, "name": item.get("name", ""), } if item.get("items") is not None: - quality["id"] = quality_collection_id quality_collection_id -= 1 quality["description"] = "" quality["qualities"] = [] for sub_item in item["items"]: quality["qualities"].append( - {"id": _get_quality_id(sub_item), "name": sub_item} + {"id": _get_quality_id(service, sub_item), "name": sub_item} ) qualities.append(quality) - return list(reversed(qualities)) + return list(qualities) def _get_upgrade_until(quality_name, profile_qualities): @@ -76,7 +86,7 @@ def _get_upgrade_until(quality_name, profile_qualities): def _collect_profile(service, input_json, output_dir, trash_id_to_scoring_mapping): # Compose YAML structure name = input_json.get("name", "") - profile_qualities = _collect_qualities(input_json.get("items", [])) + profile_qualities = _collect_qualities(service, input_json.get("items", [])) yml_data = { "name": get_name(service, name), "description": f"""[Profile from TRaSH-Guides.](https://trash-guides.info/{service.capitalize()}/{service}-setup-quality-profiles) diff --git a/uv.lock b/uv.lock index 4566a3d..c0ef9e7 100644 --- a/uv.lock +++ b/uv.lock @@ -122,11 +122,11 @@ wheels = [ [[package]] name = "isort" -version = "7.0.0" +version = "8.0.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/63/53/4f3c058e3bace40282876f9b553343376ee687f3c35a525dc79dbd450f88/isort-7.0.0.tar.gz", hash = "sha256:5513527951aadb3ac4292a41a16cbc50dd1642432f5e8c20057d414bdafb4187", size = 805049, upload-time = "2025-10-11T13:30:59.107Z" } +sdist = { url = "https://files.pythonhosted.org/packages/ef/7c/ec4ab396d31b3b395e2e999c8f46dec78c5e29209fac49d1f4dace04041d/isort-8.0.1.tar.gz", hash = "sha256:171ac4ff559cdc060bcfff550bc8404a486fee0caab245679c2abe7cb253c78d", size = 769592, upload-time = "2026-02-28T10:08:20.685Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7f/ed/e3705d6d02b4f7aea715a353c8ce193efd0b5db13e204df895d38734c244/isort-7.0.0-py3-none-any.whl", hash = "sha256:1bcabac8bc3c36c7fb7b98a76c8abb18e0f841a3ba81decac7691008592499c1", size = 94672, upload-time = "2025-10-11T13:30:57.665Z" }, + { url = "https://files.pythonhosted.org/packages/3e/95/c7c34aa53c16353c56d0b802fba48d5f5caa2cdee7958acbcb795c830416/isort-8.0.1-py3-none-any.whl", hash = "sha256:28b89bc70f751b559aeca209e6120393d43fbe2490de0559662be7a9787e3d75", size = 89733, upload-time = "2026-02-28T10:08:19.466Z" }, ] [[package]] @@ -162,11 +162,11 @@ wheels = [ [[package]] name = "platformdirs" -version = "4.9.1" +version = "4.9.4" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/6c/d5/763666321efaded11112de8b7a7f2273dd8d1e205168e73c334e54b0ab9a/platformdirs-4.9.1.tar.gz", hash = "sha256:f310f16e89c4e29117805d8328f7c10876eeff36c94eac879532812110f7d39f", size = 28392, upload-time = "2026-02-14T21:02:44.973Z" } +sdist = { url = "https://files.pythonhosted.org/packages/19/56/8d4c30c8a1d07013911a8fdbd8f89440ef9f08d07a1b50ab8ca8be5a20f9/platformdirs-4.9.4.tar.gz", hash = "sha256:1ec356301b7dc906d83f371c8f487070e99d3ccf9e501686456394622a01a934", size = 28737, upload-time = "2026-03-05T18:34:13.271Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/70/77/e8c95e95f1d4cdd88c90a96e31980df7e709e51059fac150046ad67fac63/platformdirs-4.9.1-py3-none-any.whl", hash = "sha256:61d8b967d34791c162d30d60737369cbbd77debad5b981c4bfda1842e71e0d66", size = 21307, upload-time = "2026-02-14T21:02:43.492Z" }, + { url = "https://files.pythonhosted.org/packages/63/d7/97f7e3a6abb67d8080dd406fd4df842c2be0efaf712d1c899c32a075027c/platformdirs-4.9.4-py3-none-any.whl", hash = "sha256:68a9a4619a666ea6439f2ff250c12a853cd1cbd5158d258bd824a7df6be2f868", size = 21216, upload-time = "2026-03-05T18:34:12.172Z" }, ] [[package]] @@ -217,7 +217,7 @@ wheels = [ [[package]] name = "pylint" -version = "4.0.4" +version = "4.0.5" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "astroid" }, @@ -228,9 +228,9 @@ dependencies = [ { name = "platformdirs" }, { name = "tomlkit" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/5a/d2/b081da1a8930d00e3fc06352a1d449aaf815d4982319fab5d8cdb2e9ab35/pylint-4.0.4.tar.gz", hash = "sha256:d9b71674e19b1c36d79265b5887bf8e55278cbe236c9e95d22dc82cf044fdbd2", size = 1571735, upload-time = "2025-11-30T13:29:04.315Z" } +sdist = { url = "https://files.pythonhosted.org/packages/e4/b6/74d9a8a68b8067efce8d07707fe6a236324ee1e7808d2eb3646ec8517c7d/pylint-4.0.5.tar.gz", hash = "sha256:8cd6a618df75deb013bd7eb98327a95f02a6fb839205a6bbf5456ef96afb317c", size = 1572474, upload-time = "2026-02-20T09:07:33.621Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/a6/92/d40f5d937517cc489ad848fc4414ecccc7592e4686b9071e09e64f5e378e/pylint-4.0.4-py3-none-any.whl", hash = "sha256:63e06a37d5922555ee2c20963eb42559918c20bd2b21244e4ef426e7c43b92e0", size = 536425, upload-time = "2025-11-30T13:29:02.53Z" }, + { url = "https://files.pythonhosted.org/packages/d5/6f/9ac2548e290764781f9e7e2aaf0685b086379dabfb29ca38536985471eaf/pylint-4.0.5-py3-none-any.whl", hash = "sha256:00f51c9b14a3b3ae08cff6b2cdd43f28165c78b165b628692e428fb1f8dc2cf2", size = 536694, upload-time = "2026-02-20T09:07:31.028Z" }, ] [[package]]