2020-11-02 14:46:07 +00:00
|
|
|
/*
|
|
|
|
to use this example, create an .env file
|
|
|
|
in the project root with the following values:
|
|
|
|
|
|
|
|
F95_USERNAME = YOUR_USERNAME
|
|
|
|
F95_PASSWORD = YOUR_PASSWORD
|
|
|
|
*/
|
|
|
|
|
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-02 14:06:09 +00:00
|
|
|
const F95API = require("./index.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-02 09:21:36 +00:00
|
|
|
main();
|
2020-11-01 20:56:12 +00:00
|
|
|
|
2020-11-02 09:21:36 +00:00
|
|
|
async function main() {
|
|
|
|
// Local variables
|
|
|
|
const gameList = [
|
|
|
|
"kingdom of deception",
|
|
|
|
"perverted education",
|
|
|
|
"corrupted kingdoms",
|
|
|
|
"summertime saga",
|
|
|
|
"brothel king"
|
|
|
|
];
|
2020-11-01 08:54:59 +00:00
|
|
|
|
2020-11-02 09:21:36 +00:00
|
|
|
// Log in the platform
|
2020-11-01 13:56:07 +00:00
|
|
|
console.log("Authenticating...");
|
2020-11-02 09:21:36 +00:00
|
|
|
const result = await F95API.login(process.env.F95_USERNAME, process.env.F95_PASSWORD);
|
2020-11-01 20:56:12 +00:00
|
|
|
console.log(`Authentication result: ${result.message}`);
|
2020-11-01 08:54:59 +00:00
|
|
|
|
2020-11-02 09:21:36 +00:00
|
|
|
// Get user data
|
|
|
|
console.log("Fetching user data...");
|
|
|
|
const userdata = await F95API.getUserData();
|
2020-11-07 17:55:20 +00:00
|
|
|
console.log(`${userdata.username} follows ${userdata.watchedGameThreads.length} threads`);
|
2020-11-02 09:21:36 +00:00
|
|
|
|
|
|
|
for(const gamename of gameList) {
|
|
|
|
console.log(`Searching '${gamename}'...`);
|
|
|
|
const found = await F95API.getGameData(gamename, false);
|
|
|
|
|
|
|
|
// If no game is found
|
|
|
|
if (found.length === 0) {
|
|
|
|
console.log(`No data found for '${gamename}'`);
|
|
|
|
continue;
|
|
|
|
}
|
2020-10-31 15:00:26 +00:00
|
|
|
|
2020-11-02 09:21:36 +00:00
|
|
|
// Extract first game
|
|
|
|
const gamedata = found[0];
|
2020-11-07 17:16:20 +00:00
|
|
|
console.log(`Found ${gamedata.name} (${gamedata.version}, ID ${gamedata.id}) by ${gamedata.author}`);
|
2020-10-29 21:14:40 +00:00
|
|
|
}
|
2020-10-03 14:42:29 +00:00
|
|
|
}
|