mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-14 14:57:28 +00:00
Add feed discovery plugin
This commit is contained in:
parent
e47616bf9d
commit
5cfeea6b57
37 changed files with 2432 additions and 5 deletions
25
plugins/feed-discovery/src/output/rss.ts
Normal file
25
plugins/feed-discovery/src/output/rss.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import RSS from "rss";
|
||||
import type { FeedDiscoveryResponse } from "../types.js";
|
||||
|
||||
export function renderRss(response: FeedDiscoveryResponse) {
|
||||
const feed = new RSS({
|
||||
title: `LogicSRC feed discovery: ${response.query}`,
|
||||
description: `Discovered feed sources for ${response.query}`,
|
||||
feed_url: `https://bittorrented.com/rss/discover/${encodeURIComponent(response.normalizedQuery)}.xml`,
|
||||
site_url: "https://bittorrented.com/rss",
|
||||
language: "en"
|
||||
});
|
||||
|
||||
for (const result of response.results) {
|
||||
feed.item({
|
||||
title: result.title,
|
||||
description: result.description ?? `Discovered ${result.kind} feed from ${result.provider}`,
|
||||
url: result.homepageUrl ?? result.feedUrl,
|
||||
guid: result.canonicalFeedUrl ?? result.feedUrl,
|
||||
categories: [result.kind, result.provider, ...result.tags],
|
||||
date: result.lastPublishedAt ? new Date(result.lastPublishedAt) : new Date()
|
||||
});
|
||||
}
|
||||
|
||||
return feed.xml({ indent: true });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue