fix: correct ebay title filtering and type contracts

This commit is contained in:
2026-04-27 02:04:48 -04:00
parent b73faa35da
commit 224e83ac4c
5 changed files with 69 additions and 8 deletions

View File

@@ -205,16 +205,18 @@ function parseEbayListings(
"opens in a new window or tab",
];
let shortened = false;
for (const uiString of uiStrings) {
const uiIndex = title.indexOf(uiString);
if (uiIndex !== -1) {
title = title.substring(0, uiIndex).trim();
shortened = true;
break; // Only remove one UI string per title
}
}
// If the title became empty or too short after cleaning, skip this item
if (title.length < 10) {
// If the title was shortened by UI cleaning and became too short, skip this item
if (shortened && title.length < 10) {
continue;
}
}

View File

@@ -899,6 +899,11 @@ export function parseFacebookAds(
if (Number.isNaN(dollars)) continue;
cents = Math.round(dollars * 100);
} else if (
typeof priceObj.formatted_amount === "string" &&
priceObj.formatted_amount.toUpperCase() === "FREE"
) {
cents = 0;
} else {
continue; // No price available
}
@@ -1192,8 +1197,7 @@ export default async function fetchFacebookItems(
? new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic)
: null;
const totalProgress = ads.length;
const currentProgress = 0;
progressBar?.start(totalProgress, currentProgress);
progressBar?.start(totalProgress, 0);
const items = parseFacebookAds(ads);

View File

@@ -254,7 +254,7 @@ export function resolveCategoryId(category?: number | string): number {
function matchesPriceFilters(
listing: DetailedListing,
searchOptions: Required<SearchOptions>,
searchOptions: SearchOptions,
): boolean {
const cents = listing.listingPrice?.cents;
@@ -971,9 +971,7 @@ export default async function fetchKijijiItems(
console.log(
`\nParsed ${filteredListings.length} detailed listings.`,
);
return unstableMode.hideUnstableResults
? finalizeResults(filteredListings)
: finalizeResults(filteredListings);
return finalizeResults(filteredListings);
}
// Re-export error classes for convenience