rometools / rome

Java library for RSS and Atom feeds
https://rometools.github.io/rome
Apache License 2.0
908 stars 168 forks source link

Image Url returns Pictures in Low Quality #546

Closed lukonjun closed 1 year ago

lukonjun commented 2 years ago

Hi there, this is only indirectly related to the library, however, I thought I still ask for your advice.
I am using Rome to fetch numerous RSS Feeds, save article Information in a Database, and then expose this Information via a REST API which is consumed by a mobile application.
The Problem I am currently Facing is that the img_url of Articles provide sometimes Pictures of low quality and I don't know how to overcome this. Especially the magazine Bild gives me a headache that returns pictures in low quality if you don't specify a resolution in the URL query parameters, but also other RSS Feeds provide sometimes pictures in low quality.

Bildschirmfoto 2022-04-23 um 08 39 04

Have you experienced similar issues and/or do you have any ideas, recommendation how to solve this? Thanks a lot in advance!

antoniosanct commented 2 years ago

Hi, @lukonjun!

I got an Bild.de RSS sample (link). In this case, RSS092Parser get the 'description' node at each item, that contains an thumbnail image.

Reviewing the feed, ROME parses it with the Yahoo! MediaRSS module plugin included in rome-modules project. With this approach, the SyndFeed contains a MediaEntryModule reference that contains the image as you need:

for (SyndEntry syndEntry : feed.getEntries()) {
  MediaEntryModule mm = (MediaEntryModule) syndEntry.getModule(MediaModule.URI);
  LOG.info("{}", mm.getMediaContents()[0].getReference());
}

Regards!

lukonjun commented 2 years ago

Hi @antoniosanct, thanks a lot for your answer!

For some reason, I am not able to import the MediaEntryModule Class. I checked my pom.xml

<dependency>
    <groupId>com.rometools</groupId>
    <artifactId>rome</artifactId>
    <version>1.18.0</version>
</dependency>

And also verified the included jars

Bildschirmfoto 2022-04-30 um 09 26 15

Might be missing a silly point but could you maybe share your pom.xml, this import is not working for me import com.rometools.modules.mediarss.MediaEntryModule;

Besides that, if this would solve my problem with the low-resolution pictures it would be super great!

PatrickGotthard commented 2 years ago

@lukonjun You have to add the rome-modules dependency to use the MediaRSS module :)