Skip to content

Commit 05afb3f

Browse files
committed
Fixed button matching
1 parent 8eacad5 commit 05afb3f

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

seerr/browser.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,23 @@ def check_red_buttons(driver, movie_title, normalized_seasons, confirmed_seasons
509509

510510
try:
511511
all_red_buttons_elements = driver.find_elements(By.XPATH, "//button[contains(@class, 'bg-red-900/30')]")
512-
red_buttons_elements = [button for button in all_red_buttons_elements if "Report" not in button.text]
513-
logger.info(f"Found {len(red_buttons_elements)} red button(s) (100% RD) without 'Report'. Verifying titles.")
514-
512+
# Filter out "Report" buttons and buttons that don't contain "RD (100%)"
513+
red_buttons_elements = [
514+
button for button in all_red_buttons_elements
515+
if "Report" not in button.text and "RD (100%)" in button.text
516+
]
517+
logger.info(f"Found {len(red_buttons_elements)} red button(s) with 'RD (100%)' without 'Report'. Verifying titles.")
515518
for i, red_button_element in enumerate(red_buttons_elements, start=1):
516519
if "Report" in red_button_element.text:
517520
continue
518-
logger.info(f"Checking red button {i}...")
519-
521+
522+
# Double-check that this is actually an RD (100%) button
523+
button_text = red_button_element.text.strip()
524+
if "RD (100%)" not in button_text:
525+
logger.warning(f"Red button {i} does not contain 'RD (100%)' - text: '{button_text}'. Skipping.")
526+
continue
527+
528+
logger.info(f"Checking red button {i} with text: '{button_text}'...")
520529
try:
521530
red_button_title_element = red_button_element.find_element(By.XPATH, ".//ancestor::div[contains(@class, 'border-2')]//h2")
522531
red_button_title_text = red_button_title_element.text.strip()
@@ -553,7 +562,7 @@ def check_red_buttons(driver, movie_title, normalized_seasons, confirmed_seasons
553562
episode_matched = episode_id.lower() in red_button_title_text.lower()
554563

555564
if title_matched and year_matched and (not is_tv_show or (season_matched and episode_matched)):
556-
logger.info(f"Found a match on red button {i} - {red_button_title_cleaned}. Marking as confirmed.")
565+
logger.info(f"Found a match on red button {i} - {red_button_title_cleaned} with RD (100%). Marking as confirmed.")
557566
confirmation_flag = True
558567
if is_tv_show and found_season_normalized and not episode_id:
559568
confirmed_seasons.add(found_season_normalized)
@@ -566,9 +575,9 @@ def check_red_buttons(driver, movie_title, normalized_seasons, confirmed_seasons
566575
continue
567576

568577
except NoSuchElementException:
569-
logger.info("No red buttons (100% RD) detected. Proceeding with optional fallback.")
578+
logger.info("No red buttons with 'RD (100%)' detected. Proceeding with optional fallback.")
570579

571-
return confirmation_flag, confirmed_seasons
580+
return confirmation_flag, confirmed_seasons
572581

573582
def refresh_library_stats():
574583
"""

0 commit comments

Comments
 (0)