Skip to content

fix(screenscraper): respect region priority for multi-region ROMs#3396

Merged
gantoine merged 1 commit into
masterfrom
fix-ss-multi-region-priority
May 21, 2026
Merged

fix(screenscraper): respect region priority for multi-region ROMs#3396
gantoine merged 1 commit into
masterfrom
fix-ss-multi-region-priority

Conversation

@gantoine
Copy link
Copy Markdown
Member

Summary

  • For ROMs tagged with multiple regions (e.g. Zaxxon's Motherbase 2000 (Japan, USA) (En).zip), filename order previously decided which region's name and box art ScreenScraper returned. get_preferred_regions() now reorders the rom's filename-tagged regions by SCAN_REGION_PRIORITY before prepending them, so the user's configured preference wins among the regions the file is actually tagged as.
  • A region in SCAN_REGION_PRIORITY that the file is NOT tagged as still cannot outrank a region the file IS tagged as — this only re-sorts among filename-tagged regions.
  • Adds three new tests covering the multi-region cases.
  • Also includes a minor en_GB/en_US scan locale tweak (Total RescanComplete Rescan) that was already staged.

Test plan

  • DB_HOST=127.0.0.1 uv run pytest tests/handler/metadata/test_ss_handler.py::TestGetPreferredRegions -v (7 passed)
  • Re-scrape an affected multi-region ROM with SCAN_REGION_PRIORITY set, confirm the preferred region's name and box art are picked.

🤖 Generated with Claude Code

For ROMs tagged with multiple regions (e.g. "(Japan, USA)"), filename order
previously decided which region's name and box art won. Now reorder the rom's
filename-tagged regions by SCAN_REGION_PRIORITY before prepending, so the
user's configured preference wins among the regions the file is actually
tagged as. Untagged priority regions still cannot outrank a filename-tagged
region.

Also tweak the Total Rescan → Complete Rescan label in en_GB/en_US scan
locales.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 20, 2026 21:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts ScreenScraper region selection so multi-region ROM filename tags are reordered according to SCAN_REGION_PRIORITY, ensuring the configured preference wins among regions actually present on the ROM. Also updates the scan UI copy for the rescan type label.

Changes:

  • Reorders filename-derived region codes in get_preferred_regions() using SCAN_REGION_PRIORITY before applying fallbacks.
  • Adds tests covering multi-region priority, untagged-priority behavior, and preservation of filename order for unprioritized tags.
  • Updates en_US/en_GB scan locale text from “Total Rescan” to “Complete Rescan”.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
frontend/src/locales/en_US/scan.json Updates rescan label text in the scan types help string.
frontend/src/locales/en_GB/scan.json Updates rescan label text in the scan types help string.
backend/tests/handler/metadata/test_ss_handler.py Adds multi-region test coverage for preferred region ordering behavior.
backend/handler/metadata/ss_handler.py Sorts ROM-tagged regions by configured priority before building the provider region preference list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

Test Results (postgresql)

    1 files  ±0      1 suites  ±0   3m 47s ⏱️ -9s
1 370 tests +3  1 370 ✅ +3  0 💤 ±0  0 ❌ ±0 
1 372 runs  +3  1 372 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit fe5af3e. ± Comparison against base commit c4a1cfb.

@github-actions
Copy link
Copy Markdown
Contributor

Test Results (mariadb)

    1 files  ±0      1 suites  ±0   4m 18s ⏱️ +7s
1 370 tests +3  1 370 ✅ +3  0 💤 ±0  0 ❌ ±0 
1 372 runs  +3  1 372 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit fe5af3e. ± Comparison against base commit c4a1cfb.

@github-actions
Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
16450 11489 70% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/handler/metadata/ss_handler.py 41% 🟢
TOTAL 41% 🟢

updated for commit: fe5af3e by action🐍

@gantoine gantoine merged commit ce20d40 into master May 21, 2026
15 checks passed
@gantoine gantoine deleted the fix-ss-multi-region-priority branch May 21, 2026 00:21
pull Bot pushed a commit to dwongdev/romm that referenced this pull request May 23, 2026
A COMPLETE rescan never deleted previously downloaded asset files, and
the post-scan download steps skip work when a file already exists
(store_media_file) or when the source URL is unchanged (get_cover). This
meant covers, screenshots, manuals, and SS/gamelist/LaunchBox extended
media were reused even when a fresh fetch returned a different URL —
defeating the region-priority fix in rommapp#3396.

- scan socket: for a COMPLETE rescan of an existing ROM, remove the
  cover, manual, screenshots, and all extended media directories before
  re-fetching, so the download steps pull fresh files.
- scan_handler: reset url_cover/url_screenshots/url_manual and the
  matching path_* fields for COMPLETE rescans before the priority loops
  run, so stale DB values are nulled when no selected source supplies
  them (clearing for deselected sources falls out as a subset).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants