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

Commit

Permalink
Better debug log sort
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Castle <[email protected]>
  • Loading branch information
Kas-tle committed Apr 23, 2023
1 parent 266e1b8 commit ecfea23
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
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.1.0",
"version": "1.1.1",
"description": "Scrapes an Enjin site via the Enjin API",
"repository": "https://github.com/Kas-tle/EnjinScraper.git",
"author": "Joshua Castle <[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions src/scrapers/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function getApplicationCommentsCid(domain: string, siteAuth: SiteAuth, app
const applicationResonse = await getRequest(domain, `/ajax.php?s=dashboard_applications&cmd=app&app_id=${applicationID}`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
Referer: `Referer https://${domain}/dashboard/applications/application?app_id=${applicationID}`
});
}, '/getApplicationCommentsCid');

const $ = cheerio.load(applicationResonse.data);
const commentsBlockMain = $('.app_comments_block_main');
Expand Down Expand Up @@ -100,7 +100,7 @@ async function getApplication(domain: string, siteAuth: SiteAuth, presetID: stri
const applicationResonse = await throttledGetRequest(domain, `/admin/editmodule/index/editoraction/form-builder/preset/${presetID}`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
Referer: `Referer https://${domain}/admin/editmodule/index/editoraction/index/preset/${presetID}`
}, '/applications');
}, '/getApplication');

const $ = cheerio.load(applicationResonse.data);

Expand Down
6 changes: 3 additions & 3 deletions src/scrapers/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function authenticateAPI(domain: string, email: string, password: s
}

export async function authenticateSite(domain: string, email: string, password: string): Promise<SiteAuth> {
const loginResponse = await getRequest(domain, '/login', {}, '/auth');
const loginResponse = await getRequest(domain, '/login', {}, '/authenticateSite/loginResponse');
const setCookie = loginResponse.headers['set-cookie'];
const cf_bm_token = setCookie!.find((cookie: string) => cookie.includes('__cf_bm'))!.split(';')[0];
const lastviewed = setCookie!.find((cookie: string) => cookie.includes('lastviewed'))!.split(';')[0];
Expand All @@ -45,13 +45,13 @@ export async function authenticateSite(domain: string, email: string, password:

const postLoginResponse = await postRequest(domain, '/login', formData, {
Cookie: `${lastviewed}; enjin_browsertype=web; ${cf_bm_token}`,
}, '/auth');
}, '/authenticateSite');

const phpSessID = postLoginResponse.headers['set-cookie']!.find((cookie: string) => cookie.includes('PHPSESSID'))!.split(';')[0];

const homeResponse = await getRequest(domain, '/', {
Cookie: `${lastviewed}; ${phpSessID}; enjin_browsertype=web; ${cf_bm_token}; login_temp=1`,
}, '/auth');
}, '/authenticateSite/homeResponse');

const csrfToken = homeResponse.headers['set-cookie']!.find((cookie: string) => cookie.includes('csrf_token'))!.split(';')[0];

Expand Down
2 changes: 1 addition & 1 deletion src/scrapers/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getComments(database: Database, domain: string, siteAuth:
for (let i = commentCidsCount[0]; i < totalCommentCids; i++) {
const commentResponse = await getRequest(domain, `/ajax.php?s=comments&op=load&start=0&comment_cid=${commentCids[i]}&pageSize=-1&subPageSize=-1`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
}, '/comments');
}, '/getComments');
const response: CommentResponse = commentResponse.data;

const commentsDB: CommentsDB[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/scrapers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function getDirectoryListing(domain: string, siteAuth: SiteAuth, token: st
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
Origin: `https://${domain}`,
Referer: `https://${domain}/admin/files`,
}, '/files');
}, '/getDirectoryListing');

const dirListing: DirectoryListing = dirResponse.data.result;
return dirListing;
Expand Down Expand Up @@ -165,7 +165,7 @@ export async function getFiles(domain: string, database: Database, siteAuth: Sit
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
Origin: `https://${domain}`,
Referer: `https://${domain}/admin/files`,
}, '/files')
}, '/getFiles')
const token = tokenResponse.data.token;

const s3FileUrls: FileData[] = await getS3FileUrls(domain, siteAuth, token, `/${siteID}`);
Expand Down
2 changes: 1 addition & 1 deletion src/scrapers/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function getModuleNews(domain: string, sessionID: string, siteAuth: SiteAu
async function getNewsCommentsCid(domain: string, siteAuth: SiteAuth, moduleID: string, articleID: string): Promise<string | null> {
const newsArticleResonse = await throttledGetRequest(domain, `/home/m/${moduleID}/article/${articleID}`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
}, '/news')
}, '/getNewsCommentsCid')

const $ = cheerio.load(newsArticleResonse.data);
let commentCid = null;
Expand Down
2 changes: 1 addition & 1 deletion src/scrapers/sitedata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MessageType, statusMessage } from '../util/console';
async function fetchSiteDataObject(domain: string, siteAuth: SiteAuth): Promise<SiteData | null> {
const siteResponse = await getRequest(domain, `/admin/modules/index`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`
}, '/sitedata');
}, '/fetchSiteDataObject');

const $ = cheerio.load(siteResponse.data);

Expand Down
2 changes: 1 addition & 1 deletion src/scrapers/tickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async function getTicketsByModule(database: Database, domain: string, sessionID:
async function getTicketUploads(domain: string, siteAuth: SiteAuth, ticketCode: string, ticketModule: String): Promise<TicketUpload[]> {
const homeResponse = await getRequest(domain, `/ajax.php?code=${ticketCode}&s=editmodule_tickets&cmd=ticket_html&preset_id=${ticketModule}&saved_data%5Bmode%5D=public`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
}, '/tickets');
}, '/getTicketUploads');

const uploads: TicketUpload[] = [];
const $ = cheerio.load(homeResponse.data);
Expand Down
2 changes: 1 addition & 1 deletion src/scrapers/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function getAdditionalUserData(domain: string, sessionID: string, s
const userIPsResponse = await throttledGetRequest(domain, `/ajax.php?s=admin_users&cmd=getUserAdditionalData&user_id=${userIDs[i]}`, {
Cookie: `${siteAuth.phpSessID}; ${siteAuth.csrfToken}`,
Referer: `Referer https://${domain}/admin/users`
}, '/userips');
}, '/getAdditionalUserData');

const userIPs: UserIPs = userIPsResponse.data;
await updateRow(database, 'users', 'user_id', userIDs[i], ['ip_history'], [JSON.stringify(userIPs.ips_history)]);
Expand Down
2 changes: 1 addition & 1 deletion src/scrapers/wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async function getModuleUploads(database: Database, domain: string, moduleID: st

export async function getWikis(domain: string, database: Database, wikiModuleIDs: string[]) {
// We'll just get a temp token for this
const cfbmTokenResponse = await getRequest(domain, `/wiki/m/${wikiModuleIDs[0]}`, {}, '/wiki')
const cfbmTokenResponse = await getRequest(domain, `/wiki/m/${wikiModuleIDs[0]}`, {}, '/getWikis')
const setCookie = cfbmTokenResponse.headers['set-cookie'];
const cfbmToken = setCookie!.find((cookie: string) => cookie.includes('__cf_bm'))!.split(';')[0];
const lastviewed = setCookie!.find((cookie: string) => cookie.includes('lastviewed'))!.split(';')[0];
Expand Down

0 comments on commit ecfea23

Please sign in to comment.