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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user