Giter VIP home page Giter VIP logo

f95api's Introduction

CodeFactor FOSSA Status Known Vulnerabilities codecov npm

F95API

Unofficial Typescript API used for data scraping from the 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 (NSFW)

A simple usage example can be found in src/example.ts

Table of Contents

Main features

  • Support for two-factor authentication
  • Structured and typed data of games, mods, comics, assets and animations
  • Structured and typed data of the current user (threads followed, favorites...)
  • Structured and typed data of other users (titles, donations, registration date...)
  • Standard search, through the "Latest Updates" page or advanced
  • Saving of cookies to maintain the session

Login

In addition to traditional login, two-factor authentication via callback that returns the OTP value is also supported.

// Normal login
let result = await F95API.login(username, password);

// 2FA login
let 2faCallback = function () => Promise<number>;
let result = await F95API.login(username, password, 2faCallback);

Refer to src/example.ts (lines 35-67) for a working example.

Data scraping

Each game, mod, comic, animation or asset is identified as handiwork and obtaining this element is generic, it will then be up to the user to decide which property to use based on the type of handiwork that has been requested.

Handiworks can be obtained by query or by URL.

// With query
const query = {
    category: "games";
    keywords = "Your game name";
    order = "likes";
};

let listOfFoundGames = await F95API.searchHandiwork<Game>(query);

// With URL
let specificGame = await F95API.getHandiworkFromURL<Game>("the URL of your game");

While user data (after authenticating) with

const userdata = new UserProfile();

// Fetch basic data (always necessary)
await userdata.fetch();

// Fetch all data (may take a while)
await userdata.fetch(true);

// Async properties
const threads = await userdata.watched;
const bookmarks = await userdata.bookmarks;
const alerts = await userdata.alerts;
const games = await userdata.featuredGames;

Classes

Handiwork

Information about games, mods, etc... are stored in a Handiwork object with the following fields:

Basic properties

This list of properties is common to every handiwork, be it a game, a comic, etc...

Property Type Description
id number Unique ID of the thread associated with the handiwork in the platform
name string The handiwork name
overview string Description of the handiwork
authors TAuthor[] The developer of this handiwork including the platforms on which it can be found
category TCategory The membership category
changelog TChangelog[] List of changes divided by version
cover string URL of the possible cover of the handiwork (in case of multiple images the first available is taken)
lastThreadUpdate Date Date of the last update of the thread associated with the handiwork
prefixes string[] List of prefixes
rating TRating Users' ratings on the handiwork (average, maximum, minimum, number of votes)
tags string[] List of tags
threadPublishingDate Date Publication date of the thread associated with the handiwork
url string The URL that leads to the handiwork's thread on F95Zone

Mixed properties

Each property is specific to a particular type of handiwork.

