rss-parser icon indicating copy to clipboard operation
rss-parser copied to clipboard

Multiple enclosure tags get overwritten

Open black-hawk85 opened this issue 2 years ago • 3 comments

I need to parse an RSS to JSON which has multiple enclosure tags within an item

<item>
<title>...</title>
<enclosure url="..." type="..." />
<enclosure url="..." type="..." />
<enclosure url="..." type="..." />
</item>

My resulted JSON Object only has a single enclosure object instead of an array. I tried using keepArray option already but it still happens.

It seems it gets overwritten in parser.js https://github.com/rbren/rss-parser/blob/2ea1d8f901bc804b064798d1a45ca82d984ebbee/lib/parser.js#L214

It's hard coded taking only the first enclosure item

black-hawk85 avatar Sep 07 '23 15:09 black-hawk85

Did you find another solution @black-hawk85? I want to parse and display images, which are referenced with RSS enclosure.

stweiz avatar Nov 13 '24 15:11 stweiz

Unfortunately I had to use another lib for that.

It works with rss-to-json-v2

black-hawk85 avatar Nov 13 '24 15:11 black-hawk85

I have fixed this in a fork: https://github.com/rhyst/rss-parser and PR https://github.com/rbren/rss-parser/pull/282

It adds an item.enclosures property which is an array of all enclosures. Additionally it adds a couple of obscure enclosure tags to the same list ppg:enclosureSecure and ppg:enclosureLegacy which are used at least by the BBC for some of their podcasts.

You can install now with:

npm i git+https://github.com/rhyst/rss-parser.git

rhyst avatar Feb 10 '25 17:02 rhyst