imports are cool xD
This commit is contained in:
@@ -60,6 +60,29 @@ export interface PlayniteGamesResponse {
|
||||
export type LogCallback = (message: string) => void;
|
||||
export type ProgressCallback = (progress: Partial<ImportProgress>) => void;
|
||||
|
||||
async function fetchGameCover(baseUrl: string, headers: Record<string, string>, gameId: string): Promise<string | null> {
|
||||
try {
|
||||
const coverResponse = await fetch(`${baseUrl}/api/games/${gameId}/cover`, {
|
||||
method: 'GET',
|
||||
headers
|
||||
});
|
||||
|
||||
if (!coverResponse.ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const blob = await coverResponse.blob();
|
||||
const arrayBuffer = await blob.arrayBuffer();
|
||||
const base64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)));
|
||||
|
||||
// Determine MIME type from blob
|
||||
const mimeType = blob.type || 'image/jpeg';
|
||||
return `data:${mimeType};base64,${base64}`;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function importFromPlaynite(
|
||||
config: PlayniteConfig,
|
||||
logCallback: LogCallback,
|
||||
@@ -194,7 +217,6 @@ export async function importFromPlaynite(
|
||||
|
||||
// Staff is for actors/performers only - leave empty for games
|
||||
const staff: any[] = [];
|
||||
|
||||
// Determine type based on genres/features
|
||||
let type = 'Game';
|
||||
//if (game.genres?.includes('Visual Novel') || game.genres?.includes('Adventure')) {
|
||||
@@ -242,7 +264,7 @@ export async function importFromPlaynite(
|
||||
links: game.links || [],
|
||||
achievements: [],
|
||||
year: year.toString(),
|
||||
poster: null,
|
||||
poster: game.coverBase64 || null,
|
||||
banner: null,
|
||||
rating: rating,
|
||||
category: 'Game',
|
||||
|
||||
Reference in New Issue
Block a user