mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-14 06:47: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
45
plugins/feed-discovery/src/providers/index.ts
Normal file
45
plugins/feed-discovery/src/providers/index.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import type { FeedDiscoveryConfig, FeedDiscoveryProvider, FeedProviderManifest } from "../types.js";
|
||||
import { ITunesPodcastProvider } from "./itunes-podcast.js";
|
||||
import { ManualCuratedProvider } from "./manual-curated.js";
|
||||
import { OpmlDirectoryProvider } from "./opml-directory.js";
|
||||
import { PodcastIndexProvider } from "./podcastindex.js";
|
||||
import { WebCandidateFeedProbeProvider } from "./web-feed-probe.js";
|
||||
|
||||
export function createDefaultFeedProviders(config: FeedDiscoveryConfig): FeedDiscoveryProvider[] {
|
||||
return [
|
||||
new ManualCuratedProvider(),
|
||||
new OpmlDirectoryProvider(config.opmlPaths),
|
||||
new WebCandidateFeedProbeProvider(config),
|
||||
new ITunesPodcastProvider(config),
|
||||
new PodcastIndexProvider(config)
|
||||
];
|
||||
}
|
||||
|
||||
export function providerManifests(config: FeedDiscoveryConfig): FeedProviderManifest[] {
|
||||
return createDefaultFeedProviders(config).map((provider) => ({
|
||||
id: provider.id,
|
||||
name: provider.name,
|
||||
type: provider.id.includes("podcast") || provider.id.includes("itunes") ? "podcast" : "all",
|
||||
requiresApiKey: provider.requiresApiKey,
|
||||
enabledByDefault: provider.enabledByDefault && (!provider.requiresApiKey || hasProviderKey(provider.id, config)),
|
||||
description: describeProvider(provider.id)
|
||||
}));
|
||||
}
|
||||
|
||||
function hasProviderKey(id: string, config: FeedDiscoveryConfig) {
|
||||
if (id === "podcastindex") {
|
||||
return Boolean(config.podcastIndexApiKey && config.podcastIndexApiSecret);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function describeProvider(id: string) {
|
||||
const descriptions: Record<string, string> = {
|
||||
"manual-curated": "Searches locally curated high-trust feed sources.",
|
||||
"opml-directory": "Searches configured local OPML files.",
|
||||
"web-feed-probe": "Probes configured candidate homepages and direct URL queries for feeds.",
|
||||
"itunes-podcast": "Searches the public iTunes podcast directory.",
|
||||
podcastindex: "Searches PodcastIndex when API credentials are configured."
|
||||
};
|
||||
return descriptions[id] ?? "Feed discovery provider.";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue