From 20524f75e65445817aa944ab2dd9a9f4a13380bc Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Mon, 2 Nov 2020 15:46:07 +0100 Subject: [PATCH] Updated readme --- README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ app/example.js | 9 ++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 56ff3af..73ae63c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,75 @@ Unofficial Node JS module for scraping F95Zone platform +These APIs have been developed to support this application and allow you to obtain data on games and mods on the platform [F95zone.to](www.f95zone.to) + +A simple usage example can be found in [app/example.js](https://github.com/MillenniumEarl/F95API/blob/master/app/example.js) + +**Attention**: Two-factor authentication is not supported + +# Data scraping +Games/mods can be obtained by name or URL + +```javascript +// The name is case insensitive +let listOfFoundGames = await F95API.getGameData("your game name"); +let listOfFoundMods = await F95API.getGameData("your mod name", true); + +let specificGame = await F95API.getGameDataFromURL("the URL of your game"); +``` + +While user data (after authenticating) with + +```javascript +let authResult = await F95API.login(username, password); + +let loggedUserData = await F95API.getUserData(); +``` + +# Classes +## Games and mods +Information about games and mods is stored in a GameInfo object with the following fields: + +``` +name: The game name +author: The game developer +url: The URL that leads to the game thread on F95Zone +overview: Description of the game +language: Main language of the game +supportedOS: List of supported OS (Windows/Linux/Mac/Android...) +censored: Are the NSFW parts censored? +engine: Game engine (Unity, Ren'Py, RPGM...) +status: Completed/Abandoned/Ongoing/Onhold +tags: List of tags +previewSrc: Source URL of the game description image +version: Version of the game +lastUpdate: Date of the last update (it's a Date object) +isMod: Is it a game or a mod? +changelog: Latest changelog available +``` + +The serialization in JSON format of this object is possible through `JSON.stringfy()` while the deserialization must happen through the static method `GameInfo.fromJSON()`. + +## User data +User data (after authentication) can be stored in a UserData object, consisting of the following fields: + +``` +username: Name of the logged in user +avatarSrc: Source URL of the user's profile picture +watchedThreads: List of URLs of threads followed by the user +``` + +## Login results +The outcome of the authentication process is represented by the LoginResult object: + +``` +success: Was the authentication successful?; +message: Possible error message (unrecognized user, wrong password ...) or authentication successful message +``` + +# Logging +To log the behavior of the application log4js is used with a default level of "warn". This option can be changed with the loggerLevel property. + # Guidelines for errors - If you can, return a meaningful value diff --git a/app/example.js b/app/example.js index 286425e..48eac22 100644 --- a/app/example.js +++ b/app/example.js @@ -1,3 +1,11 @@ +/* +to use this example, create an .env file +in the project root with the following values: + +F95_USERNAME = YOUR_USERNAME +F95_PASSWORD = YOUR_PASSWORD +*/ + "use strict"; // Public modules from npm @@ -9,7 +17,6 @@ const F95API = require("./index.js"); // Configure the .env reader dotenv.config(); - main(); async function main() {