mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Show "Unknown Game" when unable to get game's title
This commit is contained in:
parent
277a830d99
commit
54a3e144a6
11
dist/better-xcloud.pretty.user.js
vendored
11
dist/better-xcloud.pretty.user.js
vendored
@ -4121,11 +4121,14 @@ class XboxApi {
|
||||
static CACHED_TITLES = {};
|
||||
static async getProductTitle(xboxTitleId) {
|
||||
if (xboxTitleId = xboxTitleId.toString(), XboxApi.CACHED_TITLES[xboxTitleId]) return XboxApi.CACHED_TITLES[xboxTitleId];
|
||||
let title;
|
||||
try {
|
||||
let url = `https://displaycatalog.mp.microsoft.com/v7.0/products/lookup?market=US&languages=en&value=${xboxTitleId}&alternateId=XboxTitleId&fieldsTemplate=browse`, productTitle = (await (await NATIVE_FETCH(url)).json()).Products[0].LocalizedProperties[0].ProductTitle;
|
||||
return XboxApi.CACHED_TITLES[xboxTitleId] = productTitle, productTitle;
|
||||
} catch (e) {}
|
||||
return;
|
||||
let url = `https://displaycatalog.mp.microsoft.com/v7.0/products/lookup?market=US&languages=en&value=${xboxTitleId}&alternateId=XboxTitleId&fieldsTemplate=browse`;
|
||||
title = (await (await NATIVE_FETCH(url)).json()).Products[0].LocalizedProperties[0].ProductTitle;
|
||||
} catch (e) {
|
||||
title = "Unknown Game #" + xboxTitleId;
|
||||
}
|
||||
return XboxApi.CACHED_TITLES[xboxTitleId] = title, title;
|
||||
}
|
||||
}
|
||||
class SettingsManager {
|
||||
|
2
dist/better-xcloud.user.js
vendored
2
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -9,17 +9,18 @@ export class XboxApi {
|
||||
return XboxApi.CACHED_TITLES[xboxTitleId];
|
||||
}
|
||||
|
||||
let title: string;
|
||||
try {
|
||||
const url = `https://displaycatalog.mp.microsoft.com/v7.0/products/lookup?market=US&languages=en&value=${xboxTitleId}&alternateId=XboxTitleId&fieldsTemplate=browse`;
|
||||
const resp = await NATIVE_FETCH(url);
|
||||
const json = await resp.json();
|
||||
|
||||
const productTitle = json['Products'][0]['LocalizedProperties'][0]['ProductTitle'];
|
||||
XboxApi.CACHED_TITLES[xboxTitleId] = productTitle;
|
||||
title = json['Products'][0]['LocalizedProperties'][0]['ProductTitle'];
|
||||
} catch (e) {
|
||||
title = 'Unknown Game #' + xboxTitleId;
|
||||
}
|
||||
|
||||
return productTitle;
|
||||
} catch (e) {}
|
||||
|
||||
return;
|
||||
XboxApi.CACHED_TITLES[xboxTitleId] = title;
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user