w3stling / rssreader

A simple Java library for RSS and Atom feeds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RSS Reader

Build Download Javadoc License
CodeQL Quality Gate Coverage Bugs Vulnerabilities Code Smells

Note - from version 3.0.0:

  • New Java package name
  • New group ID in Maven / Gradle dependency declaration
  • Moved repository from JCenter to Maven Central Repository

RSS Reader is a simple Java library for reading RSS and Atom feeds. It has zero 3rd party dependencies, a low memory footprint and can process large feeds. Requires at minimum Java 11.

RSS (Rich Site Summary) is a type of web feed which allows users to access updates to online content in a standardized, computer-readable format. It removes the need for the user to manually check the website for new content.

Examples

Read RSS feed

Reads from a RSS (or Atom) feed.

RssReader rssReader = new RssReader();
List<Item> items = rssReader.read(URL)
                            .toList();

Extract all items that contains the word football in the title.

RssReader reader = new RssReader();
Stream<Item> rssFeed = reader.read(URL);
List<Item> footballArticles = rssFeed.filter(i -> i.getTitle().equals(Optional.of("football")))
                                     .toList();

Read feed from a file

InputStream file = new FileInputStream("Path to file");
List<Item> items = new RssReader().read(file);
                                  .toList();

Read from multiple feeds

Read from multiple feeds into a single stream of items sored in descending (newest first) publication date order and prints the title.

List<String> urls = List.of(URL1, URL2, URL3, URL4, URL5); 
new RssReader().read(urls)
               .sorted()
               .map(Item::getTitle)
               .forEach(System.out::println);

To change sort order to ascending (oldest first) publication date

.sorted(ItemComparator.oldestItemFirst())

Podcast / iTunes module

Use iTunes module for extracting data from Podcast specific tags and attributes.

List<ItunesItem> items = new ItunesRssReader().read(URL)
                                              .toList();

Custom RSS / Atom feed extensions

Support for mapping custom tags and attributes in feed to item and channel object.

List<Item> items = new RssReader()
             .addItemExtension("dc:creator", Item::setAuthor)
             .addItemExtension("dc:date", Item::setPubDate)
             .read("https://lwn.net/headlines/rss")
             .toList();

Download

Download the latest JAR or grab via Maven or Gradle.

Maven setup

Add dependency declaration:

<project>
    ...
    <dependencies>
        <dependency>
            <groupId>com.apptasticsoftware</groupId>
            <artifactId>rssreader</artifactId>
            <version>3.6.0</version>
        </dependency>
    </dependencies>
    ...
</project>

Gradle setup

Add dependency declaration:

dependencies {
    implementation 'com.apptasticsoftware:rssreader:3.6.0'
}

Markup Validation Services

Useful links for validating feeds

RSS / Atom

https://validator.w3.org/feed/
https://www.feedvalidator.org/check.cgi

Podcast / iTunes

https://podba.se/validate/
https://www.castfeedvalidator.com/

License

MIT License

Copyright (c) 2024, Apptastic Software

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

A simple Java library for RSS and Atom feeds

License:MIT License


Languages

Language:Java 100.0%