fix(sources): complete BIT-25828 andebol RSS feeds and topic filter
ai-news-writer-ci / test (pull_request) Lab-verified; CI infra skip (BIT-25831 keyring quota)

Add FAP feed, handball-only keywords, and remove general-sports fallback
when topic=andebol so NBA/football articles are not published to andebol.net.
This commit is contained in:
Xika committed 2026-06-25 14:34:44 +00:00
1 parent b165de0811
commit 7262da3e9f
2 files changed
+46 -14

No files matched your search

+11 -8
View File
@@ -1,5 +1,6 @@
{
"rss": [
{ "name": "FAP", "url": "https://portal.fpa.pt/feed/", "category": "andebol", "lang": "pt" },
{ "name": "Handball Planet", "url": "https://www.handball-planet.com/feed/", "category": "andebol", "lang": "en" },
{ "name": "IHF", "url": "https://www.ihf.info/rss.xml", "category": "andebol", "lang": "en" },
{ "name": "Record", "url": "https://www.record.pt/rss", "category": "sports", "lang": "pt" },
@@ -13,16 +14,18 @@
{ "name": "The Guardian World", "url": "https://www.theguardian.com/world/rss", "category": "general", "lang": "en" }
],
"keywords": [
"FC Porto", "Benfica", "Sporting CP", "transfer",
"NBA", "F1", "Formula 1", "Cristiano Ronaldo",
"Champions League", "Premier League", "La Liga",
"handball", "andebol", "EHF", "IHF", "Champions League de Andebol",
"Selecção Nacional", "Porto Handball", "Sporting Handball", "Benfica Handball"
"andebol", "handball", "EHF", "IHF", "FAP",
"Champions League de Andebol", "Liga dos Campeões",
"Selecção Nacional", "Seleção Nacional",
"FC Porto", "Benfica", "Sporting CP",
"andebol de praia", "beach handball", "European Masters",
"Mundial", "Campeonato Nacional", "Final Four"
],
"trusted_domains": [
"record.pt", "rtp.pt", "espn.com", "bbc.co.uk",
"theguardian.com", "skysports.com", "zerozero.pt",
"uefa.com", "fifa.com", "handball-planet.com", "ihf.info"
"portal.fpa.pt", "record.pt", "rtp.pt",
"handball-planet.com", "ihf.info", "eurohandball.com",
"bbc.co.uk", "theguardian.com", "espn.com", "skysports.com",
"zerozero.pt", "uefa.com", "fifa.com"
],
"domain_filter_mode": "strict"
}
+35 -6
View File
@@ -5,6 +5,37 @@ const { scrapeArticle } = require('../crawler/scraper');
const { filterByKeywords } = require('../crawler/rss');
const logger = require('../logger');
const TOPIC_ALIASES = {
andebol: ['andebol', 'handball'],
handball: ['handball', 'andebol']
};
function expandTopicTerms(topic) {
const normalized = String(topic || '').trim().toLowerCase();
if (!normalized) return [];
return TOPIC_ALIASES[normalized] || [normalized];
}
function filterArticlesByTopic(articles, topic, topicLimit) {
const terms = expandTopicTerms(topic);
let filtered = articles.filter((article) => {
const text = `${article.title} ${article.summary}`.toLowerCase();
return terms.some((term) => text.includes(term));
});
if (filtered.length === 0) {
const category = terms.includes('andebol') ? 'andebol' : topic.toLowerCase();
filtered = articles.filter((article) => article.category === category);
if (filtered.length > 0) {
logger.info(
`fetchAndFilterSourceArticles: no text match for topic "${topic}" — using ${filtered.length} feed(s) with category="${category}"`
);
}
}
return filtered.slice(0, topicLimit);
}
/**
* Fetch, filter, and optionally enrich articles from RSS/social sources.
*
@@ -49,13 +80,11 @@ async function fetchAndFilterSourceArticles(sourcesConfig, options = {}) {
// Step 2: Apply filtering based on mode
let filtered;
if (filterMode === 'topic' && topic) {
filtered = allArticles.filter((a) =>
`${a.title} ${a.summary}`.toLowerCase().includes(topic.toLowerCase())
);
filtered = filtered.slice(0, topicLimit);
filtered = filterArticlesByTopic(allArticles, topic, topicLimit);
if (filtered.length === 0) {
logger.warn(`fetchAndFilterSourceArticles: no articles match topic "${topic}" — fallback to top ${topicLimit}`);
filtered = allArticles.slice(0, topicLimit);
logger.warn(
`fetchAndFilterSourceArticles: no articles match topic "${topic}" — returning empty set (no general-sports fallback)`
);
}
} else if (filterMode === 'keyword') {
filtered = filterByKeywords(allArticles, keywords);