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;
|
||||
}
|
||||
|
||||
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
|
||||
if (urlExists) return info.version;
|
||||
|
@ -286,7 +286,7 @@ module.exports.getUserData = async function () {
|
|||
|
||||
let ud = new UserData();
|
||||
ud.username = username;
|
||||
ud.avatarSrc = isStringAValidURL(avatarSrc) ? new URL(avatarSrc) : null;
|
||||
ud.avatarSrc = isStringAValidURL(avatarSrc) ? avatarSrc : null;
|
||||
ud.watchedThreads = await threads;
|
||||
|
||||
await page.close();
|
||||
|
@ -504,7 +504,7 @@ async function loginF95(browser, username, password) {
|
|||
* @private
|
||||
* Gets the list of URLs of threads the user follows.
|
||||
* @param {puppeteer.Browser} browser Browser object used for navigation
|
||||
* @returns {Promise<URL[]>} URL list
|
||||
* @returns {Promise<String[]>} URL list
|
||||
*/
|
||||
async function getUserWatchedGameThreads(browser) {
|
||||
let page = await preparePage(browser); // Set new isolated page
|
||||
|
@ -543,7 +543,7 @@ async function getUserWatchedGameThreads(browser) {
|
|||
handle
|
||||
);
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ async function getUserWatchedGameThreads(browser) {
|
|||
* 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 {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) {
|
||||
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
|
||||
* @param {puppeteer.Page} page Page containing 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) {
|
||||
const GAME_RECOMMENDATION_PREFIX = "RECOMMENDATION";
|
||||
|
@ -625,7 +625,7 @@ async function getOnlyGameThreads(page, titleHandle) {
|
|||
/* istanbul ignore next */ (element) => element.querySelector("a").href,
|
||||
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
|
||||
for (let element of await titleHandle.$$('span[dir="auto"]')) {
|
||||
|
|
|
@ -11,7 +11,7 @@ class GameDownload {
|
|||
/**
|
||||
* @public
|
||||
* Link to game files
|
||||
* @type URL
|
||||
* @type String
|
||||
*/
|
||||
this.link = null;
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ class GameInfo {
|
|||
this.author = UNKNOWN;
|
||||
/**
|
||||
* URL to the game's official conversation on the F95Zone portal
|
||||
* @type URL
|
||||
* @type String
|
||||
*/
|
||||
this.f95url = null;
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ class GameInfo {
|
|||
this.status = UNKNOWN;
|
||||
/**
|
||||
* Game description image URL
|
||||
* @type URL
|
||||
* @type String
|
||||
*/
|
||||
this.previewSource = null;
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ class UserData {
|
|||
this.username = "";
|
||||
/**
|
||||
* Path to the user's profile picture.
|
||||
* @type URL
|
||||
* @type String
|
||||
*/
|
||||
this.avatarSrc = null;
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ const { isStringAValidURL, isF95URL } = require("./urls-helper.js");
|
|||
* @protected
|
||||
* Get information from the game's main page.
|
||||
* @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
|
||||
*/
|
||||
module.exports.getGameInfo = async function (browser, url) {
|
||||
|
@ -25,12 +25,12 @@ module.exports.getGameInfo = async function (browser, url) {
|
|||
|
||||
// Verify the correctness of the 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();
|
||||
|
||||
let page = await preparePage(browser); // Set new isolated page
|
||||
await page.setCookie(...shared.cookies); // Set cookies to avoid login
|
||||
await page.goto(url.toString(), {
|
||||
await page.goto(url, {
|
||||
waitUntil: shared.WAIT_STATEMENT,
|
||||
}); // Go to the game page and wait until it loads
|
||||
|
||||
|
@ -157,7 +157,7 @@ function parseConversationPage(text) {
|
|||
* @private
|
||||
* 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
|
||||
* @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) {
|
||||
let src = await page.evaluate(
|
||||
|
@ -172,7 +172,7 @@ async function getGamePreviewSource(page) {
|
|||
);
|
||||
|
||||
// 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)) {
|
||||
let gd = new GameDownload();
|
||||
gd.hosting = hosting.toUpperCase();
|
||||
gd.link = new URL(link);
|
||||
gd.link = link;
|
||||
gd.supportedOS = platform.toUpperCase();
|
||||
|
||||
downloadData.push(gd);
|
||||
|
|
|
@ -68,7 +68,7 @@ class Shared {
|
|||
}
|
||||
/**
|
||||
* List of cookies obtained from the F95Zone platform.
|
||||
* @returns {bject[]}
|
||||
* @returns {Object[]}
|
||||
*/
|
||||
static get cookies() {
|
||||
return this._cookies;
|
||||
|
|
|
@ -8,7 +8,7 @@ const {
|
|||
/**
|
||||
* @protected
|
||||
* 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
|
||||
*/
|
||||
module.exports.isF95URL = function(url) {
|
||||
|
|
Loading…
Reference in New Issue