mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2026-06-13 04:04:59 +03:00
Refactor game metadata to allow null values
Updated game metadata handling to allow null values for developer and publisher fields instead of defaulting to 'Unknown'. Adjusted platform handling to return null instead of 'Unknown' when no data is available.
This commit is contained in:
+30
-19
@@ -2369,6 +2369,8 @@ except Exception as e:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### METADATA ONLY
|
### METADATA ONLY
|
||||||
METADATA_CODE = r"""
|
METADATA_CODE = r"""
|
||||||
(function () {
|
(function () {
|
||||||
@@ -2448,13 +2450,13 @@ METADATA_CODE = r"""
|
|||||||
.filter(([k,v]) => v)
|
.filter(([k,v]) => v)
|
||||||
.map(([k]) => k)
|
.map(([k]) => k)
|
||||||
.join(", ")
|
.join(", ")
|
||||||
: "Unknown";
|
: null;
|
||||||
|
|
||||||
const gameData = {
|
const gameData = {
|
||||||
appid: appid,
|
appid: appid,
|
||||||
about_the_game: info.short_description || null,
|
about_the_game: info.short_description || null,
|
||||||
developer: info.developers?.join(", ") || "Unknown",
|
developer: info.developers?.join(", ") || null,
|
||||||
publisher: info.publishers?.join(", ") || "Unknown",
|
publisher: info.publishers?.join(", ") || null,
|
||||||
release_date: info.release_date?.date || null,
|
release_date: info.release_date?.date || null,
|
||||||
genres: info.genres?.map(g => g.description).join(", ") || null,
|
genres: info.genres?.map(g => g.description).join(", ") || null,
|
||||||
platforms: platformsStr,
|
platforms: platformsStr,
|
||||||
@@ -2513,11 +2515,11 @@ METADATA_CODE = r"""
|
|||||||
appid: null,
|
appid: null,
|
||||||
displayTitle,
|
displayTitle,
|
||||||
about_the_game: description || data.extract || null,
|
about_the_game: description || data.extract || null,
|
||||||
developer: "Unknown",
|
developer: null,
|
||||||
publisher: "Unknown",
|
publisher: null,
|
||||||
release_date: null,
|
release_date: null,
|
||||||
genres: null,
|
genres: null,
|
||||||
platforms: "Unknown",
|
platforms: null,
|
||||||
metacritic_score: null,
|
metacritic_score: null,
|
||||||
metacritic_url: null,
|
metacritic_url: null,
|
||||||
image_url: data.originalimage?.source || null
|
image_url: data.originalimage?.source || null
|
||||||
@@ -2550,22 +2552,23 @@ METADATA_CODE = r"""
|
|||||||
labelsData = labelsJson.entities || {};
|
labelsData = labelsJson.entities || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
game.developer = developerId ? labelsData[developerId]?.labels?.en?.value ?? "Unknown" : "Unknown";
|
game.developer = developerId ? labelsData[developerId]?.labels?.en?.value ?? null : null;
|
||||||
game.publisher = publisherId ? labelsData[publisherId]?.labels?.en?.value ?? "Unknown" : "Unknown";
|
game.publisher = publisherId ? labelsData[publisherId]?.labels?.en?.value ?? null : null;
|
||||||
game.release_date = releaseTime ? releaseTime.match(/\d{4}/)[0] : null;
|
game.release_date = releaseTime ? releaseTime.match(/\d{4}/)[0] : null;
|
||||||
|
|
||||||
if (genreIds.length) {
|
if (genreIds.length) {
|
||||||
const genreLabel = labelsData[genreIds[0]]?.labels?.en?.value ?? "Unknown";
|
const genreLabel = labelsData[genreIds[0]]?.labels?.en?.value;
|
||||||
game.genres = genreLabel.replace(/\s*\(.*?\)\s*/g, "").trim();
|
game.genres = genreLabel.replace(/\s*\(.*?\)\s*/g, "").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
const platformsClean = platformIds.map(id => {
|
const platformsClean = platformIds
|
||||||
const label = labelsData[id]?.labels?.en?.value ?? "Unknown";
|
.map(id => labelsData[id]?.labels?.en?.value)
|
||||||
return label.replace(/\s*\(.*?\)\s*/g, "").trim();
|
.filter(Boolean)
|
||||||
});
|
.map(label => label.replace(/\s*\(.*?\)\s*/g, "").trim());
|
||||||
|
|
||||||
game.platforms = platformsClean.length
|
game.platforms = platformsClean.length
|
||||||
? platformsClean.join(", ")
|
? platformsClean.join(", ")
|
||||||
: "Unknown"; // <- Always string
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
gameCache[gameName] = game;
|
gameCache[gameName] = game;
|
||||||
@@ -2963,12 +2966,20 @@ METADATA_CODE = r"""
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gameData.platforms)
|
||||||
|
leftColumn.appendChild(createTagRow(gameData.platforms.split(",").map(p => p.trim())));
|
||||||
|
|
||||||
leftColumn.appendChild(createTagRow((gameData.platforms || "Unknown").split(",").map(p => p.trim())));
|
if (gameData.developer)
|
||||||
leftColumn.appendChild(createTagRow((gameData.developer || "Unknown").split(",").map(d => d.trim())));
|
leftColumn.appendChild(createTagRow(gameData.developer.split(",").map(d => d.trim())));
|
||||||
leftColumn.appendChild(createTagRow((gameData.publisher || "Unknown").split(",").map(p => p.trim())));
|
|
||||||
leftColumn.appendChild(createTagRow([gameData.release_date || "Unknown"]));
|
if (gameData.publisher)
|
||||||
leftColumn.appendChild(createTagRow((gameData.genres || "Unknown").split(",").map(g => g.trim())));
|
leftColumn.appendChild(createTagRow(gameData.publisher.split(",").map(p => p.trim())));
|
||||||
|
|
||||||
|
if (gameData.release_date)
|
||||||
|
leftColumn.appendChild(createTagRow([gameData.release_date]));
|
||||||
|
|
||||||
|
if (gameData.genres)
|
||||||
|
leftColumn.appendChild(createTagRow(gameData.genres.split(",").map(g => g.trim())));
|
||||||
|
|
||||||
// Right column (description + Metacritic tab)
|
// Right column (description + Metacritic tab)
|
||||||
const rightColumn = document.createElement('div');
|
const rightColumn = document.createElement('div');
|
||||||
|
|||||||
Reference in New Issue
Block a user