Merge pull request #559 from zurdi15/romm-554

Support for switch update and DLC files
This commit is contained in:
Zurdi
2024-01-03 01:12:00 +01:00
committed by GitHub
2 changed files with 16 additions and 6 deletions

View File

@@ -165,18 +165,21 @@ class IGDBHandler:
@staticmethod
async def _ps2_opl_format(match: re.Match[str], search_term: str) -> str:
serial_code = match.group(1)
with open(PS2_OPL_INDEX_FILE, "r") as index_json:
opl_index = json.loads(index_json.read())
index_entry = opl_index.get(serial_code, None)
if index_entry:
search_term = index_entry["Name"] # type: ignore
return search_term
@staticmethod
async def _switch_titledb_format(match: re.Match[str], search_term: str) -> str:
title_id = match.group(1)
titledb_index = {}
title_id = match.group(1)
try:
with open(SWITCH_TITLEDB_INDEX_FILE, "r") as index_json:
titledb_index = json.loads(index_json.read())
@@ -192,12 +195,19 @@ class IGDBHandler:
index_entry = titledb_index.get(title_id, None)
if index_entry:
search_term = index_entry["name"] # type: ignore
return search_term
@staticmethod
async def _switch_productid_format(match: re.Match[str], search_term: str) -> str:
product_id = match.group(1)
product_id_index = {}
product_id = match.group(1)
# Game updates have the same product ID as the main application, except with bitmask 0x800 set
product_id = list(product_id)
product_id[-3] = '0'
product_id = ''.join(product_id)
try:
with open(SWITCH_PRODUCT_ID_FILE, "r") as index_json:
product_id_index = json.loads(index_json.read())
@@ -218,6 +228,7 @@ class IGDBHandler:
@staticmethod
async def _mame_format(search_term: str) -> str:
mame_index = {"menu": {"game": []}}
try:
with open(MAME_XML_FILE, "r") as index_xml:
mame_index = xmltodict.parse(index_xml.read())
@@ -240,6 +251,7 @@ class IGDBHandler:
search_term = get_search_term(
index_entry[0].get("description", search_term)
)
return search_term
@check_twitch_token
@@ -268,7 +280,7 @@ class IGDBHandler:
search_term = await self._ps2_opl_format(match, search_term)
# Support for switch titleID filename format
match = re.match(SWITCH_TITLEDB_REGEX, file_name)
match = re.search(SWITCH_TITLEDB_REGEX, file_name)
if platform_idgb_id == SWITCH_IGDB_ID and match:
search_term = await self._switch_titledb_format(match, search_term)

View File

@@ -11,7 +11,7 @@ function formatItem(rom) {
const langs = rom.languages.map((l) => languageToEmoji(l)).join(" ");
const regions = rom.regions.map((r) => regionToEmoji(r)).join(" ");
const tags = rom.tags.map((t) => `(${t})`).join(" ");
return `${langs} ${regions} ${tags}`;
return `${langs} ${regions} ${tags}` || rom.file_name;
}
function updateVersion() {
@@ -42,8 +42,6 @@ function updateVersion() {
<style scoped>
.version-select {
/* position: absolute; */
max-width: fit-content;
/* min-width: 8rem; */
}
</style>