diff --git a/backend/handler/metadata/hasheous_handler.py b/backend/handler/metadata/hasheous_handler.py index ba1fd0153..bb6ee4c68 100644 --- a/backend/handler/metadata/hasheous_handler.py +++ b/backend/handler/metadata/hasheous_handler.py @@ -241,13 +241,15 @@ class HasheousHandler(MetadataHandler): if file.file_size_bytes > 0 and file.is_top_level and ( - file.file_extension + UPS(platform_slug) not in ACCEPTABLE_FILE_EXTENSIONS_BY_PLATFORM_SLUG + or file.file_extension in ACCEPTABLE_FILE_EXTENSIONS_BY_PLATFORM_SLUG[UPS(platform_slug)] - if UPS(platform_slug) in ACCEPTABLE_FILE_EXTENSIONS_BY_PLATFORM_SLUG - else True ) ] + # Select the largest file by size, as it is most likely to be the main ROM file. + # This increases the accuracy of metadata lookups, since the largest file is + # expected to have the correct and complete hash values for external services. first_file = max(filtered_files, key=lambda f: f.file_size_bytes, default=None) if first_file is None: return fallback_rom diff --git a/backend/handler/metadata/ss_handler.py b/backend/handler/metadata/ss_handler.py index 99749e07a..813cf672f 100644 --- a/backend/handler/metadata/ss_handler.py +++ b/backend/handler/metadata/ss_handler.py @@ -537,13 +537,16 @@ class SSHandler(MetadataHandler): if file.file_size_bytes > 0 and file.is_top_level and ( - file.file_extension + UPS(rom.platform_slug) + not in ACCEPTABLE_FILE_EXTENSIONS_BY_PLATFORM_SLUG + or file.file_extension in ACCEPTABLE_FILE_EXTENSIONS_BY_PLATFORM_SLUG[UPS(rom.platform_slug)] - if UPS(rom.platform_slug) in ACCEPTABLE_FILE_EXTENSIONS_BY_PLATFORM_SLUG - else True ) ] + # Select the largest file by size, as it is most likely to be the main ROM file. + # This increases the accuracy of metadata lookups, since the largest file is + # expected to have the correct and complete hash values for external services. first_file = max(filtered_files, key=lambda f: f.file_size_bytes, default=None) if first_file is None: return SSRom(ss_id=None)