diff --git a/server/routes.ts b/server/routes.ts index f8db794..cd818f5 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -1060,34 +1060,33 @@ export async function registerRoutes( }); app.get("/api/breaking-news", async (_req, res) => { + // 31. 8. 2026: blok Aktuelle Nachrichten je vodil na tagesschau, n-tv, ORF + // in Welt, torej smo obiskovalce posiljali s strani. Zdaj kaze nase novice + // z news.folx.tv, kjer imamo oglase. const cacheKey = "breaking-news"; - const cached = getCached(cacheKey, 15 * 60 * 1000); + const cached = getCached(cacheKey, 5 * 60 * 1000); if (cached) return res.json(cached); try { - const newsFeeds = [ - "https://www.tagesschau.de/xml/rss2_https/", - "https://www.n-tv.de/rss", - "https://rss.orf.at/oesterreich.xml", - "https://www.welt.de/feeds/latest.rss", - ]; - let allItems: { title: string; link: string; source: string; pubDate: string }[] = []; - const results = await Promise.allSettled( - newsFeeds.map(async (url) => { - try { - const xml = await fetchRssFeed(url); - return parseRssItems(xml, 1); - } catch { return []; } - }) - ); - for (const r of results) { - if (r.status === "fulfilled") allItems.push(...r.value); - } - allItems = allItems.slice(0, 10); - if (allItems.length > 0) setCache(cacheKey, allItems); - res.json(allItems); + const r = await fetch("https://news.folx.tv/api/articles", { + headers: { "user-agent": "folx.tv-widget" }, + signal: AbortSignal.timeout(10000), + }); + const arts: any[] = await r.json(); + const items = (Array.isArray(arts) ? arts : []) + .filter((a) => a && a.slug && a.title) + .sort((a, b) => String(b.publishedAt || "").localeCompare(String(a.publishedAt || ""))) + .slice(0, 12) + .map((a) => ({ + title: String(a.title), + link: `https://news.folx.tv/${a.slug}`, + source: String(a.category || "FOLX NEWS"), + pubDate: String(a.publishedAt || ""), + })); + if (items.length > 0) setCache(cacheKey, items); + res.json(items); } catch (err: any) { - console.log("[breaking-news] RSS fetch error:", err.message); + console.log("[breaking-news] news.folx.tv error:", err.message); const stale = getStale(cacheKey); res.json(stale || []); }