Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple enclosure tags get overwritten #254

Open
black-hawk85 opened this issue Sep 7, 2023 · 3 comments
Open

Multiple enclosure tags get overwritten #254

black-hawk85 opened this issue Sep 7, 2023 · 3 comments

Comments

@black-hawk85
Copy link

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

item.enclosure = xmlItem.enclosure[0].$;

It's hard coded taking only the first enclosure item

@stweiz
Copy link

stweiz commented Nov 13, 2024

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

@black-hawk85
Copy link
Author

Unfortunately I had to use another lib for that.

It works with rss-to-json-v2

@rhyst
Copy link

rhyst commented Feb 10, 2025

I have fixed this in a fork: https://github.com/rhyst/rss-parser and PR #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants