mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 08:12:40 +10:00
fix: missing metadata preventing game import
when a metadata provider fails to import a game's developer / publisher, the import is no longer blocked. the imports usally fail because there isn't a page for these compaines
This commit is contained in:
@ -175,14 +175,18 @@ export class GiantBombProvider implements MetadataProvider {
|
|||||||
const publishers: Publisher[] = [];
|
const publishers: Publisher[] = [];
|
||||||
if (gameData.publishers) {
|
if (gameData.publishers) {
|
||||||
for (const pub of gameData.publishers) {
|
for (const pub of gameData.publishers) {
|
||||||
publishers.push(await publisher(pub.name));
|
const res = await publisher(pub.name);
|
||||||
|
if (res === undefined) continue;
|
||||||
|
publishers.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const developers: Developer[] = [];
|
const developers: Developer[] = [];
|
||||||
if (gameData.developers) {
|
if (gameData.developers) {
|
||||||
for (const dev of gameData.developers) {
|
for (const dev of gameData.developers) {
|
||||||
developers.push(await developer(dev.name));
|
const res = await developer(dev.name);
|
||||||
|
if (res === undefined) continue;
|
||||||
|
developers.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -334,10 +334,16 @@ export class IGDBProvider implements MetadataProvider {
|
|||||||
for (const company of findCompanyResponse) {
|
for (const company of findCompanyResponse) {
|
||||||
// if company was a dev or publisher
|
// if company was a dev or publisher
|
||||||
// CANNOT use else since a company can be both
|
// CANNOT use else since a company can be both
|
||||||
if (foundInvolved.developer)
|
if (foundInvolved.developer) {
|
||||||
developers.push(await developer(company.name));
|
const res = await developer(company.name);
|
||||||
if (foundInvolved.publisher)
|
if (res === undefined) continue;
|
||||||
publishers.push(await publisher(company.name));
|
developers.push(res);
|
||||||
|
}
|
||||||
|
if (foundInvolved.publisher) {
|
||||||
|
const res = await publisher(company.name);
|
||||||
|
if (res === undefined) continue;
|
||||||
|
publishers.push(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,7 +409,7 @@ export class IGDBProvider implements MetadataProvider {
|
|||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("No results found");
|
throw new Error(`igdb failed to find publisher/developer ${query}`);
|
||||||
}
|
}
|
||||||
async fetchDeveloper(
|
async fetchDeveloper(
|
||||||
params: _FetchDeveloperMetadataParams,
|
params: _FetchDeveloperMetadataParams,
|
||||||
|
|||||||
@ -39,10 +39,10 @@ export abstract class MetadataProvider {
|
|||||||
abstract fetchGame(params: _FetchGameMetadataParams): Promise<GameMetadata>;
|
abstract fetchGame(params: _FetchGameMetadataParams): Promise<GameMetadata>;
|
||||||
abstract fetchPublisher(
|
abstract fetchPublisher(
|
||||||
params: _FetchPublisherMetadataParams,
|
params: _FetchPublisherMetadataParams,
|
||||||
): Promise<PublisherMetadata>;
|
): Promise<PublisherMetadata | undefined>;
|
||||||
abstract fetchDeveloper(
|
abstract fetchDeveloper(
|
||||||
params: _FetchDeveloperMetadataParams,
|
params: _FetchDeveloperMetadataParams,
|
||||||
): Promise<DeveloperMetadata>;
|
): Promise<DeveloperMetadata | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MetadataHandler {
|
export class MetadataHandler {
|
||||||
@ -192,7 +192,7 @@ export class MetadataHandler {
|
|||||||
query,
|
query,
|
||||||
"fetchDeveloper",
|
"fetchDeveloper",
|
||||||
"developer",
|
"developer",
|
||||||
)) as Developer;
|
)) as Developer | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchPublisher(query: string) {
|
async fetchPublisher(query: string) {
|
||||||
@ -200,7 +200,7 @@ export class MetadataHandler {
|
|||||||
query,
|
query,
|
||||||
"fetchPublisher",
|
"fetchPublisher",
|
||||||
"publisher",
|
"publisher",
|
||||||
)) as Publisher;
|
)) as Publisher | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Careful with this function, it has no typechecking
|
// Careful with this function, it has no typechecking
|
||||||
@ -226,9 +226,14 @@ export class MetadataHandler {
|
|||||||
{},
|
{},
|
||||||
["internal:read"],
|
["internal:read"],
|
||||||
);
|
);
|
||||||
let result: PublisherMetadata;
|
let result: PublisherMetadata | undefined;
|
||||||
try {
|
try {
|
||||||
result = await provider[functionName]({ query, createObject });
|
result = await provider[functionName]({ query, createObject });
|
||||||
|
if (result === undefined) {
|
||||||
|
throw new Error(
|
||||||
|
`${provider.source()} failed to find a ${databaseName} for "${query}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
dumpObjects();
|
dumpObjects();
|
||||||
@ -257,9 +262,10 @@ export class MetadataHandler {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(
|
// throw new Error(
|
||||||
`No metadata provider found a ${databaseName} for "${query}"`,
|
// `No metadata provider found a ${databaseName} for "${query}"`,
|
||||||
);
|
// );
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -171,7 +171,9 @@ export class PCGamingWikiProvider implements MetadataProvider {
|
|||||||
if (game.Publishers !== null) {
|
if (game.Publishers !== null) {
|
||||||
const pubListClean = this.parseCompanyStr(game.Publishers);
|
const pubListClean = this.parseCompanyStr(game.Publishers);
|
||||||
for (const pub of pubListClean) {
|
for (const pub of pubListClean) {
|
||||||
publishers.push(await publisher(pub));
|
const res = await publisher(pub);
|
||||||
|
if (res === undefined) continue;
|
||||||
|
publishers.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +181,9 @@ export class PCGamingWikiProvider implements MetadataProvider {
|
|||||||
if (game.Developers !== null) {
|
if (game.Developers !== null) {
|
||||||
const devListClean = this.parseCompanyStr(game.Developers);
|
const devListClean = this.parseCompanyStr(game.Developers);
|
||||||
for (const dev of devListClean) {
|
for (const dev of devListClean) {
|
||||||
developers.push(await developer(dev));
|
const res = await developer(dev);
|
||||||
|
if (res === undefined) continue;
|
||||||
|
developers.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +253,7 @@ export class PCGamingWikiProvider implements MetadataProvider {
|
|||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("Error in pcgamingwiki, no publisher");
|
throw new Error(`pcgamingwiki failed to find publisher/developer ${query}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchDeveloper(
|
async fetchDeveloper(
|
||||||
|
|||||||
4
server/internal/metadata/types.d.ts
vendored
4
server/internal/metadata/types.d.ts
vendored
@ -57,8 +57,8 @@ export interface _FetchGameMetadataParams {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
publisher: (query: string) => Promise<Publisher>;
|
publisher: (query: string) => Promise<Publisher | undefined>;
|
||||||
developer: (query: string) => Promise<Developer>;
|
developer: (query: string) => Promise<Developer | undefined>;
|
||||||
|
|
||||||
createObject: (data: TransactionDataType) => ObjectReference;
|
createObject: (data: TransactionDataType) => ObjectReference;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user