Sobstitute URL object to string for compatibility
parent
2db1b6a1f8
commit
ac3f0e8acf
14
app/index.js
14
app/index.js
|
@ -195,7 +195,7 @@ module.exports.getGameVersion = async function (info) {
|
||||||
return info.version;
|
return info.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
let urlExists = await urlExist(info.f95url.toString());
|
let urlExists = await urlExist(info.f95url);
|
||||||
|
|
||||||
// F95 change URL at every game update, so if the URL is the same no update is available
|
// F95 change URL at every game update, so if the URL is the same no update is available
|
||||||
if (urlExists) return info.version;
|
if (urlExists) return info.version;
|
||||||
|
@ -286,7 +286,7 @@ module.exports.getUserData = async function () {
|
||||||
|
|
||||||
let ud = new UserData();
|
let ud = new UserData();
|
||||||
ud.username = username;
|
ud.username = username;
|
||||||
ud.avatarSrc = isStringAValidURL(avatarSrc) ? new URL(avatarSrc) : null;
|
ud.avatarSrc = isStringAValidURL(avatarSrc) ? avatarSrc : null;
|
||||||
ud.watchedThreads = await threads;
|
ud.watchedThreads = await threads;
|
||||||
|
|
||||||
await page.close();
|
await page.close();
|
||||||
|
@ -504,7 +504,7 @@ async function loginF95(browser, username, password) {
|
||||||
* @private
|
* @private
|
||||||
* Gets the list of URLs of threads the user follows.
|
* Gets the list of URLs of threads the user follows.
|
||||||
* @param {puppeteer.Browser} browser Browser object used for navigation
|
* @param {puppeteer.Browser} browser Browser object used for navigation
|
||||||
* @returns {Promise<URL[]>} URL list
|
* @returns {Promise<String[]>} URL list
|
||||||
*/
|
*/
|
||||||
async function getUserWatchedGameThreads(browser) {
|
async function getUserWatchedGameThreads(browser) {
|
||||||
let page = await preparePage(browser); // Set new isolated page
|
let page = await preparePage(browser); // Set new isolated page
|
||||||
|
@ -543,7 +543,7 @@ async function getUserWatchedGameThreads(browser) {
|
||||||
handle
|
handle
|
||||||
);
|
);
|
||||||
// If 'unread' is left, it will redirect to the last unread post
|
// If 'unread' is left, it will redirect to the last unread post
|
||||||
let url = new URL(src.replace("/unread", ""));
|
let url = src.replace("/unread", "");
|
||||||
urls.push(url);
|
urls.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ async function getUserWatchedGameThreads(browser) {
|
||||||
* Search the F95Zone portal to find possible conversations regarding the game you are looking for.
|
* Search the F95Zone portal to find possible conversations regarding the game you are looking for.
|
||||||
* @param {puppeteer.Browser} browser Browser object used for navigation
|
* @param {puppeteer.Browser} browser Browser object used for navigation
|
||||||
* @param {String} gamename Name of the game to search for
|
* @param {String} gamename Name of the game to search for
|
||||||
* @returns {Promise<URL[]>} List of URL of possible games obtained from the preliminary research on the F95 portal
|
* @returns {Promise<String[]>} List of URL of possible games obtained from the preliminary research on the F95 portal
|
||||||
*/
|
*/
|
||||||
async function getSearchGameResults(browser, gamename) {
|
async function getSearchGameResults(browser, gamename) {
|
||||||
if (shared.debug) console.log("Searching " + gamename + " on F95Zone");
|
if (shared.debug) console.log("Searching " + gamename + " on F95Zone");
|
||||||
|
@ -615,7 +615,7 @@ async function getSearchGameResults(browser, gamename) {
|
||||||
* Return the link of a conversation if it is a game or a mod
|
* Return the link of a conversation if it is a game or a mod
|
||||||
* @param {puppeteer.Page} page Page containing the conversation to be analyzed
|
* @param {puppeteer.Page} page Page containing the conversation to be analyzed
|
||||||
* @param {puppeteer.ElementHandle} titleHandle Title of the conversation to be analyzed
|
* @param {puppeteer.ElementHandle} titleHandle Title of the conversation to be analyzed
|
||||||
* @return {Promise<URL>} URL of the game/mod
|
* @return {Promise<String>} URL of the game/mod
|
||||||
*/
|
*/
|
||||||
async function getOnlyGameThreads(page, titleHandle) {
|
async function getOnlyGameThreads(page, titleHandle) {
|
||||||
const GAME_RECOMMENDATION_PREFIX = "RECOMMENDATION";
|
const GAME_RECOMMENDATION_PREFIX = "RECOMMENDATION";
|
||||||
|
@ -625,7 +625,7 @@ async function getOnlyGameThreads(page, titleHandle) {
|
||||||
/* istanbul ignore next */ (element) => element.querySelector("a").href,
|
/* istanbul ignore next */ (element) => element.querySelector("a").href,
|
||||||
titleHandle
|
titleHandle
|
||||||
);
|
);
|
||||||
let url = new URL(relativeURLThread, constURLs.F95_BASE_URL);
|
let url = new URL(relativeURLThread, constURLs.F95_BASE_URL).toString();
|
||||||
|
|
||||||
// Parse prefixes to ignore game recommendation
|
// Parse prefixes to ignore game recommendation
|
||||||
for (let element of await titleHandle.$$('span[dir="auto"]')) {
|
for (let element of await titleHandle.$$('span[dir="auto"]')) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ class GameDownload {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* Link to game files
|
* Link to game files
|
||||||
* @type URL
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.link = null;
|
this.link = null;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,7 @@ class GameInfo {
|
||||||
this.author = UNKNOWN;
|
this.author = UNKNOWN;
|
||||||
/**
|
/**
|
||||||
* URL to the game's official conversation on the F95Zone portal
|
* URL to the game's official conversation on the F95Zone portal
|
||||||
* @type URL
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.f95url = null;
|
this.f95url = null;
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +42,7 @@ class GameInfo {
|
||||||
this.status = UNKNOWN;
|
this.status = UNKNOWN;
|
||||||
/**
|
/**
|
||||||
* Game description image URL
|
* Game description image URL
|
||||||
* @type URL
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.previewSource = null;
|
this.previewSource = null;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@ class UserData {
|
||||||
this.username = "";
|
this.username = "";
|
||||||
/**
|
/**
|
||||||
* Path to the user's profile picture.
|
* Path to the user's profile picture.
|
||||||
* @type URL
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.avatarSrc = null;
|
this.avatarSrc = null;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,7 @@ const { isStringAValidURL, isF95URL } = require("./urls-helper.js");
|
||||||
* @protected
|
* @protected
|
||||||
* Get information from the game's main page.
|
* Get information from the game's main page.
|
||||||
* @param {puppeteer.Browser} browser Browser object used for navigation
|
* @param {puppeteer.Browser} browser Browser object used for navigation
|
||||||
* @param {URL} url URL of the game/mod to extract data from
|
* @param {String} url URL (String) of the game/mod to extract data from
|
||||||
* @return {Promise<GameInfo>} Complete information about the game you are looking for
|
* @return {Promise<GameInfo>} Complete information about the game you are looking for
|
||||||
*/
|
*/
|
||||||
module.exports.getGameInfo = async function (browser, url) {
|
module.exports.getGameInfo = async function (browser, url) {
|
||||||
|
@ -25,12 +25,12 @@ module.exports.getGameInfo = async function (browser, url) {
|
||||||
|
|
||||||
// Verify the correctness of the URL
|
// Verify the correctness of the URL
|
||||||
if (!isF95URL(url)) throw url + " is not a valid F95Zone URL";
|
if (!isF95URL(url)) throw url + " is not a valid F95Zone URL";
|
||||||
let exists = await urlExist(url.toString());
|
let exists = await urlExist(url);
|
||||||
if (!exists) return new GameInfo();
|
if (!exists) return new GameInfo();
|
||||||
|
|
||||||
let page = await preparePage(browser); // Set new isolated page
|
let page = await preparePage(browser); // Set new isolated page
|
||||||
await page.setCookie(...shared.cookies); // Set cookies to avoid login
|
await page.setCookie(...shared.cookies); // Set cookies to avoid login
|
||||||
await page.goto(url.toString(), {
|
await page.goto(url, {
|
||||||
waitUntil: shared.WAIT_STATEMENT,
|
waitUntil: shared.WAIT_STATEMENT,
|
||||||
}); // Go to the game page and wait until it loads
|
}); // Go to the game page and wait until it loads
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ function parseConversationPage(text) {
|
||||||
* @private
|
* @private
|
||||||
* Gets the URL of the image used as a preview for the game in the conversation.
|
* Gets the URL of the image used as a preview for the game in the conversation.
|
||||||
* @param {puppeteer.Page} page Page containing the URL to be extrapolated
|
* @param {puppeteer.Page} page Page containing the URL to be extrapolated
|
||||||
* @returns {Promise<URL>} URL of the image or null if failed to get it
|
* @returns {Promise<String>} URL (String) of the image or null if failed to get it
|
||||||
*/
|
*/
|
||||||
async function getGamePreviewSource(page) {
|
async function getGamePreviewSource(page) {
|
||||||
let src = await page.evaluate(
|
let src = await page.evaluate(
|
||||||
|
@ -172,7 +172,7 @@ async function getGamePreviewSource(page) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if the URL is valid
|
// Check if the URL is valid
|
||||||
return isStringAValidURL(src) ? new URL(src) : null;
|
return isStringAValidURL(src) ? src : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,7 +364,7 @@ function extractGameHostingData(platform, text) {
|
||||||
if (isStringAValidURL(link)) {
|
if (isStringAValidURL(link)) {
|
||||||
let gd = new GameDownload();
|
let gd = new GameDownload();
|
||||||
gd.hosting = hosting.toUpperCase();
|
gd.hosting = hosting.toUpperCase();
|
||||||
gd.link = new URL(link);
|
gd.link = link;
|
||||||
gd.supportedOS = platform.toUpperCase();
|
gd.supportedOS = platform.toUpperCase();
|
||||||
|
|
||||||
downloadData.push(gd);
|
downloadData.push(gd);
|
||||||
|
|
|
@ -68,7 +68,7 @@ class Shared {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* List of cookies obtained from the F95Zone platform.
|
* List of cookies obtained from the F95Zone platform.
|
||||||
* @returns {bject[]}
|
* @returns {Object[]}
|
||||||
*/
|
*/
|
||||||
static get cookies() {
|
static get cookies() {
|
||||||
return this._cookies;
|
return this._cookies;
|
||||||
|
|
|
@ -8,7 +8,7 @@ const {
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* Check if the url belongs to the domain of the F95 platform.
|
* Check if the url belongs to the domain of the F95 platform.
|
||||||
* @param {URL} url URL to check
|
* @param {String} url URL to check
|
||||||
* @returns {Boolean} true if the url belongs to the domain, false otherwise
|
* @returns {Boolean} true if the url belongs to the domain, false otherwise
|
||||||
*/
|
*/
|
||||||
module.exports.isF95URL = function(url) {
|
module.exports.isF95URL = function(url) {
|
||||||
|
|
Loading…
Reference in New Issue