From 395e25aa37951660924e557ba21f9bf94debf477 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Sun, 31 Dec 2023 18:15:45 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Added=20a=20socket.io?= =?UTF-8?q?=20event=20for=20CV=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + services/comicvine.service.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c4e6a9d..b2900c9 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,4 @@ typings/ dist/ .vscode userdata +.DS_Store diff --git a/services/comicvine.service.ts b/services/comicvine.service.ts index 72f072a..0ca86e4 100644 --- a/services/comicvine.service.ts +++ b/services/comicvine.service.ts @@ -95,7 +95,7 @@ export default class ComicVineService extends Service { filter: `volume:${comicBookDetails.sourcedMetadata.comicvine.volumeInformation.id}`, }, headers: { - "Accept": "application/json", + Accept: "application/json", "User-Agent": "ThreeTwo", }, }); @@ -192,7 +192,7 @@ export default class ComicVineService extends Service { ); const results: any = []; console.log( - "passed to fetchvolumesfromcv", + "passed to fetchVolumesFromCV", ctx.params ); const volumes = await this.fetchVolumesFromCV( @@ -254,7 +254,7 @@ export default class ComicVineService extends Service { filter: filterString, }, headers: { - "Accept": "application/json", + Accept: "application/json", "User-Agent": "ThreeTwo", }, }); @@ -315,7 +315,7 @@ export default class ComicVineService extends Service { resources, }, headers: { - "Accept": "application/json", + Accept: "application/json", "User-Agent": "ThreeTwo", }, }); @@ -335,11 +335,24 @@ export default class ComicVineService extends Service { output.push(...data.results); currentPage += 1; // Params.page = currentPage; + console.log( `Fetching results for page ${currentPage} (of ${ totalPages + 1 })...` ); + + await this.broker.call("socket.broadcast", { + namespace: "/", + event: "CV_SCRAPING_STATUS", + args: [ + { + message: `Fetching results for page ${currentPage} (of ${ + totalPages + 1 + })...`, + }, + ], + }); return await this.fetchVolumesFromCV( { format,