From c9c2bd4e8ed7b0e97a5495da3fd3e82d4036106e Mon Sep 17 00:00:00 2001 From: wheat4714 <169086384+wheat4714@users.noreply.github.com> Date: Sun, 19 May 2024 03:45:39 +0100 Subject: [PATCH] Bugfix/AV1 (#68) - AV1 CF now correctly parses releases encoded in AV1 - Tests added to verify --------- Co-authored-by: wheat4714.usedwhensimpleloginisbanned@gmail.com Co-authored-by: santiagosayshey --- .../custom formats (radarr - master).json | 12 +- .../custom formats (sonarr - master).json | 10 +- .../1080p Balanced (radarr - master).json | 2 +- .../1080p Optimal (radarr - master).json | 2 +- ...arent (Double Grab) (radarr - master).json | 2 +- .../1080p Transparent (radarr - master).json | 2 +- ...265 HDR Transparent (radarr - master).json | 2 +- .../2160p Optimal (radarr - master).json | 2 +- ...anced (HEVC) [Beta] (radarr - master).json | 2 +- .../1080p Balanced (sonarr - master).json | 2 +- .../1080p Optimal (sonarr - master).json | 2 +- ...arent (Double Grab) (sonarr - master).json | 2 +- .../1080p Transparent (sonarr - master).json | 2 +- .../2160p Optimal (sonarr - master).json | 2 +- .../Balanced (HEVC) (sonarr - master).json | 2 +- tests/av1.py | 116 ++++++++++++++++++ tests/regex.py | 6 +- tests/utr.py | 101 --------------- 18 files changed, 143 insertions(+), 128 deletions(-) create mode 100644 tests/av1.py delete mode 100644 tests/utr.py diff --git a/imports/custom_formats/radarr/custom formats (radarr - master).json b/imports/custom_formats/radarr/custom formats (radarr - master).json index 7c1ac45..d6d48df 100644 --- a/imports/custom_formats/radarr/custom formats (radarr - master).json +++ b/imports/custom_formats/radarr/custom formats (radarr - master).json @@ -9225,14 +9225,14 @@ ] }, { - "name": "AV-1", + "name": "AV1", "includeCustomFormatWhenRenaming": false, "specifications": [ { - "name": "AV-1", - "implementation": "ReleaseGroupSpecification", - "implementationName": "Release Group", - "infoLink": "https://wiki.servarr.com/radarr/settings#custom-formats-2", + "name": "AV1", + "implementation": "ReleaseTitleSpecification", + "implementationName": "Release Title", + "infoLink": "https://wiki.servarr.com/sonarr/settings#custom-formats-2", "negate": false, "required": true, "fields": [ @@ -9241,7 +9241,7 @@ "name": "value", "label": "Regular Expression", "helpText": "Custom Format RegEx is Case Insensitive", - "value": "(?<=^|[\\s.-])AV-1\\b", + "value": "\\bAV1\\b", "type": "textbox", "advanced": false, "privacy": "normal", diff --git a/imports/custom_formats/sonarr/custom formats (sonarr - master).json b/imports/custom_formats/sonarr/custom formats (sonarr - master).json index f97ca48..d1f7377 100644 --- a/imports/custom_formats/sonarr/custom formats (sonarr - master).json +++ b/imports/custom_formats/sonarr/custom formats (sonarr - master).json @@ -6922,13 +6922,13 @@ ] }, { - "name": "AV-1", + "name": "AV1", "includeCustomFormatWhenRenaming": false, "specifications": [ { - "name": "AV-1", - "implementation": "ReleaseGroupSpecification", - "implementationName": "Release Group", + "name": "AV1", + "implementation": "ReleaseTitleSpecification", + "implementationName": "Release Title", "infoLink": "https://wiki.servarr.com/sonarr/settings#custom-formats-2", "negate": false, "required": true, @@ -6938,7 +6938,7 @@ "name": "value", "label": "Regular Expression", "helpText": "Custom Format RegEx is Case Insensitive", - "value": "(?<=^|[\\s.-])AV-1\\b", + "value": "\\bAV1\\b", "type": "textbox", "advanced": false, "privacy": "normal", diff --git a/imports/quality_profiles/radarr/1080p Balanced (radarr - master).json b/imports/quality_profiles/radarr/1080p Balanced (radarr - master).json index 9b07d6a..3387672 100644 --- a/imports/quality_profiles/radarr/1080p Balanced (radarr - master).json +++ b/imports/quality_profiles/radarr/1080p Balanced (radarr - master).json @@ -568,7 +568,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/radarr/1080p Optimal (radarr - master).json b/imports/quality_profiles/radarr/1080p Optimal (radarr - master).json index 38744b5..a53a6c4 100644 --- a/imports/quality_profiles/radarr/1080p Optimal (radarr - master).json +++ b/imports/quality_profiles/radarr/1080p Optimal (radarr - master).json @@ -561,7 +561,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/radarr/1080p Transparent (Double Grab) (radarr - master).json b/imports/quality_profiles/radarr/1080p Transparent (Double Grab) (radarr - master).json index 7659200..df09be0 100644 --- a/imports/quality_profiles/radarr/1080p Transparent (Double Grab) (radarr - master).json +++ b/imports/quality_profiles/radarr/1080p Transparent (Double Grab) (radarr - master).json @@ -568,7 +568,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/radarr/1080p Transparent (radarr - master).json b/imports/quality_profiles/radarr/1080p Transparent (radarr - master).json index 0364d28..771541d 100644 --- a/imports/quality_profiles/radarr/1080p Transparent (radarr - master).json +++ b/imports/quality_profiles/radarr/1080p Transparent (radarr - master).json @@ -568,7 +568,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/radarr/1080p x265 HDR Transparent (radarr - master).json b/imports/quality_profiles/radarr/1080p x265 HDR Transparent (radarr - master).json index 6eddd43..f507c8e 100644 --- a/imports/quality_profiles/radarr/1080p x265 HDR Transparent (radarr - master).json +++ b/imports/quality_profiles/radarr/1080p x265 HDR Transparent (radarr - master).json @@ -568,7 +568,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/radarr/2160p Optimal (radarr - master).json b/imports/quality_profiles/radarr/2160p Optimal (radarr - master).json index 9f97207..5aa4fa7 100644 --- a/imports/quality_profiles/radarr/2160p Optimal (radarr - master).json +++ b/imports/quality_profiles/radarr/2160p Optimal (radarr - master).json @@ -554,7 +554,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/radarr/Balanced (HEVC) [Beta] (radarr - master).json b/imports/quality_profiles/radarr/Balanced (HEVC) [Beta] (radarr - master).json index 3b04418..14a6d3a 100644 --- a/imports/quality_profiles/radarr/Balanced (HEVC) [Beta] (radarr - master).json +++ b/imports/quality_profiles/radarr/Balanced (HEVC) [Beta] (radarr - master).json @@ -668,7 +668,7 @@ }, { "format": 302, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/sonarr/1080p Balanced (sonarr - master).json b/imports/quality_profiles/sonarr/1080p Balanced (sonarr - master).json index 859a69e..f9ffe71 100644 --- a/imports/quality_profiles/sonarr/1080p Balanced (sonarr - master).json +++ b/imports/quality_profiles/sonarr/1080p Balanced (sonarr - master).json @@ -364,7 +364,7 @@ }, { "format": 194, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/sonarr/1080p Optimal (sonarr - master).json b/imports/quality_profiles/sonarr/1080p Optimal (sonarr - master).json index ac7e496..2112f68 100644 --- a/imports/quality_profiles/sonarr/1080p Optimal (sonarr - master).json +++ b/imports/quality_profiles/sonarr/1080p Optimal (sonarr - master).json @@ -350,7 +350,7 @@ }, { "format": 194, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/sonarr/1080p Transparent (Double Grab) (sonarr - master).json b/imports/quality_profiles/sonarr/1080p Transparent (Double Grab) (sonarr - master).json index ba5ea66..cf1f553 100644 --- a/imports/quality_profiles/sonarr/1080p Transparent (Double Grab) (sonarr - master).json +++ b/imports/quality_profiles/sonarr/1080p Transparent (Double Grab) (sonarr - master).json @@ -411,7 +411,7 @@ }, { "format": 194, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/sonarr/1080p Transparent (sonarr - master).json b/imports/quality_profiles/sonarr/1080p Transparent (sonarr - master).json index 41608e8..d9734b4 100644 --- a/imports/quality_profiles/sonarr/1080p Transparent (sonarr - master).json +++ b/imports/quality_profiles/sonarr/1080p Transparent (sonarr - master).json @@ -411,7 +411,7 @@ }, { "format": 194, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/sonarr/2160p Optimal (sonarr - master).json b/imports/quality_profiles/sonarr/2160p Optimal (sonarr - master).json index 98a54b6..7a99976 100644 --- a/imports/quality_profiles/sonarr/2160p Optimal (sonarr - master).json +++ b/imports/quality_profiles/sonarr/2160p Optimal (sonarr - master).json @@ -376,7 +376,7 @@ }, { "format": 194, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/imports/quality_profiles/sonarr/Balanced (HEVC) (sonarr - master).json b/imports/quality_profiles/sonarr/Balanced (HEVC) (sonarr - master).json index 7b0562a..71c90d9 100644 --- a/imports/quality_profiles/sonarr/Balanced (HEVC) (sonarr - master).json +++ b/imports/quality_profiles/sonarr/Balanced (HEVC) (sonarr - master).json @@ -464,7 +464,7 @@ }, { "format": 194, - "name": "AV-1", + "name": "AV1", "score": -9999 }, { diff --git a/tests/av1.py b/tests/av1.py new file mode 100644 index 0000000..67f4992 --- /dev/null +++ b/tests/av1.py @@ -0,0 +1,116 @@ +from extract import get_custom_format, get_regex +import re +import sys + +# ANSI escape codes for colors +GREEN = '\033[92m' +RED = '\033[91m' +BLUE = '\033[94m' +ORANGE = '\033[38;5;208m' +RESET = '\033[0m' + + +good_matches = [ + "HobyBuchanon.Rebecca.Vanguard.Sailor.Luna.Extreme.Sloppy.Gagging.Throat.Fuck.and.Throat.Pie.2019.12.20.1080p.AV1", + "TushyRaw.Emma.Rosie.Petite.Tight.Emma.Gets.Her.Tiny.Ass.Stretched.Out.TushyRaw.Emma.Rosie.Petite.Tight.Emma.Gets.Her.Tiny.Ass.Stretched.Out.2023.12.06.2160p.AV1.mp4", + "MILFY 24 05 15 Nikki Benz Ultimate MILF Nikki Cums Hard while Riding His Cock XXX 720p AV1 XLeech.mkv", + "MILFY 24 05 08 Medusa Fit Yoga MILF Medusa Rides Young Studs Cock All Day XXX 720p AV1 XLeech.mkv", + "Vixen 24 05 17 Blake Blossom Giselle Blanco Double Take XXX 720p AV1 XLeech.mkv", + "TouchMyWife 24 05 17 Addison Vodka Wife Wants the Younger Version XXX 720p AV1 XLeech.mkv", + "LoveHerAss 24 05 08 Clea Gaultier Big Tits Hot Ass Absolute Babe XXX 720p AV1 XLeech.mkv", + "Deeper 24 05 09 Lulu Chu Cop Shop XXX 720p AV1 XLeech.mkv", + "BreedMe 24 05 14 Payton Preslee Busty Brunette Payton Preslee XXX 720p AV1 XLeech.mkv", + "Freeze 24 05 03 Lia Lin When Shaman Calls XXX 720p AV1 XLeech.mkv", + "Oppenheimer 2023 BluRay 2160p UHD AV1 HDR10 DTS-HD MA 5.1 - PRL Waldek", + "Casino.Royale.2006.1080p.Bluray.OPUS.5.1.AV1-WhiskeyJack.mkv", + "Interstellar 2014 BluRay 2160p DTS HDMA5 1 AV1 10bit-CHD", + "Dune.Part.Two.2024.REPACK.1080p.BluRay.AV1.Opus.7.1.MULTi4-dAV1nci", + "Oppenheimer 2023 BluRay 2160p UHD AV1 HDR10 DTS-HD MA 5.1 - PRL Waldek", + "Guardians of the Galaxy Vol 3 2023 BluRay 2160p UHD AV1 HDR10 TrueHD 7.1 Atmos - PRL Waldek", + "Dune.Part.Two.2024.2160p.DV.HDR.BluRay.AV1.Opus.7.1.MULTi4-dAV1nci", + "AVATAR: THE WAY OF WATER [2022]1080p WEB DL[AV1][10 BIT][Atmos/E-AC3][RoB]", + "Godzilla.X.Kong.The.New.Empire.2024.Web-Dl.2160P.AV1", + "GREEN LANTERN EXTENDED CUT [2011]1080p BDRRip[10 BIT AV1][DTS-HD MA][RoB]", + "Resident Evil Death Island 2023 1080p English AAC AV1", + "Bird Box (2018) 1080p DS4K NF WEBRip AV1 Opus 5.1 [Retr0]", + "The Banshees of Inisherin (2022) 1080p DS4K MA WEBRip AV1 Opus 5.1 [Retr0]", + "Once Upon a Studio (2023) DS4K 1080p DSNP WEBRip AV1 Opus 5.1 [RAV1NE]", + "24 Jam Bersama Gaspar (2024) INDONESIAN DS4K 1080p NF WEBRip AV1 Opus 5.1 [RAV1NE]", + "THE HUNGER GAMES QUADRILOGY [4K UHD BDRip][10 BIT AV1][HDR][ATMOS/TrueHD][RoB]", + "AVATAR: THE WAY OF WATER [2022]1080p WEB DL[AV1][10 BIT][Atmos/E-AC3][RoB]", + "Rebel Moon Part One-A Child of Fire 2023 720p AV1-Zero00", + "[Copernicus] Chainsaw Man - S01E02 [BDRip][1080p][AV1-10bit]", + "Scavengers.Reign.S01e05.The.Demeter.Opus.AV1" +] + + +bad_matches = [ +] + +def AV1(debug_level=0): + # Get the custom formats for "AV1" from both Radarr and Sonarr + AV1_radarr = get_custom_format("AV1", "radarr", debug_level) + AV1_sonarr = get_custom_format("AV1", "sonarr", debug_level) + + # Extract the regex values for both Radarr and Sonarr using get_regex + AV1_value_radarr = get_regex(AV1_radarr, "AV1", debug_level) + AV1_value_sonarr = get_regex(AV1_sonarr, "AV1", debug_level) + + # Replace the negative lookbehind with a negative lookahead + AV1_value_radarr = AV1_value_radarr.replace(r"(?<=^|[\s.-])", r"(?:^|[\s.-])") + AV1_value_sonarr = AV1_value_sonarr.replace(r"(?<=^|[\s.-])", r"(?:^|[\s.-])") + + if debug_level > 0: + print(f"Testing with regex: {ORANGE}{AV1_value_radarr}{RESET}\n") + + # Compare Radarr and Sonarr AV1 regex values + if AV1_value_radarr != AV1_value_sonarr: + print("Test Failed: regex value not same.") + print(f"Radarr regex: {AV1_value_radarr}") + print(f"Sonarr regex: {AV1_value_sonarr}") + + good_matches_passed = [] + good_matches_failed = [] + bad_matches_passed = [] + bad_matches_failed = [] + + print("Checking good matches:") + # Test good matches + for release in good_matches: + if re.search(AV1_value_radarr, release, re.IGNORECASE): + good_matches_passed.append(release) + print(f" - {release}: {GREEN}Passed{RESET}") + else: + good_matches_failed.append(release) + print(f" - {release}: {RED}Failed{RESET}") + + print("\nChecking bad matches:") + # Test bad matches + for release in bad_matches: + if re.search(AV1_value_radarr, release, re.IGNORECASE): + bad_matches_passed.append(release) + print(f" - {release}: {RED}Failed{RESET}") + else: + bad_matches_failed.append(release) + print(f" - {release}: {GREEN}Passed{RESET}") + + print("\nFailed matches:") + if good_matches_failed or bad_matches_passed: + for release in good_matches_failed + bad_matches_passed: + print(f" - {release}") + else: + print(f"{GREEN}None, Great Job! :){RESET}") + + total_matches = len(good_matches) + len(bad_matches) + passed_matches = len(good_matches_passed) + len(bad_matches_failed) + success_rate = (passed_matches / total_matches) * 100 + + print("\nStats:") + print(f"Total: {total_matches}") + print(f"Bad: {len(bad_matches_passed) + len(good_matches_failed)}") + print(f"Rate: {success_rate:.2f}%") + + if success_rate >= 99.8: + return True + else: + return False \ No newline at end of file diff --git a/tests/regex.py b/tests/regex.py index 16efa7f..2b97b72 100644 --- a/tests/regex.py +++ b/tests/regex.py @@ -2,9 +2,9 @@ import sys from roku import roku from h265verify import h265 from qxr import qxr -from utr import utr from taoe import taoe from ralphy import Ralphy +from av1 import AV1 # ... import other test functions # ANSI escape codes for colors @@ -19,9 +19,9 @@ def run_tests(): ("ROKU", roku), ("h265 Verified Groups", h265), ("QxR Groups", qxr), - ("UTR Groups", utr), ("TAoE Groups", taoe), - ("Ralphy", Ralphy) + ("Ralphy", Ralphy), + ("AV1", AV1), # ... add other test functions ] diff --git a/tests/utr.py b/tests/utr.py deleted file mode 100644 index 7cd9f0a..0000000 --- a/tests/utr.py +++ /dev/null @@ -1,101 +0,0 @@ -from extract import get_custom_format, get_regex -import re -import sys - -# ANSI escape codes for colors -GREEN = '\033[92m' -RED = '\033[91m' -RESET = '\033[0m' - -def utr(debug_level=0): - # Define good and bad matches for Radarr and Sonarr - radarr_good_matches = [ - "Brigsby Bear (2017) (1080p BluRay x265 SDR AAC 5.1 English - Tigole UTR)", - "Risky Business (1983) (1080p BluRay x265 SDR AAC 5.1 English - FreetheFish UTR)", - "Labyrinth (1986) 30th Anniversary (1080p BluRay x265 SDR AAC 7.1 English - Tigole UTR)", - "Love Actually (2003) (1080p BluRay x265 SDR AAC 5.1 English - Tigole UTR)" - ] - radarr_bad_matches = [ - "Eva.Soda.Utroskab.med.den.første.kvinde.i.bilen.Sex.i.bilen.6462a7a8a5d9e.", - "Outrage.1950.1080p.BluRay.Flac.2.0.x265.HEVC-Nb8.mkv", - "Utro 1966 DANiSH 720p WEB-DL H 264 AAC2 0-TWA" - ] - sonarr_good_matches = [ - "The Simpsons (1989) S07 (480p DVD x265 SDR AAC 5.1 English - ImE UTR)", - "The Simpsons (1989) S14 (1080p BluRay x265 SDR AAC 5.1 English - ImE UTR)" - ] - sonarr_bad_matches = [ - "The.Outreau.Case.A.French.Nightmare.S01E01.The.Renard.Block.1080p.NF.WEB-DL.DDP5.1.H.264-NTb.mkv", - "The.Outreau.Case.A.French.Nightmare.S01.1080p.NF.WEB-DL.DDP5.1.H.264-NTb" - ] - - # Get the custom formats for "qxr" from both Radarr and Sonarr - qxr_radarr = get_custom_format("qxr", "radarr", debug_level) - qxr_sonarr = get_custom_format("qxr", "sonarr", debug_level) - - # Extract the regex values for both Radarr and Sonarr using get_regex - UTR_value_radarr = get_regex(qxr_radarr, "UTR (Title)", debug_level) - UTR_value_sonarr = get_regex(qxr_sonarr, "UTR (Title)", debug_level) - - # Replace the negative lookbehind with a negative lookahead if necessary - UTR_value_radarr = UTR_value_radarr.replace("(?<=^|[\\s.-])", "(?:^|[\\s.-])") - UTR_value_sonarr = UTR_value_sonarr.replace("(?<=^|[\\s.-])", "(?:^|[\\s.-])") - - if debug_level > 0: - print(f"Testing with regex: {UTR_value_radarr}") - - # Compare Radarr and Sonarr qxr regex values - if UTR_value_radarr != UTR_value_sonarr: - print("Test Failed: regex value not same.") - print(f"Radarr regex: {UTR_value_radarr}") - print(f"Sonarr regex: {UTR_value_sonarr}") - sys.exit(1) - - failed_good_matches = [] - failed_bad_matches = [] - - # Print Radarr Good Matches - print("\nRadarr Releases:") - print("----------------") - print("Should Match:") - for term in radarr_good_matches: - if re.search(UTR_value_radarr, term, re.IGNORECASE): - print(f" - {term}: {GREEN}Passed{RESET}") - else: - failed_good_matches.append(("Radarr", term)) - print(f" - {term}: {RED}Failed{RESET}") - - # Print Radarr Bad Matches - print("\nShould NOT Match:") - for term in radarr_bad_matches: - if not re.search(UTR_value_radarr, term, re.IGNORECASE): - print(f" - {term}: {GREEN}Passed{RESET}") - else: - failed_bad_matches.append(("Radarr", term)) - print(f" - {term}: {RED}Failed{RESET}") - - # Print Sonarr Good Matches - print("\nSonarr Releases:") - print("----------------") - print("Should Match:") - for term in sonarr_good_matches: - if re.search(UTR_value_sonarr, term, re.IGNORECASE): - print(f" - {term}: {GREEN}Passed{RESET}") - else: - failed_good_matches.append(("Sonarr", term)) - print(f" - {term}: {RED}Failed{RESET}") - - # Print Sonarr Bad Matches - print("\nShould NOT Match:") - for term in sonarr_bad_matches: - if not re.search(UTR_value_sonarr, term, re.IGNORECASE): - print(f" - {term}: {GREEN}Passed{RESET}") - else: - failed_bad_matches.append(("Sonarr", term)) - print(f" - {term}: {RED}Failed{RESET}") - - # Determine and print overall test result - if not failed_good_matches and not failed_bad_matches: - return True - else: - return False \ No newline at end of file