From 009f67e3a439d5f06904114e38c8ec0b87668a5f Mon Sep 17 00:00:00 2001 From: Dreu LaVelle Date: Sun, 4 Aug 2024 09:10:12 -0500 Subject: [PATCH] fix(tests): cleaned up tests and started normalizing handlers --- PTT/handlers.py | 35 ++++++++++++++++++++++++----------- tests/test_episodes.py | 2 +- tests/test_group.py | 5 ++--- tests/test_language.py | 1 + tests/test_main.py | 12 +++++++++--- tests/test_quality.py | 4 ++-- 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/PTT/handlers.py b/PTT/handlers.py index 9082d4f..8201899 100644 --- a/PTT/handlers.py +++ b/PTT/handlers.py @@ -42,6 +42,9 @@ def add_defaults(parser: Parser): # parser.add_handler("resolution", regex.compile(r"21600?[pi]", regex.IGNORECASE), value("4k"), {"skipIfAlreadyFound": False, "remove": True}) parser.add_handler("resolution", regex.compile(r"(?:^|\D)(\d{3,4})[pi]", regex.IGNORECASE), value("$1p"), {"remove": True}) parser.add_handler("resolution", regex.compile(r"(240|360|480|576|720|1080|2160|3840)[pi]", regex.IGNORECASE), lowercase, {"remove": True}) + + # Classify unknown resolutions with their quality counterpart. (normalize qualities to resolution) - DO NOT REMOVE HERE! + parser.add_handler("resolution", regex.compile(r"\bDVD(.*Rip|.*Mux)?\b", regex.IGNORECASE), value("480p"), {"remove": False}) # Date parser.add_handler("date", regex.compile(r"(?:\W|^)([[(]?(?:19[6-9]|20[012])[0-9]([. \-/\\])(?:0[1-9]|1[012])\2(?:0[1-9]|[12][0-9]|3[01])[])]?)(?:\W|$)"), date("YYYY MM DD"), {"remove": True}) @@ -128,11 +131,11 @@ def add_defaults(parser: Parser): parser.add_handler("quality", regex.compile(r"\b(?:BR|Blu[ .-]*Ray)[ .-]*Rip\b", regex.IGNORECASE), value("BRRip"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\bBD[ .-]*Rip\b|\bBDR\b|\bBD-RM\b|[[(]BD[\]) .,-]", regex.IGNORECASE), value("BDRip"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\b(?:HD[ .-]*)?DVD[ .-]*Rip\b", regex.IGNORECASE), value("DVDRip"), {"remove": True}) - parser.add_handler("quality", regex.compile(r"\bVHS[ .-]*Rip\b", regex.IGNORECASE), value("DVDRip"), {"remove": True}) + parser.add_handler("quality", regex.compile(r"\bVHS[ .-]*Rip?\b", regex.IGNORECASE), value("VHSRip"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\b(?:DVD?|BD|BR)?[ .-]*Scr(?:eener)?\b", regex.IGNORECASE), value("SCR"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\bP(?:re)?DVD(?:Rip)?\b", regex.IGNORECASE), value("SCR"), {"remove": True}) - parser.add_handler("quality", regex.compile(r"\bDVD(?:R\d?)?\b", regex.IGNORECASE), value("DVD"), {"remove": True}) - parser.add_handler("quality", regex.compile(r"\bVHS\b", regex.IGNORECASE), value("DVD"), {"remove": True}) + parser.add_handler("quality", regex.compile(r"\bDVD(?:R\d?|.*Mux)?\b", regex.IGNORECASE), value("DVD"), {"remove": True}) + parser.add_handler("quality", regex.compile(r"\bVHS\b", regex.IGNORECASE), value("VHS"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\bPPVRip\b", regex.IGNORECASE), value("PPVRip"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\bHD[ .-]*TV(?:Rip)?\b", regex.IGNORECASE), value("HDTV"), {"remove": True}) parser.add_handler("quality", regex.compile(r"\bDVB[ .-]*(?:Rip)?\b", regex.IGNORECASE), value("HDTV"), {"remove": True}) @@ -287,6 +290,8 @@ def handle_volumes(context): parser.add_handler("episodes", regex.compile(r"\b\d{2}[ ._-](\d{2})(?:.F)?\.\w{2,4}$"), array(integer)) parser.add_handler("episodes", regex.compile(r"(?