w3stling / rssreader

A simple Java library for reading RSS and Atom feeds
MIT License
152 stars 25 forks source link

Add info about image into rss item. #155

Closed logart closed 5 months ago

logart commented 5 months ago

Hi, @w3stling

I really appreciate your library since it saved me a lot of time and I really like the extension points with addItemExtension API. However, for my project I needed to parse media:thumbnail attribute of the rss feed. Of course I could parse it into author or comments field as a hack like this .addItemExtension("media:thumbnail", "url", Item::setAuthor), but I would rather contribute to the library to add additional image field on the rss Item class.

If you don't mind, I've added the default behaviour to abstract parser so it will work out of the box. But if this is inapropriate, I can happily use .addItemExtension("media:thumbnail", "url", Item::setImage) in my code.

Let me know if you could accept my PR as is, or should I remove default behaviour from abstact parser and only add an image field on the item class.

I wish you have a best day, Artem

w3stling commented 5 months ago

Thanks @logart for the PR. I prefer not to add fields to the Item class that is not part of the RSS specification.

The easiest solution is as you suggested to map the media:thumbnail url attribute to author field. An alternative solution is to create your own RssReader class by extending AbstractRssReader class and override the createItem(DateTimeParser dateTimeParser)method. In that way you can add as many custom field to your implementation of the Item class. See ItunesRssReader class for an example.

I have started to implement a Media RSS module similar to the iTunes module that supports all tags and attributes of the Media RSS specification but I never finished that work.

logart commented 5 months ago

Thanks, @w3stling This sounds like a great plan.

Do you think it's ok to add this custom reader to your repo like the iTunes one? I will gladly move implementation here to not pollute the Item class.

It's totally ok for me to maintain my own fork, but if you think this is a good solution I would rather merge it to your repository to not create a lot of copies of the library.

Let me know what do you think.

Best regards, Artem

logart commented 5 months ago

I've updated the MR with media:thumbnail parsing support from media rss. Unfortunately I am unable to complete the whole spec. Hopefully when someone else would need it he can finish the job. Thanks for your help. I really like your library.

w3stling commented 5 months ago

Thanks @logart. Merged

logart commented 5 months ago

Thank you @w3stling