Bugfix
parent
d335f192cd
commit
c88c9720a2
|
@ -122,7 +122,7 @@ module.exports.getGameData = async function (name, mod) {
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const url of urls) {
|
for (const url of urls) {
|
||||||
// Start looking for information
|
// Start looking for information
|
||||||
const info = scraper.getGameInfo(url);
|
const info = await scraper.getGameInfo(url);
|
||||||
results.push(info);
|
results.push(info);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -305,10 +305,11 @@ function extractStructuredData(body) {
|
||||||
* Different processing depending on whether the game is a mod or not.
|
* Different processing depending on whether the game is a mod or not.
|
||||||
* @param {String} text Structured text extracted from the game's web page
|
* @param {String} text Structured text extracted from the game's web page
|
||||||
* @param {Boolean} mod Specify if it is a game or a mod
|
* @param {Boolean} mod Specify if it is a game or a mod
|
||||||
* @returns {Promise<String>} Game description
|
* @returns {String} Game description
|
||||||
*/
|
*/
|
||||||
function getOverview(text, mod) {
|
function getOverview(text, mod) {
|
||||||
shared.logger.trace("Extracting game overview...");
|
shared.logger.trace("Extracting game overview...");
|
||||||
|
|
||||||
// Get overview (different parsing for game and mod)
|
// Get overview (different parsing for game and mod)
|
||||||
const overviewEndIndex = mod ? text.indexOf("Updated") : text.indexOf("Thread Updated");
|
const overviewEndIndex = mod ? text.indexOf("Updated") : text.indexOf("Thread Updated");
|
||||||
return text.substring(0, overviewEndIndex).replace("Overview:\n", "").trim();
|
return text.substring(0, overviewEndIndex).replace("Overview:\n", "").trim();
|
||||||
|
|
|
@ -4,58 +4,46 @@
|
||||||
const dotenv = require("dotenv");
|
const dotenv = require("dotenv");
|
||||||
|
|
||||||
// Modules from file
|
// Modules from file
|
||||||
const searcher = require("../app/scripts/searcher.js");
|
const F95API = require("../app/index.js");
|
||||||
const scraper = require("../app/scripts/scraper.js");
|
|
||||||
const Credentials = require("../app/scripts/classes/credentials.js");
|
|
||||||
const networkHelper = require("../app/scripts/network-helper.js");
|
|
||||||
const uScraper = require("../app/scripts/user-scraper.js");
|
|
||||||
|
|
||||||
// Configure the .env reader
|
// Configure the .env reader
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
// Login
|
|
||||||
auth().then(async function searchGames(result) {
|
|
||||||
if(!result) return;
|
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
// Local variables
|
||||||
|
const gameList = [
|
||||||
|
"kingdom of deception",
|
||||||
|
"perverted education",
|
||||||
|
"corrupted kingdoms",
|
||||||
|
"summertime saga",
|
||||||
|
"brothel king"
|
||||||
|
];
|
||||||
|
|
||||||
|
// Log in the platform
|
||||||
|
console.log("Authenticating...");
|
||||||
|
const result = await F95API.login(process.env.F95_USERNAME, process.env.F95_PASSWORD);
|
||||||
|
console.log(`Authentication result: ${result.message}`);
|
||||||
|
|
||||||
|
// Get user data
|
||||||
console.log("Fetching user data...");
|
console.log("Fetching user data...");
|
||||||
const userdata = await uScraper.getUserData();
|
const userdata = await F95API.getUserData();
|
||||||
console.log(`${userdata.username} follows ${userdata.watchedThreads.length} threads`);
|
console.log(`${userdata.username} follows ${userdata.watchedThreads.length} threads`);
|
||||||
|
|
||||||
// Search for Kingdom Of Deception data
|
for(const gamename of gameList) {
|
||||||
await search("kingdom of deception");
|
console.log(`Searching '${gamename}'...`);
|
||||||
|
const found = await F95API.getGameData(gamename, false);
|
||||||
|
|
||||||
// Search for Perverted Education data
|
// If no game is found
|
||||||
await search("perverted education");
|
if (found.length === 0) {
|
||||||
|
console.log(`No data found for '${gamename}'`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Search for Corrupted Kingdoms data
|
// Extract first game
|
||||||
await search("corrupted kingdoms");
|
const gamedata = found[0];
|
||||||
|
|
||||||
// Search for Summertime Saga data
|
|
||||||
await search("summertime saga");
|
|
||||||
});
|
|
||||||
|
|
||||||
async function auth() {
|
|
||||||
console.log("Token fetch...");
|
|
||||||
const creds = new Credentials(process.env.F95_USERNAME, process.env.F95_PASSWORD);
|
|
||||||
await creds.fetchToken();
|
|
||||||
console.log(`Token obtained: ${creds.token}`);
|
|
||||||
|
|
||||||
console.log("Authenticating...");
|
|
||||||
const result = await networkHelper.autenticate(creds);
|
|
||||||
console.log(`Authentication result: ${result.message}`);
|
|
||||||
|
|
||||||
return result.success;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function search(gamename) {
|
|
||||||
console.log(`Searching '${gamename}'...`);
|
|
||||||
const urls = await searcher.searchGame(gamename);
|
|
||||||
console.log(`Found: ${urls}`);
|
|
||||||
|
|
||||||
console.log("Scraping data...");
|
|
||||||
for (const url of urls) {
|
|
||||||
const gamedata = await scraper.getGameInfo(url);
|
|
||||||
console.log(`Found ${gamedata.name} (${gamedata.version}) by ${gamedata.author}`);
|
console.log(`Found ${gamedata.name} (${gamedata.version}) by ${gamedata.author}`);
|
||||||
}
|
}
|
||||||
console.log("Scraping completed!");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue