From 54214e1adff6a8f93d4f80938a870ae94ab298cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= Date: Sat, 9 Mar 2024 19:27:28 +0100 Subject: [PATCH 01/14] Normalize names when looking for exact matches in IGDB Removes diacritics, accents and articles from rom names when comparing exact matches --- backend/handler/igdb_handler.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index 6388d1474..ffc45a9ca 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -213,6 +213,23 @@ class IGDBHandler: return res.json() + @staticmethod + def _normalize_rom_name(name: str) -> str: + # Convert to lower case, replace underscores with spaces + name = name.lower() + name = re.sub(r'_', ' ', name) + + # Remove leading and trailing articles + name = re.sub(r'^(a|an|the)\b', '', name) + name = re.sub(r',\b(a|an|the)\b', '', name) + + # Remove special characters and punctuation + converted_name = ' '.join((re.findall(r'\w+', name))) # only keep words, no special characters or punctuation + normalized_name = unicodedata.normalize('NFD', converted_name) # convert to normal form + canonical_form = ''.join([c for c in normalized_name if not unicodedata.combining(c)]) # remove accents + + return canonical_form.strip() + @staticmethod def _normalize_search_term(search_term: str) -> str: return ( @@ -253,6 +270,8 @@ class IGDBHandler: for rom in roms if rom["name"].lower() == search_term.lower() or rom["slug"].lower() == search_term.lower() + or self._normalize_rom_name(rom["name"]) == self._normalize_rom_name(search_term) + or self._normalize_rom_name(rom["slug"]) == self._normalize_rom_name(search_term) ] return pydash.get(exact_matches or roms, "[0]", {}) From 3d7426aaef37f228981fda7dc71a1e4671b2dd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= Date: Sat, 9 Mar 2024 19:35:01 +0100 Subject: [PATCH 02/14] Ignore apostrophes and quotes when normalizing rom names --- backend/handler/igdb_handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index ffc45a9ca..73a2ae310 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -219,6 +219,9 @@ class IGDBHandler: name = name.lower() name = re.sub(r'_', ' ', name) + # Remove apostrophes and quotes + name = re.sub(r'[\'\"]', '', name) + # Remove leading and trailing articles name = re.sub(r'^(a|an|the)\b', '', name) name = re.sub(r',\b(a|an|the)\b', '', name) From 18cb3be7e013d64049178611bdc17a962866fe13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= Date: Sat, 9 Mar 2024 22:04:24 +0100 Subject: [PATCH 03/14] Remove _normalize_rom_name from slug comparison --- backend/handler/igdb_handler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index 73a2ae310..df0b08045 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -274,7 +274,6 @@ class IGDBHandler: if rom["name"].lower() == search_term.lower() or rom["slug"].lower() == search_term.lower() or self._normalize_rom_name(rom["name"]) == self._normalize_rom_name(search_term) - or self._normalize_rom_name(rom["slug"]) == self._normalize_rom_name(search_term) ] return pydash.get(exact_matches or roms, "[0]", {}) From 401498bf2af29626c88968668b076a1927e6e48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= Date: Sat, 9 Mar 2024 22:16:14 +0100 Subject: [PATCH 04/14] Import unicodedata Forgot this step, my bad. --- backend/handler/igdb_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index df0b08045..73c9ad833 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -8,6 +8,7 @@ from typing import Final, Optional import pydash import requests +import unicodedata import xmltodict from config import IGDB_CLIENT_ID, IGDB_CLIENT_SECRET from fastapi import HTTPException, status From b3f55dbe5555109ce1ef7ed174615f5e37c941ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= Date: Sun, 10 Mar 2024 09:28:23 +0100 Subject: [PATCH 05/14] Remove all whitespace in normalize ROM name Given how the search term determines the results, then spaces in the name shouldnt matter anyway. This should be more flexible with rom names using special characters within words (if there are any) i.e. "Game 1/2", "Game 12" and "Game 1 2" will all be equal --- backend/handler/igdb_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index 73c9ad833..c5a1e98d2 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -228,11 +228,11 @@ class IGDBHandler: name = re.sub(r',\b(a|an|the)\b', '', name) # Remove special characters and punctuation - converted_name = ' '.join((re.findall(r'\w+', name))) # only keep words, no special characters or punctuation + converted_name = ''.join((re.findall(r'\w+', name))) # only keep words, no special characters or punctuation normalized_name = unicodedata.normalize('NFD', converted_name) # convert to normal form canonical_form = ''.join([c for c in normalized_name if not unicodedata.combining(c)]) # remove accents - return canonical_form.strip() + return canonical_form @staticmethod def _normalize_search_term(search_term: str) -> str: From af48893363d88f8f120296b076d97ced42ea02f8 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 14 Mar 2024 13:13:02 -0400 Subject: [PATCH 06/14] Add famicon disk system to emulatorj --- frontend/src/utils/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 95b64639f..73e3c8d25 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -108,7 +108,7 @@ export function regionToEmoji(region: string) { return "🇨🇳"; case "e": case "eu": - case "eur": + case "eur": case "europe": return "🇪🇺"; case "f": @@ -261,6 +261,7 @@ export const platformSlugEJSCoreMap = { "neo-geo-pocket-color": "mednafen_ngp", nes: "fceumm", famicom: "fceumm", + fds: "fceumm", "game-televisison": "fceumm", "new-style-nes": "fceumm", // n64: "mupen64plus_next", Disabled until emujs 4.0.12 is released @@ -304,6 +305,6 @@ export const platformSlugEJSCoreMap = { "turbografx16--1": "mednafen_pce", virtualboy: "beetle_vb", wonderswan: "mednafen_wswan", - "swancrystal": "mednafen_wswan", + swancrystal: "mednafen_wswan", "wonderswan-color": "mednafen_wswan", } as const; From 55c86355bd8d10609a2dea7b3a0994c9a036e3ae Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 14 Mar 2024 13:57:35 -0400 Subject: [PATCH 07/14] Normalize exact matches on search --- backend/handler/igdb_handler.py | 40 ++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index 6388d1474..fc18e31fd 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -4,6 +4,7 @@ import os import re import sys import time +import unicodedata from typing import Final, Optional import pydash @@ -166,7 +167,6 @@ class IGDBHandler: return wrapper - def _request(self, url: str, data: str, timeout: int = 120) -> list: try: res = requests.post( @@ -227,6 +227,34 @@ class IGDBHandler: def _normalize_cover_url(url: str) -> str: return f"https:{url.replace('https:', '')}" if url != "" else "" + # This is expensive, so it should be used sparingly + @staticmethod + def _normalize_exact_match(name: str) -> str: + name = ( + name.lower() # Convert to lower case, + .replace("_", " ") # Replace underscores with spaces + .replace("'", "") # Remove single quotes + .replace('"', "") # Remove double quotes + .strip() # Remove leading and trailing spaces + ) + + # Remove leading and trailing articles + name = re.sub(r"^(a|an|the)\b", "", name) + name = re.sub(r",\b(a|an|the)\b", "", name) + + # Remove special characters and punctuation + converted_name = "".join((re.findall(r"\w+", name))) + + # Convert to normal form + normalized_name = unicodedata.normalize("NFD", converted_name) + + # Remove accents + canonical_form = "".join( + [c for c in normalized_name if not unicodedata.combining(c)] + ) + + return canonical_form + def _search_rom( self, search_term: str, platform_idgb_id: int, category: int = 0 ) -> dict: @@ -251,8 +279,14 @@ class IGDBHandler: exact_matches = [ rom for rom in roms - if rom["name"].lower() == search_term.lower() - or rom["slug"].lower() == search_term.lower() + if ( + rom["name"].lower() == search_term.lower() + or rom["slug"].lower() == search_term.lower() + or ( + self._normalize_exact_match(rom["name"]) + == self._normalize_exact_match(search_term) + ) + ) ] return pydash.get(exact_matches or roms, "[0]", {}) From ee025b33c6b44f71fdb6729a3af7fb053745ec51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= <44143748+sondregronas@users.noreply.github.com> Date: Thu, 14 Mar 2024 22:17:28 +0100 Subject: [PATCH 08/14] Rebase into normalize-exact-matches --- backend/handler/igdb_handler.py | 11 ++++++++--- frontend/src/utils/index.ts | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index c5a1e98d2..9527c6f3a 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -272,9 +272,14 @@ class IGDBHandler: exact_matches = [ rom for rom in roms - if rom["name"].lower() == search_term.lower() - or rom["slug"].lower() == search_term.lower() - or self._normalize_rom_name(rom["name"]) == self._normalize_rom_name(search_term) + if ( + rom["name"].lower() == search_term.lower() + or rom["slug"].lower() == search_term.lower() + or ( + self._normalize_exact_match(rom["name"]) + == self._normalize_exact_match(search_term) + ) + ) ] return pydash.get(exact_matches or roms, "[0]", {}) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 73e3c8d25..95b64639f 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -108,7 +108,7 @@ export function regionToEmoji(region: string) { return "🇨🇳"; case "e": case "eu": - case "eur": + case "eur": case "europe": return "🇪🇺"; case "f": @@ -261,7 +261,6 @@ export const platformSlugEJSCoreMap = { "neo-geo-pocket-color": "mednafen_ngp", nes: "fceumm", famicom: "fceumm", - fds: "fceumm", "game-televisison": "fceumm", "new-style-nes": "fceumm", // n64: "mupen64plus_next", Disabled until emujs 4.0.12 is released @@ -305,6 +304,6 @@ export const platformSlugEJSCoreMap = { "turbografx16--1": "mednafen_pce", virtualboy: "beetle_vb", wonderswan: "mednafen_wswan", - swancrystal: "mednafen_wswan", + "swancrystal": "mednafen_wswan", "wonderswan-color": "mednafen_wswan", } as const; From 078c7e86806e72fde3281d5746193174d4266eaa Mon Sep 17 00:00:00 2001 From: Zurdi <34356590+zurdi15@users.noreply.github.com> Date: Thu, 14 Mar 2024 22:52:57 +0100 Subject: [PATCH 09/14] Revert "Normalize rom names when parsing exact matches (remove diacritics & special characters)" --- backend/handler/igdb_handler.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/backend/handler/igdb_handler.py b/backend/handler/igdb_handler.py index 19d9d12ae..fc18e31fd 100644 --- a/backend/handler/igdb_handler.py +++ b/backend/handler/igdb_handler.py @@ -9,7 +9,6 @@ from typing import Final, Optional import pydash import requests -import unicodedata import xmltodict from config import IGDB_CLIENT_ID, IGDB_CLIENT_SECRET from fastapi import HTTPException, status @@ -214,26 +213,6 @@ class IGDBHandler: return res.json() - @staticmethod - def _normalize_rom_name(name: str) -> str: - # Convert to lower case, replace underscores with spaces - name = name.lower() - name = re.sub(r'_', ' ', name) - - # Remove apostrophes and quotes - name = re.sub(r'[\'\"]', '', name) - - # Remove leading and trailing articles - name = re.sub(r'^(a|an|the)\b', '', name) - name = re.sub(r',\b(a|an|the)\b', '', name) - - # Remove special characters and punctuation - converted_name = ''.join((re.findall(r'\w+', name))) # only keep words, no special characters or punctuation - normalized_name = unicodedata.normalize('NFD', converted_name) # convert to normal form - canonical_form = ''.join([c for c in normalized_name if not unicodedata.combining(c)]) # remove accents - - return canonical_form - @staticmethod def _normalize_search_term(search_term: str) -> str: return ( From f070a596f23d15eaf4d42f51064e9d3d5e81a9cf Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:55:02 -0400 Subject: [PATCH 10/14] Update index.ts --- frontend/src/utils/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 95b64639f..e5d3b946a 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -108,7 +108,7 @@ export function regionToEmoji(region: string) { return "🇨🇳"; case "e": case "eu": - case "eur": + case "eur": case "europe": return "🇪🇺"; case "f": @@ -304,6 +304,6 @@ export const platformSlugEJSCoreMap = { "turbografx16--1": "mednafen_pce", virtualboy: "beetle_vb", wonderswan: "mednafen_wswan", - "swancrystal": "mednafen_wswan", + swancrystal: "mednafen_wswan", "wonderswan-color": "mednafen_wswan", } as const; From 4e17303275ecc08cf024ec1b45fa6e835d791a13 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:55:26 -0400 Subject: [PATCH 11/14] Update index.ts --- frontend/src/utils/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index e5d3b946a..73e3c8d25 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -261,6 +261,7 @@ export const platformSlugEJSCoreMap = { "neo-geo-pocket-color": "mednafen_ngp", nes: "fceumm", famicom: "fceumm", + fds: "fceumm", "game-televisison": "fceumm", "new-style-nes": "fceumm", // n64: "mupen64plus_next", Disabled until emujs 4.0.12 is released From db0eb39deb00cb4dfebffcdcfd837f2897caad03 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Thu, 14 Mar 2024 21:47:08 -0400 Subject: [PATCH 12/14] Add classes for overflow and height restriction --- frontend/src/views/Library/Scan/Base.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Library/Scan/Base.vue b/frontend/src/views/Library/Scan/Base.vue index 7e5bcb123..b12d9e492 100644 --- a/frontend/src/views/Library/Scan/Base.vue +++ b/frontend/src/views/Library/Scan/Base.vue @@ -103,7 +103,8 @@ async function scan() { From fe994678e34fc0dd31274f4b6a01566e731287d5 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 14 Mar 2024 22:01:47 -0400 Subject: [PATCH 13/14] wrap in div for scrolling --- frontend/src/views/Library/Scan/Base.vue | 65 +++++++++++++----------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/frontend/src/views/Library/Scan/Base.vue b/frontend/src/views/Library/Scan/Base.vue index b12d9e492..43e56cc26 100644 --- a/frontend/src/views/Library/Scan/Base.vue +++ b/frontend/src/views/Library/Scan/Base.vue @@ -101,33 +101,40 @@ async function scan() { /> - - - - - - - {{ platform.name }} - - - - • Identified {{ rom.name }} 👾 - - - • {{ rom.file_name }} not found in IGDB ❌ - - - - +
+ + + + + + + {{ platform.name }} + + + + • Identified {{ rom.name }} 👾 + + + • {{ rom.file_name }} not found in IGDB ❌ + + + + +
+ + From 3502b299c77ebca0637f29a335a62fb9ae72f7db Mon Sep 17 00:00:00 2001 From: Zurdi <34356590+zurdi15@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:28:38 +0100 Subject: [PATCH 14/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a70a0eb81..1337e8e00 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ If you like this project, consider buying me a coffee! Here are a few projects that we think you might like: -- [EmualtorJS](https://emulatorjs.org/): An embeddable, browser-based emulator +- [EmulatorJS](https://emulatorjs.org/): An embeddable, browser-based emulator - [RetroDECK](https://retrodeck.net/): Retro gaming on SteamOS and Linux - [ES-DE Frontend](https://es-de.org/): Emulator frontend for Linux, macOS and Windows - [Gaseous](https://github.com/gaseous-project/gaseous-server): Another self-hosted ROM manager