Property Type Handiwork type Description
genre string[] Animation/Comic/Game List of genres represented in this work
pages string Animation/Comic Number of pages or elements of which the work is composed
resolution string[] Animation/Comic List of resolutions available for the work
installation string Animation Installation instructions
language string[] Animation List of available languages
length string Animation Length of the animation
censored boolean Animation/Game Are the NSFW parts censored?
engine TEngine Game Game engine (Unity, Ren'Py, RPGM...)
lastRelease Date Game Date of the last update of this handiwork
mod boolean Game Specify if it is a mod or a real game
os string[] Game List of supported OS (Windows/Linux/Mac/Android...)
status TStatus Game State of development (Completed/Abandoned/Ongoing/Onhold)
version string Game Version of the handiwork
assetLink string Asset External URL of the asset (es. Daz3D store)
associatedAssets string[] Asset List of URLs of assets associated with the work (for example same collection)
compatibleSoftware string[] Asset Software compatible with the work
includedAssets string[] Asset List of assets url included in the work or used to develop it
officialLinks string[] Asset List of official links of the work, external to the platform (es. Daz3D store)
sku string Asset Unique SKU value of the work

The serialization/deserialization in JSON format of this object is possible through JSON.stringify()/JSON.parse().

Platform user

A generic user registered on the platform is represented by a PlatformUser object with the following fields:

Property Type Description
id number Unique user ID
name string Username
title string Title assigned to the user by the platform
banners string[] List of banners assigned by the platform
messages number Number of messages written by the user
reactionScore number Total number of reactions received from other users
points number Total number of points received after the acquisition of trophies
ratingsReceived number Number of ratings received
joined Date Date of joining the platform
lastSeen Date Date of the last connection to the platform
followed boolean Indicates whether the user is followed by the currently logged in user
ignored boolean Indicates whether the user is ignored by the currently logged on user
private boolean Indicates that the profile is private and not viewable by the user
avatar string URL of the image used as the user's avatar
amountDonated number Value ($) of donations made

User data

The user data currently connected through this API extends the PlatformUser class via the class UserProfile and adds:

Property Type Description
watched Promise<IWatchedThread[]> List of followed thread data
bookmarks Promise<IBookmarkedPost[]> List of bookmarked posts data
alerts Promise<IAlert[]> List of alerts
conversations Promise<IConversation[]> List of conversations (only without labels)
featuredGames Promise<Game[]> List of featured games from the platform (carousel, may not be available if disabled in settings)

Login results

The outcome of the authentication process is represented by the LoginResult object:

Property Type Description
success boolean List of followed thread data
code number Code associated with the result of the login operation
message string Possible error message (unrecognized user, wrong password...) or authentication successful message

Logging

To log the behavior of the application log4js-api 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
  • Return null only if the function should return a complex object (including strings)
  • Return an empty array if the function should return an array
  • Return false, -1 when the function should return boolean or number
  • Throw an exception only if it is an error or if a wrong value could mess up the functioning of the library
  • For all network operations, return a Result object

f95api's People

Contributors

code-factor avatar deepsource-autofix[bot] avatar deepsourcebot avatar dependabot[bot] avatar fossabot avatar millenniumearl avatar moulik-deepsource avatar renovate-bot avatar renovate[bot] avatar samueleberlusconi avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

f95api's Issues

Example not working

Describe the bug
When I npm run the example I get the error show in the screenshot

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'termina'
  2. Run on 'npm run example'
  3. See error

Expected behavior
For the example to work.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Brave
  • Version: 1.51.114

Missing overview and release date on old thread

Describe the bug
On threads with an old template it is not possible to obtain information on the release date or overview because different keywords are used, such as "Story" instead of "Overview" and "Updated" instead of "Release date".

It is also recommended to use Regex in the release dates to get the dates if they are mixed with other information (see example).

Additional context
Some sites where the reported problems occur:

Site's new DDOS-GUARD DDOS protection is resulting in errors when scraping

I see this when running the example with the correct credentials. I can confirm that this worked a few days ago when was testing #257. Pretty sure this is caused by the newly added DDOS protection from DDOS-GUARD. Need to debug this further and probably look into bypassing DDOS-GUARD (could be something custom or a lib).

f95api: v2.0.0-beta.12
Node.js: v17.6.0
Windows 10: v19044.1586

PS G:\dev\code\F95API> npm run example

> @millenniumearl/[email protected] example     
> npm run build && node --inspect ./dist/example.js


> @millenniumearl/[email protected] prebuild
> node -p "'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'" > src/version.ts


> @millenniumearl/[email protected] build
> npm run prebuild && tsc --project ./      


> @millenniumearl/[email protected] prebuild
> node -p "'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'" > src/version.ts

Debugger listening on ws://127.0.0.1:9229/cedbfbf7-6837-4df6-ba8e-3fb0e50b85d3
For help, see: https://nodejs.org/en/docs/inspector
Authenticating...
G:\dev\code\F95API\dist\scripts\network-helper.js:111
        throw new errors_1.InvalidF95Token(`Invalid token for auth: ${credentials.token}`);
              ^

InvalidF95Token [Error]: Invalid token for auth: undefined
    at authenticate (G:\dev\code\F95API\dist\scripts\network-helper.js:111:15)        
    at loginInTheRemotePlatform (G:\dev\code\F95API\dist\scripts\login.js:105:58)     
    at login (G:\dev\code\F95API\dist\scripts\login.js:47:29)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async authenticate (G:\dev\code\F95API\dist\example.js:72:20)
    at async main (G:\dev\code\F95API\dist\example.js:143:9)

(JS-0134) Prefer or disallow trailing commas

Description

Trailing commas in object literals are valid according to the ECMAScript 5 (and ECMAScript 3!) spec. However, IE8 (when not in IE8 document mode) and below will throw an error when it encounters trailing commas in JavaScript. var foo = { bar: &quot;baz&quot;, qux: &quot;quux&quot;, }; Trailing commas …

Occurrences

There are 21 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/MillenniumEarl/F95API/issue/JS-0134/occurrences/

Missing ld+json with Dark Mode BETA Theme

Describe the bug
The use of Dark Mode BETA Theme prevents the use of F95API as one of the two ld+json script tags is not present in the HTML source of the thread's pages. In particular is missing the script containing "@type":"DiscussionForumPosting",

To Reproduce
Steps to reproduce the behavior:

  1. Change the theme from White theme/UI.X.Dark to Dark Mode BETA
  2. Use the module to search for a thread
  3. Expect an error at utils > getDateFromString line 16 because s is undefined.

Expected behavior
There should be no usage differences based on the theme chosen by the user.

Additional context
Since the problem is with the site, a report has been opened on the site at this address.

I can't find your contacts :)

Hey mate! I'm going to use your npm package f95api for my project and instead of this I think it will be a good idea to ask you join us with developing our project which is similar to yours. We've got 1 junior frontend, 1 junior+ frontend< 1 ux/ui designer and me node.js senior dev/PM/team lead. If you interested - welcome to my telegram @fpavlik or email [email protected]
Hope to see you soon :3

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error: expecting String near ], sched

