Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
fix module double ask
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
  • Loading branch information
Kas-tle committed Apr 25, 2023
1 parent 4406e3a commit 30769b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
8 changes: 4 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function main(): Promise<void> {

// Login to API and get session ID
const sessionID = config.sessionID ? config.sessionID : await authenticateAPI(config.domain, config.email, config.password);

// Login to site and get PHPSESSID and csrf_token
const siteAuth = config.siteAuth ? config.siteAuth : await authenticateSite(config.domain, config.email, config.password);

Expand All @@ -47,7 +47,7 @@ async function main(): Promise<void> {
await initializeTables(database);

// Get site data
if(await isModuleScraped(database, 'site_data')) {
if (await isModuleScraped(database, 'site_data')) {
statusMessage(MessageType.Critical, 'Site data already scraped, moving on...');
} else {
await getSiteData(config.domain, siteAuth, database, siteID);
Expand Down Expand Up @@ -193,7 +193,7 @@ async function main(): Promise<void> {
if (config.disabledModules?.files === true) {
statusMessage(MessageType.Critical, 'Files module disabled, skipping file scraping...');
} else if (
await isModuleScraped(database, 's3_files') &&
await isModuleScraped(database, 's3_files') &&
await isModuleScraped(database, 'wiki_files') &&
await isModuleScraped(database, 'avatar_files') &&
await isModuleScraped(database, 'profile_cover_files') &&
Expand Down Expand Up @@ -230,7 +230,7 @@ async function main(): Promise<void> {
}

deleteFiles([
'./target/recovery/s3_file_progress.json',
'./target/recovery/s3_file_progress.json',
'./target/recovery/wiki_file_progress.json',
'./target/recovery/avatar_file_progress.json',
'./target/recovery/cover_file_progress.json',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "enjinscraper",
"version": "1.5.0",
"version": "1.5.1",
"description": "Scrapes an Enjin site via the Enjin API",
"repository": "https://github.com/Kas-tle/EnjinScraper.git",
"author": "Joshua Castle <packages@kastle.dev",
Expand Down
29 changes: 15 additions & 14 deletions src/util/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,14 @@ import { writeJsonFile } from "./files";
import { MessageType, statusMessage } from "./console";

let id = 0;
let protocol: string;
let retrySeconds = 5;
let retryTimes = 5;

(async function () {
const config = await getConfig();
protocol = config.disableSSL ? 'http' : 'https';
retrySeconds = config.retrySeconds >= 0 ? config.retrySeconds : 0;
retryTimes = config.retryTimes >= 0 ? config.retryTimes : Number.MAX_SAFE_INTEGER;
statusMessage(MessageType.Info, `Using ${protocol} protocol`);
statusMessage(MessageType.Info, `Retrying after ${retrySeconds} seconds between requests for a mximum of ${retryTimes} requests`);
})();

const retryTime = retrySeconds * 1000;

export async function enjinRequest<T>(params: Params, method: string, domain: string, inputHeaders: any = {}): Promise<EnjinResponse<T>> {
const config = await getConfig();
const protocol = config.disableSSL ? 'http' : 'https';
const retrySeconds = config.retrySeconds >= 0 ? config.retrySeconds : 0;
const retryTimes = config.retryTimes >= 0 ? config.retryTimes : Number.MAX_SAFE_INTEGER;
const retryTime = retrySeconds * 1000;

let retries = 0;
while (retries <= retryTimes) {
const qid = (++id).toString().padStart(7, '0');
Expand Down Expand Up @@ -81,6 +72,11 @@ let lastCallTime = 0;

export async function getRequest(domain: string, url: string, headers: any, debugPath = '', overrideDebug = false, responseType: ResponseType | undefined = undefined): Promise<AxiosResponse> {
const config = await getConfig();
const protocol = config.disableSSL ? 'http' : 'https';
const retrySeconds = config.retrySeconds >= 0 ? config.retrySeconds : 0;
const retryTimes = config.retryTimes >= 0 ? config.retryTimes : Number.MAX_SAFE_INTEGER;
const retryTime = retrySeconds * 1000;

let retries = 0;
while (retries <= retryTimes) {
const rid = (++id).toString().padStart(7, '0');
Expand Down Expand Up @@ -151,6 +147,11 @@ export async function throttledGetRequest(domain: string, url: string, headers:

export async function postRequest(domain: string, url: string, data: any, headers: any, debugPath = ''): Promise<AxiosResponse> {
const config = await getConfig();
const protocol = config.disableSSL ? 'http' : 'https';
const retrySeconds = config.retrySeconds >= 0 ? config.retrySeconds : 0;
const retryTimes = config.retryTimes >= 0 ? config.retryTimes : Number.MAX_SAFE_INTEGER;
const retryTime = retrySeconds * 1000;

let retries = 0;
while (retries <= retryTimes) {
const rid = (++id).toString().padStart(7, '0');
Expand Down

0 comments on commit 30769b3

Please sign in to comment.