Merge branch 'master' into release

This commit is contained in:
Zurdi
2024-03-15 12:29:02 +01:00
committed by GitHub
3 changed files with 76 additions and 33 deletions

View File

@@ -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]", {})

View File

@@ -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;

View File

@@ -101,32 +101,40 @@ async function scan() {
/>
<!-- Scan log -->
<v-row
no-gutters
class="align-center pa-4"
v-for="platform in scanningPlatforms"
>
<v-col>
<v-list-item
:to="{ name: 'platform', params: { platform: platform.id } }"
>
<v-avatar :rounded="0" size="40">
<platform-icon :key="platform.slug" :slug="platform.slug" />
</v-avatar>
<span class="text-body-2 ml-5"> {{ platform.name }}</span>
</v-list-item>
<v-list-item
v-for="rom in platform.roms"
class="text-body-2 romm-grey"
:to="{ name: 'rom', params: { rom: rom.id } }"
>
<span v-if="rom.igdb_id" class="ml-10">
• Identified <b>{{ rom.name }} 👾</b>
</span>
<span v-else class="ml-10">
• {{ rom.file_name }} not found in IGDB ❌
</span>
</v-list-item>
</v-col>
</v-row>
<div class="overflow-y-auto scan-log">
<v-row
no-gutters
class="align-center pa-4"
v-for="platform in scanningPlatforms"
>
<v-col>
<v-list-item
:to="{ name: 'platform', params: { platform: platform.id } }"
>
<v-avatar :rounded="0" size="40">
<platform-icon :key="platform.slug" :slug="platform.slug" />
</v-avatar>
<span class="text-body-2 ml-5"> {{ platform.name }}</span>
</v-list-item>
<v-list-item
v-for="rom in platform.roms"
class="text-body-2 romm-grey"
:to="{ name: 'rom', params: { rom: rom.id } }"
>
<span v-if="rom.igdb_id" class="ml-10">
• Identified <b>{{ rom.name }} 👾</b>
</span>
<span v-else class="ml-10">
• {{ rom.file_name }} not found in IGDB ❌
</span>
</v-list-item>
</v-col>
</v-row>
</div>
</template>
<style scoped>
.scan-log {
max-height: calc(100vh - 295px);
}
</style>