(JS-0097) Found some unnecessary escape characters

Description

Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect, as demonstrated in the following example: js let foo = &quot;hol\a&quot;; // &gt; foo = &quot;hola&quot; let bar = `${foo}\!`; // &gt; bar = &quot;hola!&quot; let baz = /\:/ // same functionality with /:/ Example …

Occurrences

There is 1 occurrence of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/MillenniumEarl/F95API/issue/JS-0097/occurrences/

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update codecov/codecov-action action to v4
  • Update dependency axios-cookiejar-support to v5
  • Update dependency c8 to v10
  • Update dependency chai-as-promised to v8
  • Update dependency eslint to v9
  • Update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v3
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/coverage.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3.3.3
  • codecov/codecov-action v3.1.6
npm
package.json
  • @log4js-node/log4js-api ^1.0.2
  • await-semaphore ^0.1.3
  • axios ^1.0.0
  • axios-cookiejar-support ^4.0.2
  • axios-retry ^3.2.5
  • cheerio ^1.0.0-rc.12
  • iso-datestring-validator ^2.2.2
  • js-sha256 ^0.11.0
  • tough-cookie ^4.0.0
  • @millenniumearl/recaptcha-harvester 1.2.1
  • @types/chai 4.3.16
  • @types/chai-as-promised 7.1.8
  • @types/chai-spies 1.0.6
  • @types/mocha ^10.0.1
  • @types/mock-fs 4.13.4
  • @types/node 18.19.34
  • @types/rewire 2.5.30
  • @types/tough-cookie 4.0.5
  • @typescript-eslint/eslint-plugin 6.21.0
  • @typescript-eslint/parser 6.21.0
  • c8 8.0.1
  • chai 4.4.1
  • chai-as-promised 7.1.2
  • chai-spies 1.1.0
  • dotenv 16.4.5
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-prettier 4.2.1
  • inquirer ^9.0.0
  • log4js 6.9.1
  • mocha 10.4.0
  • mock-fs 5.2.0
  • prettier 2.8.8
  • rewire 7.0.0
  • ts-node 10.9.2
  • typescript 5.4.5
  • node >=14.0

  • Check this box to trigger a request for Renovate to run again on this repository

Undefined version on old thread template

Describe the bug
Older games that are described on threads using a different template than the current one have an undefined version field. This can be caused by the fact that the version is written in bold type or that "Version" is not present in the thread.

Should switch back to get the version from the title?

Additional context
Some threads on which the problem occurred:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.