Game profile: granular IGDB platforms and free-game badge
Build & Push / Lint & Build (push) Successful in 1m16s
Build & Push / Build & Push Image (push) Successful in 28s
Build & Push / Trigger Deploy (push) Successful in 2s

- List IGDB platform names verbatim (Windows, MacOS) instead of
  coarse buckets; fall back to Steam OS flags and hardware
  distributors only when IGDB has none
- Show a Free badge instead of prices when best price is zero
This commit is contained in:
fristy committed 2026-09-11 06:51:41 +03:00
1 parent d778a18a49
commit 7d6d31265b
5 files changed
+74 -54

No files matched your search

+32 -22
View File
@@ -88,9 +88,7 @@ async function getDetectables(): Promise<DetectableEntry[]> {
return detectablesCache.data;
}
try {
const response = await fetch("https://cdn.discordapp.com/detectables/games-v1.json", {
next: { revalidate: 86_400 },
});
const response = await fetch("https://cdn.discordapp.com/detectables/games-v1.json");
if (!response.ok) {
console.error(`detectables failed: ${response.status}`);
return detectablesCache?.data ?? [];
@@ -104,10 +102,6 @@ async function getDetectables(): Promise<DetectableEntry[]> {
}
const DISTRIBUTOR_PLATFORM: Record<string, string> = {
steam: "PC",
battlenet: "PC",
gog: "PC",
epic: "PC",
xbox: "Xbox",
xbox_title: "Xbox",
xbox_game_pass: "Xbox",
@@ -220,10 +214,16 @@ interface IgdbGame {
let igdbTokenCache: { token: string; expires: number } | null = null;
let igdbKeyWarned = false;
async function getIgdbToken(): Promise<string | null> {
const clientId = process.env.TWITCH_CLIENT_ID;
const clientSecret = process.env.TWITCH_CLIENT_SECRET;
if (!clientId || !clientSecret) {
if (!igdbKeyWarned) {
igdbKeyWarned = true;
console.error("igdb keys missing: set TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET");
}
return null;
}
if (igdbTokenCache && Date.now() < igdbTokenCache.expires) {
@@ -386,9 +386,15 @@ interface ItadOverviewPrice {
} | null;
}
let itadKeyWarned = false;
async function itadFetch<T>(path: string, init?: RequestInit): Promise<T | null> {
const key = process.env.ITAD_API_KEY;
if (!key) {
if (!itadKeyWarned) {
itadKeyWarned = true;
console.error("itad key missing: set ITAD_API_KEY");
}
return null;
}
try {
@@ -499,24 +505,28 @@ export async function getGameProfile(
const igdbPlatforms = new Set<string>();
for (const p of igdb?.platforms ?? []) {
const label = `${p.abbreviation ?? ""} ${p.name ?? ""}`.toUpperCase();
if (/PS|PLAYSTATION/.test(label)) {
igdbPlatforms.add("PlayStation");
} else if (/XBOX|XONE|XSX/.test(label)) {
igdbPlatforms.add("Xbox");
} else if (/PC|WIN|MAC|LIN/.test(label)) {
igdbPlatforms.add("PC");
} else if (/SWITCH/.test(label)) {
igdbPlatforms.add("Switch");
const raw = (p.name ?? "").trim();
if (!raw) {
continue;
}
if (raw === "PC (Microsoft Windows)") {
igdbPlatforms.add("Windows");
} else if (raw === "Mac") {
igdbPlatforms.add("MacOS");
} else {
igdbPlatforms.add(raw);
}
}
const platforms = new Set<string>(igdbPlatforms);
if (platforms.size === 0) {
if (
steam?.platforms &&
(steam.platforms.windows || steam.platforms.mac || steam.platforms.linux)
) {
platforms.add("PC");
if (platforms.size === 0 && steam?.platforms) {
if (steam.platforms.windows) {
platforms.add("Windows");
}
if (steam.platforms.mac) {
platforms.add("MacOS");
}
if (steam.platforms.linux) {
platforms.add("Linux");
}
for (const sku of entry?.third_party_skus ?? []) {
const mapped = DISTRIBUTOR_PLATFORM[sku.distributor];
+1
View File
@@ -37,6 +37,7 @@
"links": "Links",
"reviews": "Bewertungen",
"prices": "Preise",
"free": "Kostenlos",
"bestPrice": "Bester Preis",
"historyLow": "Historischer Tiefstpreis",
"allPrices": "ITAD",
+1
View File
@@ -37,6 +37,7 @@
"links": "Links",
"reviews": "Reviews",
"prices": "Prices",
"free": "Free",
"bestPrice": "Best Price",
"historyLow": "All-Time Low",
"allPrices": "ITAD",
+1
View File
@@ -37,6 +37,7 @@
"links": "Bağlantılar",
"reviews": "İncelemeler",
"prices": "Fiyatlar",
"free": "Ücretsiz",
"bestPrice": "En İyi Fiyat",
"historyLow": "Tarihi En Düşük",
"allPrices": "ITAD",