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": [ "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": "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": "IHF", "url": "https://www.ihf.info/rss.xml", "category": "andebol", "lang": "en" },
{ "name": "Record", "url": "https://www.record.pt/rss", "category": "sports", "lang": "pt" }, { "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" } { "name": "The Guardian World", "url": "https://www.theguardian.com/world/rss", "category": "general", "lang": "en" }
], ],
"keywords": [ "keywords": [
"FC Porto", "Benfica", "Sporting CP", "transfer", "andebol", "handball", "EHF", "IHF", "FAP",
"NBA", "F1", "Formula 1", "Cristiano Ronaldo", "Champions League de Andebol", "Liga dos Campeões",
"Champions League", "Premier League", "La Liga", "Selecção Nacional", "Seleção Nacional",
"handball", "andebol", "EHF", "IHF", "Champions League de Andebol", "FC Porto", "Benfica", "Sporting CP",
"Selecção Nacional", "Porto Handball", "Sporting Handball", "Benfica Handball" "andebol de praia", "beach handball", "European Masters",
"Mundial", "Campeonato Nacional", "Final Four"
], ],
"trusted_domains": [ "trusted_domains": [
"record.pt", "rtp.pt", "espn.com", "bbc.co.uk", "portal.fpa.pt", "record.pt", "rtp.pt",
"theguardian.com", "skysports.com", "zerozero.pt", "handball-planet.com", "ihf.info", "eurohandball.com",
"uefa.com", "fifa.com", "handball-planet.com", "ihf.info" "bbc.co.uk", "theguardian.com", "espn.com", "skysports.com",
"zerozero.pt", "uefa.com", "fifa.com"
], ],
"domain_filter_mode": "strict" "domain_filter_mode": "strict"
} }
+35 -6
View File
@@ -5,6 +5,37 @@ const { scrapeArticle } = require('../crawler/scraper');
const { filterByKeywords } = require('../crawler/rss'); const { filterByKeywords } = require('../crawler/rss');
const logger = require('../logger'); 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. * 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 // Step 2: Apply filtering based on mode
let filtered; let filtered;
if (filterMode === 'topic' && topic) { if (filterMode === 'topic' && topic) {
filtered = allArticles.filter((a) => filtered = filterArticlesByTopic(allArticles, topic, topicLimit);
`${a.title} ${a.summary}`.toLowerCase().includes(topic.toLowerCase())
);
filtered = filtered.slice(0, topicLimit);
if (filtered.length === 0) { if (filtered.length === 0) {
logger.warn(`fetchAndFilterSourceArticles: no articles match topic "${topic}" — fallback to top ${topicLimit}`); logger.warn(
filtered = allArticles.slice(0, topicLimit); `fetchAndFilterSourceArticles: no articles match topic "${topic}" — returning empty set (no general-sports fallback)`
);
} }
} else if (filterMode === 'keyword') { } else if (filterMode === 'keyword') {
filtered = filterByKeywords(allArticles, keywords); filtered = filterByKeywords(allArticles, keywords);