Skip to content

Commit

Permalink
Test/h265 whitelist (#53)
Browse files Browse the repository at this point in the history
- Implemented test for verifying h265 whitelisted groups
- Improved readability of regex testing
- Force merge (santiagosayshey)
  • Loading branch information
santiagosayshey authored May 10, 2024
1 parent 3f1d618 commit 9b505ba
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 55 deletions.
122 changes: 122 additions & 0 deletions tests/h265verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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 h265(debug_level=0):
# Get the custom formats for "h265" from both Radarr and Sonarr
h265_radarr = get_custom_format("h265", "radarr", debug_level)
h265_sonarr = get_custom_format("h265", "sonarr", debug_level)

# Extract the regex values for verified groups
h265_value_radarr = get_regex(h265_radarr, "verified groups", debug_level)
h265_value_sonarr = get_regex(h265_sonarr, "verified groups", debug_level)

# Replace the negative lookbehind with a negative lookahead
h265_value_radarr = h265_value_radarr.replace("(?<=^|[\\s.-])", "(?:^|[\\s.-])")
h265_value_sonarr = h265_value_sonarr.replace("(?<=^|[\\s.-])", "(?:^|[\\s.-])")

if debug_level > 1:
print(f"Testing with regex: {h265_value_radarr}")

# Compare Radarr and Sonarr h265 regex values
if h265_value_radarr != h265_value_sonarr:
print("Test Failed: regex value not same.")
print(f"Radarr regex: {h265_value_radarr}")
print(f"Sonarr regex: {h265_value_sonarr}")
sys.exit(1)

radarr_good_matches = [
"The Batman (2022) (1080p HMAX WEB-DL H265 SDR DDP Atmos 5.1 English - HONE)",
"King Richard (2021) (1080p HMAX WEB-DL H265 SDR DDP Atmos 5.1 English - HONE)",
"The Survivor (2021) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - HONE)",
"Transformers (2007) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - BLAZE)",
"Significant Other (2022) (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - Yoyo)",
"The NeverEnding Story (1984) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - SiGLA)",
"Monster-in-Law (2005) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - SiGLA)",
"Rocky III (1982) (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - AnoZu)",
"Samaritan (2022) (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - GRiMM)",
"The Old Guard (2020) (1080p NF WEB-DL H265 SDR DDP Atmos 5.1 English - GRiMM)"
]
radarr_bad_matches = [
"The Tinder Swindler (2022) (1080p NF WEB-DL H265 SDR DDP Atmos 5.1 English - TEPES)",
"The Greatest Lie Ever Sold: George Floyd and the Rise of BLM (2022) (1080p WEB-DL H265 SDR AAC 2.0 English - NOGROUP)",
"Baccano! (2007) S01 (1080p BluRay H265 SDR OPUS 2.0 English - NOGROUP)",
"Bhool Bhulaiyaa 2 (2022) (1080p NF WEB-DL H265 SDR DDP 5.1 Hindi - ElecTr0n)",
"Ek Villain Returns (2022) (1080p NF WEB-DL H265 SDR DDP 5.1 Hindi - SKUI)"
]
sonarr_good_matches = [
"Minx (2022) S01 (1080p HMAX WEB-DL H265 SDR DD 5.1 English - HONE)",
"We Own This City (2022) S01E01 (1080p HMAX WEB-DL H265 SDR DD 5.1 English - HONE)",
"My Brilliant Friend (2018) S01 (1080p HMAX WEB-DL H265 SDR DD 5.1 Italian - HONE)",
"The Goldbergs (2013) S09 (1080p HULU WEB-DL H265 SDR DDP 5.1 English - BLAZE)",
"Atlanta (2016) S01 (1080p HULU WEB-DL H265 SDR DDP 5.1 English - Yoyo)",
"Friday Night Lights (2006) S01 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - SiGMA)",
"Defiance (2013) S03 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - SiGMA)",
"Happy Valley (2014) S01 (1080p iP WEB-DL H265 SDR AAC 2.0 English - HECATE)",
"Shaun the Sheep (2007) S05 (1080p iP WEB-DL H265 SDR AAC 2.0 English - HECATE)",
"Skins (2007) S01 (1080p AMZN WEB-DL H265 SDR DDP 2.0 English - DarQ)",
"Wheeler Dealers (2003) S17 (1080p AMZN WEB-DL H265 SDR DDP 2.0 English - DarQ)",
"Supernatural (2005) S04 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - AnoZu)",
"DC's Stargirl (2020) S01 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - YELLO)",
"American Horror Story (2011) S12E01 (1080p HULU WEB-DL H265 SDR DDP 5.1 English - YELLO)"
]
sonarr_bad_matches = [
"House of the Dragon (2022) S00E24 (1080p HMAX WEB-DL H265 SDR DD 2.0 English - PbP)",
"Daybreak (2019) S01 (1080p NF WEB-DL x265 SDR H265 DDP Atmos 5.1 English - t3nzin)",
"Superjail! (2008) S03 (1080p AMZN WEB-DL H265 SDR DD 5.1 English - DiNGUS)"
]


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(h265_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(h265_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(h265_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(h265_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
48 changes: 25 additions & 23 deletions tests/regex.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
# run_tests.py
import sys
from roku import roku
from h265verify import h265
# ... import other test functions

# ANSI escape codes for colors
BLUE = '\033[94m'
GREEN = '\033[92m'
RED = '\033[91m'
YELLOW = '\033[93m'
RESET = '\033[0m'

def run_tests():
tests = [
("ROKU", roku),
("h265 Verified Groups", h265)
# ... add other test functions
]

failed_tests = []
for test_name, test_func in tests:
print(f"Running test: {test_name}")
test_result, failed_good_matches, failed_bad_matches = test_func(debug_level=0)
print(f"{BLUE}=============================================={RESET}")
print(f"{BLUE}Running test: {test_name}{RESET}")
print(f"{BLUE}=============================================={RESET}\n")

test_result = test_func(debug_level=1)

if test_result:
print(f"Test passed: {test_name}\n")
print()
print(f"{GREEN}=============================================={RESET}")
print(f"{GREEN}Passed Test: {test_name}{RESET}")
print(f"{GREEN}=============================================={RESET}\n")
continue
else:
print(f"Test failed: {test_name}")
if failed_bad_matches:
print("The following terms should not have matched:")
for platform, term in failed_bad_matches:
print(f"- {platform}: {term}")
if failed_good_matches:
print("The following terms should have matched:")
for platform, term in failed_good_matches:
print(f"- {platform}: {term}")
print()
failed_tests.append((test_name, failed_good_matches, failed_bad_matches))

if failed_tests:
print("Some tests failed!")
sys.exit(1)
else:
print("All tests passed!")
sys.exit(0)
print(f"{RED}=============================================={RESET}")
print(f"{RED}Failed Test: {test_name}{RESET}")
print(f"{RED}=============================================={RESET}\n")
sys.exit(1)

if __name__ == "__main__":
run_tests()
run_tests()
71 changes: 39 additions & 32 deletions tests/roku.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import re
import sys

# ANSI escape codes for colors
GREEN = '\033[92m'
RED = '\033[91m'
RESET = '\033[0m'

def roku(debug_level=0):
# Get the custom formats for "roku" from both Radarr and Sonarr
roku_radarr = get_custom_format("roku", "radarr", debug_level)
Expand All @@ -26,65 +31,67 @@ def roku(debug_level=0):
"The.Spiderwick.Chronicles.2024.S01E06.1028.Teeth.1080p.ROKU.WEB-DL.DD5.1.H.264-playWEB",
"The Imitation Game 2014 1080p ROKU WEB-DL AAC 2 0 H 264-PiRaTeS"
]

radarr_bad_matches = [
"Ikimono no kiroku 1955 720p BluRay FLAC x264-EA.mkv"
]

sonarr_good_matches = [
"The Now S01 1080p ROKU WEB-DL DD5 1 H 264-WELP",
"The Rockford Files S01 1080p ROKU WEB-DL HE-AAC 2 0 H 264-PiRaTeS",
"50.States.of.Fright.S02E05.13.Steps.to.Hell.Washington.Part.2.1080p.ROKU.WEB-DL.DD5.1.H.264-NTb"
]

sonarr_bad_matches = [
"Avatar.The.Last.Airbender.S01E08.Avatar.Roku.Winter.Solstice.2.1080p.AMZN.WEB-DL.DD+2.0.H.264-CtrlHD",
"[HorribleSubs] Rokujouma no Shinryakusha - 01 [480p]"
]


failed_good_matches = []
failed_bad_matches = []

# Check Radarr good matches
# Print Radarr Good Matches
print("\nRadarr Releases:")
print("----------------")
print("Should Match:")
for term in radarr_good_matches:
if not re.search(roku_value_radarr, term, re.IGNORECASE):
if re.search(roku_value_radarr, term, re.IGNORECASE):
print(f" - {term}: {GREEN}Passed{RESET}")
else:
failed_good_matches.append(("Radarr", term))
print(f" - {term}: {RED}Failed{RESET}")

# Check Radarr bad matches
# Print Radarr Bad Matches
print("\nShould NOT Match:")
for term in radarr_bad_matches:
if re.search(roku_value_radarr, term, re.IGNORECASE):
if not re.search(roku_value_radarr, term, re.IGNORECASE):
print(f" - {term}: {GREEN}Passed{RESET}")
else:
failed_bad_matches.append(("Radarr", term))
print(f" - {term}: {RED}Failed{RESET}")

# Check Sonarr good matches
# Print Sonarr Good Matches
print("\nSonarr Releases:")
print("----------------")
print("Should Match:")
for term in sonarr_good_matches:
if not re.search(roku_value_sonarr, term, re.IGNORECASE):
if re.search(roku_value_sonarr, term, re.IGNORECASE):
print(f" - {term}: {GREEN}Passed{RESET}")
else:
failed_good_matches.append(("Sonarr", term))
print(f" - {term}: {RED}Failed{RESET}")

# Check Sonarr bad matches
# Print Sonarr Bad Matches
print("\nShould NOT Match:")
for term in sonarr_bad_matches:
if re.search(roku_value_sonarr, term, re.IGNORECASE):
if not re.search(roku_value_sonarr, term, re.IGNORECASE):
print(f" - {term}: {GREEN}Passed{RESET}")
else:
failed_bad_matches.append(("Sonarr", term))
print(f" - {term}: {RED}Failed{RESET}")

# Return test result as a tuple (status, failed_good_matches, failed_bad_matches)
# Determine and print overall test result
if not failed_good_matches and not failed_bad_matches:
if debug_level > 0:
print("Test Passed!")
return True, [], []
return True
else:
return False, failed_good_matches, failed_bad_matches

# Call the test function with debug level
if __name__ == "__main__":
test_result, failed_good_matches, failed_bad_matches = roku(1)
if not test_result:
print("Test Failed!")
if failed_bad_matches:
print("\nThe following terms should not have matched:")
for platform, term in failed_bad_matches:
print(f"- {platform}: {term}")
if failed_good_matches:
print("\nThe following terms should have matched:")
for platform, term in failed_good_matches:
print(f"- {platform}: {term}")
sys.exit(1)



return False

0 comments on commit 9b505ba

Please sign in to comment.