Added game ID
parent
222fe21185
commit
28b1bf0ea2
|
@ -51,6 +51,6 @@ async function main() {
|
||||||
|
|
||||||
// Extract first game
|
// Extract first game
|
||||||
const gamedata = found[0];
|
const gamedata = found[0];
|
||||||
console.log(`Found ${gamedata.name} (${gamedata.version}) by ${gamedata.author}`);
|
console.log(`Found ${gamedata.name} (${gamedata.version}, ID ${gamedata.id}) by ${gamedata.author}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
class GameInfo {
|
class GameInfo {
|
||||||
constructor() {
|
constructor() {
|
||||||
//#region Properties
|
//#region Properties
|
||||||
|
/**
|
||||||
|
* Unique ID of the game on the platform.
|
||||||
|
* @type Number
|
||||||
|
*/
|
||||||
|
this.id = -1;
|
||||||
/**
|
/**
|
||||||
* Game name
|
* Game name
|
||||||
* @type String
|
* @type String
|
||||||
|
|
|
@ -40,6 +40,7 @@ module.exports.getGameInfo = async function (url) {
|
||||||
|
|
||||||
// Fill in the GameInfo element with the information obtained
|
// Fill in the GameInfo element with the information obtained
|
||||||
const info = new GameInfo();
|
const info = new GameInfo();
|
||||||
|
info.id = extractIDFromURL(url);
|
||||||
info.name = titleData.name;
|
info.name = titleData.name;
|
||||||
info.author = titleData.author;
|
info.author = titleData.author;
|
||||||
info.isMod = prefixesData.mod;
|
info.isMod = prefixesData.mod;
|
||||||
|
@ -353,6 +354,23 @@ function isMod(prefix) {
|
||||||
return modPrefixes.includes(prefix.toUpperCase());
|
return modPrefixes.includes(prefix.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* Extracts the game's unique ID from the game's URL.
|
||||||
|
* @param {String} url Game's URL
|
||||||
|
* @return {Number} Game's ID
|
||||||
|
*/
|
||||||
|
function extractIDFromURL(url) {
|
||||||
|
// URL are in the format https://f95zone.to/threads/GAMENAME-VERSION-DEVELOPER.ID/
|
||||||
|
const splitted = url.split(".");
|
||||||
|
|
||||||
|
// We took the last part (clean it)
|
||||||
|
const value = splitted.pop().replace("/", "").trim();
|
||||||
|
|
||||||
|
// Parse and return number
|
||||||
|
return parseInt(value, 10);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* Makes an array of strings uppercase.
|
* Makes an array of strings uppercase.
|
||||||
|
|
Loading…
Reference in New Issue