Ignore games with no JSON-LD
							parent
							
								
									fe164e1ea6
								
							
						
					
					
						commit
						6bb089cca6
					
				| 
						 | 
					@ -22,9 +22,9 @@ main();
 | 
				
			||||||
async function main() {
 | 
					async function main() {
 | 
				
			||||||
    // Local variables
 | 
					    // Local variables
 | 
				
			||||||
    const gameList = [
 | 
					    const gameList = [
 | 
				
			||||||
 | 
					        "Four Elements Trainer",
 | 
				
			||||||
        "corrupted kingdoms",
 | 
					        "corrupted kingdoms",
 | 
				
			||||||
        "summertime saga",
 | 
					        "summertime saga"
 | 
				
			||||||
        "brothel king"
 | 
					 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Log in the platform
 | 
					    // Log in the platform
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -122,6 +122,7 @@ module.exports.getGameData = async function (name, mod) {
 | 
				
			||||||
    for (const url of urls) {
 | 
					    for (const url of urls) {
 | 
				
			||||||
        // Start looking for information
 | 
					        // Start looking for information
 | 
				
			||||||
        const info = await scraper.getGameInfo(url);
 | 
					        const info = await scraper.getGameInfo(url);
 | 
				
			||||||
 | 
					        if(!info) continue;
 | 
				
			||||||
        results.push(info);
 | 
					        results.push(info);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return results;
 | 
					    return results;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ const f95Selector = require("./constants/css-selector.js");
 | 
				
			||||||
 * Get information from the game's main page.
 | 
					 * Get information from the game's main page.
 | 
				
			||||||
 * @param {String} url URL of the game/mod to extract data from
 | 
					 * @param {String} url URL of the game/mod to extract data from
 | 
				
			||||||
 * @return {Promise<GameInfo>} Complete information about the game you are
 | 
					 * @return {Promise<GameInfo>} Complete information about the game you are
 | 
				
			||||||
 * looking for
 | 
					 * looking for or `null` if is impossible to parse information
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
module.exports.getGameInfo = async function (url) {
 | 
					module.exports.getGameInfo = async function (url) {
 | 
				
			||||||
    shared.logger.info("Obtaining game info");
 | 
					    shared.logger.info("Obtaining game info");
 | 
				
			||||||
| 
						 | 
					@ -32,8 +32,12 @@ module.exports.getGameInfo = async function (url) {
 | 
				
			||||||
    const src = extractPreviewSource(body);
 | 
					    const src = extractPreviewSource(body);
 | 
				
			||||||
    const changelog = extractChangelog(mainPost);
 | 
					    const changelog = extractChangelog(mainPost);
 | 
				
			||||||
    const structuredData = extractStructuredData(body);
 | 
					    const structuredData = extractStructuredData(body);
 | 
				
			||||||
    const parsedInfos = parseMainPostText(structuredData["description"]);
 | 
					
 | 
				
			||||||
    const overview = getOverview(structuredData["description"], prefixesData.mod);
 | 
					    // Sometimes the JSON-LD are not set, especially in low-profile game
 | 
				
			||||||
 | 
					    if(!structuredData) return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const parsedInfos = parseMainPostText(structuredData.description);
 | 
				
			||||||
 | 
					    const overview = getOverview(structuredData.description, prefixesData.mod);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Obtain the updated URL
 | 
					    // Obtain the updated URL
 | 
				
			||||||
    const redirectUrl = await getUrlRedirect(url);
 | 
					    const redirectUrl = await getUrlRedirect(url);
 | 
				
			||||||
| 
						 | 
					@ -302,7 +306,7 @@ function extractStructuredData(body) {
 | 
				
			||||||
        // Return only the data of the game
 | 
					        // Return only the data of the game
 | 
				
			||||||
        if (json["@type"] === "Book") return json;
 | 
					        if (json["@type"] === "Book") return json;
 | 
				
			||||||
    }).get();
 | 
					    }).get();
 | 
				
			||||||
    return json[0] ? json[0] : null;
 | 
					    return json.lenght !== 0 ? json[0] : null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name": "f95api",
 | 
					  "name": "f95api",
 | 
				
			||||||
  "version": "1.5.0",
 | 
					  "version": "1.6.1",
 | 
				
			||||||
  "lockfileVersion": 1,
 | 
					  "lockfileVersion": 1,
 | 
				
			||||||
  "requires": true,
 | 
					  "requires": true,
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "main": "./app/index.js",
 | 
					  "main": "./app/index.js",
 | 
				
			||||||
  "name": "f95api",
 | 
					  "name": "f95api",
 | 
				
			||||||
  "version": "1.6.0",
 | 
					  "version": "1.6.1",
 | 
				
			||||||
  "author": {
 | 
					  "author": {
 | 
				
			||||||
    "name": "Millennium Earl"
 | 
					    "name": "Millennium Earl"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue