2020-10-31 15:00:26 +00:00
|
|
|
"use strict";
|
2020-09-29 15:11:43 +00:00
|
|
|
|
2020-11-01 08:54:59 +00:00
|
|
|
// Public modules from npm
|
|
|
|
const dotenv = require("dotenv");
|
|
|
|
|
2020-10-31 15:00:26 +00:00
|
|
|
// Modules from file
|
2020-11-01 08:54:59 +00:00
|
|
|
const searcher = require("../app/scripts/searcher.js");
|
|
|
|
const scraper = require("../app/scripts/scraper.js");
|
|
|
|
const Credentials = require("../app/scripts/classes/credentials.js");
|
|
|
|
const networkHelper = require("../app/scripts/network-helper.js");
|
2020-11-01 23:14:28 +00:00
|
|
|
const uScraper = require("../app/scripts/user-scraper.js");
|
2020-11-01 08:54:59 +00:00
|
|
|
|
|
|
|
// Configure the .env reader
|
|
|
|
dotenv.config();
|
2020-09-29 15:11:43 +00:00
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
// Login
|
|
|
|
auth().then(async function searchGames(result) {
|
|
|
|
if(!result) return;
|
2020-09-29 15:11:43 +00:00
|
|
|
|
2020-11-01 23:14:28 +00:00
|
|
|
console.log("Fetching user data...");
|
|
|
|
const userdata = await uScraper.getUserData();
|
|
|
|
console.log(`${userdata.username} follows ${userdata.watchedThreads.length} threads`);
|
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
// Search for Kingdom Of Deception data
|
|
|
|
await search("kingdom of deception");
|
|
|
|
|
|
|
|
// Search for Perverted Education data
|
|
|
|
await search("perverted education");
|
|
|
|
|
|
|
|
// Search for Corrupted Kingdoms data
|
|
|
|
await search("corrupted kingdoms");
|
|
|
|
|
|
|
|
// Search for Summertime Saga data
|
|
|
|
await search("summertime saga");
|
|
|
|
});
|
|
|
|
|
|
|
|
async function auth() {
|
2020-11-01 08:54:59 +00:00
|
|
|
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}`);
|
|
|
|
|
2020-11-01 13:56:07 +00:00
|
|
|
console.log("Authenticating...");
|
2020-11-01 20:56:12 +00:00
|
|
|
const result = await networkHelper.autenticate(creds);
|
|
|
|
console.log(`Authentication result: ${result.message}`);
|
|
|
|
|
|
|
|
return result.success;
|
|
|
|
}
|
2020-11-01 08:54:59 +00:00
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
async function search(gamename) {
|
|
|
|
console.log(`Searching '${gamename}'...`);
|
|
|
|
const urls = await searcher.searchGame(gamename);
|
2020-10-31 15:00:26 +00:00
|
|
|
console.log(`Found: ${urls}`);
|
|
|
|
|
|
|
|
console.log("Scraping data...");
|
|
|
|
for (const url of urls) {
|
|
|
|
const gamedata = await scraper.getGameInfo(url);
|
2020-11-01 20:56:12 +00:00
|
|
|
console.log(`Found ${gamedata.name} (${gamedata.version}) by ${gamedata.author}`);
|
2020-10-29 21:14:40 +00:00
|
|
|
}
|
2020-10-31 15:00:26 +00:00
|
|
|
console.log("Scraping completed!");
|
2020-10-03 14:42:29 +00:00
|
|
|
}
|