feat(parsing): Replace rss-parser with fast-xml-parser and add native feed parser; update Smartfeed to use parseFeedXML and adjust plugins/tests

This commit is contained in:
2025-10-31 21:26:07 +00:00
parent 64c7414682
commit 645f9c0e64
20 changed files with 353 additions and 1064 deletions

View File

@@ -3,6 +3,7 @@ import type { IFeedOptions } from './classes.feed.js';
import { PodcastFeed } from './classes.podcast.js';
import type { IPodcastFeedOptions } from './classes.podcast.js';
import * as plugins from './plugins.js';
import { parseFeedXML } from './lib/feedparser.js';
/**
* Main class for creating and parsing various feed formats (RSS, Atom, JSON Feed)
@@ -120,9 +121,7 @@ export class Smartfeed {
* ```
*/
public async parseFeedFromString(rssFeedString: string) {
const parser = new plugins.rssParser();
const resultingFeed = await parser.parseString(rssFeedString);
return resultingFeed;
return parseFeedXML(rssFeedString);
}
/**
@@ -138,8 +137,11 @@ export class Smartfeed {
* ```
*/
public async parseFeedFromUrl(urlArg: string) {
const parser = new plugins.rssParser();
const resultingFeed = await parser.parseURL(urlArg);
return resultingFeed;
const response = await fetch(urlArg);
if (!response.ok) {
throw new Error(`Failed to fetch feed: ${response.status} ${response.statusText}`);
}
const xmlString = await response.text();
return parseFeedXML(xmlString);
}
}