google trends

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-06-08 07:07:49 +02:00
padre 6bc4955f3d
commit 752d5d3f6d
Se han modificado 2 ficheros con 4 adiciones y 237 borrados

Ver fichero

@@ -394,8 +394,6 @@ async function searchVideos(query, limit = 5) {
// Function to get trending topics with country-specific sources
async function getTrends(country = 'US') {
try {
console.log(`📊 Fetching trends for ${country}...`);
// Try country-specific sources first
const countryTrends = await getCountrySpecificTrends(country);
if (countryTrends && Object.keys(countryTrends).length > 0) {
@@ -407,7 +405,6 @@ async function getTrends(country = 'US') {
return redditTrends;
} catch (error) {
console.error('❌ Error fetching trends:', error.message);
throw error;
}
}
@@ -426,7 +423,7 @@ async function getCountrySpecificTrends(country) {
sourcesSucceeded++;
}
} catch (redditError) {
console.log(`Reddit trends failed for ${country}: ${redditError.message}`);
// Reddit failure handled silently
}
// Get news headlines for the country (non-blocking)
@@ -438,7 +435,6 @@ async function getCountrySpecificTrends(country) {
}
} catch (newsError) {
// News failure is not critical - Reddit trends are sufficient
console.log(`News trends failed for ${country}, continuing with Reddit only`);
}
// Return trends if we got data from at least one source
@@ -450,7 +446,6 @@ async function getCountrySpecificTrends(country) {
return {};
} catch (error) {
console.error('Country trends error:', error.message);
return {}; // Return empty to trigger global fallback
}
}
@@ -502,7 +497,7 @@ async function getCountryRedditTrends(country) {
await new Promise(resolve => setTimeout(resolve, 200));
} catch (subredditError) {
console.log(`Failed to fetch from r/${subreddit}:`, subredditError.message);
// Subreddit failed silently - continue to next one
}
}
@@ -565,7 +560,7 @@ async function getNewsHeadlines(country) {
return groupedTrends;
}
} catch (apiError) {
console.log(`Primary news API failed for ${country}: ${apiError.message}`);
// Primary news API failed silently
}
// Fallback: Try alternative news endpoint
@@ -591,7 +586,7 @@ async function getNewsHeadlines(country) {
return groupedTrends;
}
} catch (fallbackError) {
console.log(`Fallback news API also failed: ${fallbackError.message}`);
// Fallback news API also failed silently
}
// If both APIs fail, return empty object (don't log error - it's handled gracefully)