fix: refine scraper output behavior

This commit is contained in:
2026-04-23 10:43:38 -04:00
parent 244a88e63c
commit 9c8643086a
4 changed files with 141 additions and 7 deletions

View File

@@ -87,6 +87,12 @@ function parseEbayPrice(
cleaned.toUpperCase().includes("US $")
) {
currency = "USD";
} else if (cleaned.includes("£")) {
currency = "GBP";
} else if (cleaned.includes("€")) {
currency = "EUR";
} else if (cleaned.includes("¥")) {
currency = "JPY";
}
return { cents, currency };

View File

@@ -1180,13 +1180,13 @@ export default async function fetchFacebookItems(
console.log(`\nFound ${ads.length} raw ads. Processing...`);
const progressBar = new cliProgress.SingleBar(
{},
cliProgress.Presets.shades_classic,
);
const isTTY = process.stdout?.isTTY ?? false;
const progressBar = isTTY
? new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic)
: null;
const totalProgress = ads.length;
const currentProgress = 0;
progressBar.start(totalProgress, currentProgress);
progressBar?.start(totalProgress, currentProgress);
const items = parseFacebookAds(ads);
@@ -1196,8 +1196,8 @@ export default async function fetchFacebookItems(
typeof item.listingPrice?.cents === "number" && item.listingPrice.cents >= 0,
);
progressBar.update(totalProgress);
progressBar.stop();
progressBar?.update(totalProgress);
progressBar?.stop();
console.log(`\nParsed ${pricedItems.length} Facebook marketplace listings.`);
return finalizeResults(pricedItems);