• Stars
    star
    511
  • Rank 86,473 (Top 2 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Kotlin Multiplatform library to parse a RSS Feed

RSS Parser

Maven Central License API

RSS Parser is a Kotlin Multiplatform library for parsing RSS and Atom feeds. It supports Android, iOS, and the JVM.

With RSS Parser, you can fetch plenty of useful information from any RSS channel, be it a blog, magazine, or even a podcast feed.

Table of Contents

Installation

RSS Parser is currently published to Maven Central, so add it to your project's repositories.

repositories {
    mavenCentral()
    // ...
}

Then, add the dependency to your common source set's dependencies.

commonMain {
    dependencies {
        // ...
        implementation("com.prof18.rssparser:rssparser:<latest-version>")
    }
}

If you are in an Android-only project, simply add the dependency:

dependencies {
    // ...
    implementation("com.prof18.rssparser:rssparser:<latest-version>")
}

Important Notices

Artifact change

Since February 2022, the library artifacts have been moved to MavenCentral. The group ID changed from com.prof.rssparser to com.prof18.rssparser. Be sure to add the gradle dependency to your root build.gradle file.

allprojects {
    repositories {
        mavenCentral()
    }
}

Breaking changes

From version 6.0, RSSParser has become Multiplatform. This update brought some breaking changes:

  • Some class names and packages have been changed. Check out the migration guide for further info.
  • Caching of feeds is not supported anymore. After some consideration, I decided that the aim of this library is not meant to provide a caching solution for RSS feeds, but just to do the parsing. The user of the library should implement any caching/storing solutions their project requires.
  • Support for Java with the OnTaskCompleted and onError callbacks has been dropped.

Here you can find the README for version 5 of RSSParser.

Available data

The RssChannel result object provides the following data:

  • Title
  • Description
  • Link
  • Items
  • Image (Title, Url and Link)
  • Last build data
  • Update period
  • Itunes Data:
    • Author
    • Categories
    • Duration
    • Explicit
    • Image
    • Keywords
    • News Feed URL
    • Owner
    • Subtitle
    • Summary
    • Type

Items support the following attributes:

  • Title
  • Author
  • Description
  • Content
  • Image
  • Link
  • Publication Date
  • Categories
  • Audio
  • Source (name and URL)
  • GUID
  • Video
  • Comments URL
  • Itunes Data:
    • Author
    • Duration
    • Episode
    • Episode Type
    • Explicit
    • Image
    • Keywords
    • Subtitle
    • Summary
    • Season

Usage

RssParser uses Coroutines for all the asynchronous work.

Creating an RssParser instance

An RssParser instance is the entry point of the library.

It's possible to create an instance of RssParser directly in the common code, without having to pass any platform-specific dependencies.

val rssParser: RssParser = RssParser()

Builder

An RssParser instance can also be built with a platform-specific RssParserBuilder. Some custom and optional fields can be provided to the builder.

On Android and the JVM, a custom OkHttpClient instance and a custom Charset can be provided. If an OkHttpClient instance is not provided, the library will create one. If no Charset is provided, it will automatically be inferred from the feed XML.

val builder = RssParserBuilder(
    callFactory = OkHttpClient(),
    charset = Charsets.UTF_8,
)
val rssParser = builder.build() 

On iOS, a custom NSURLSession instance can be provided. If an NSURLSession instance is not provided, the library will use the shared NSURLSession.

val builder = RssParserBuilder(
    nsUrlSession = NSURLSession(),
)
val rssParser = builder.build() 

RSS Parsing from URL

To parse an RSS feed from a URL, the suspending getRssChannel function can be used.

val rssChannel: RssChannel = rssParser.getRssChannel("https://www.rssfeed.com")

RSS Parsing from string

To parse an RSS feed from an XML string, the suspending parse function can be used

val xmlString: String = "xml-string"
val rssChannel: RssChannel = rssParser.parse(xmlString)

Sample projects

The repository contains two samples projects: a multiplatform and an Android project to showcase the usage in a multiplatform app and an Android one.

Migration from version 5

Version 6 of the library introduced the following breaking changes:

  • The main package name has been changed from com.prof.rssparser to com.prof18.rssparser;
  • com.prof.rssparser.Parser has been moved and renamed to com.prof18.rssparser.RssParser;
  • com.prof.rssparser.Parser.Builder has been moved and renamed to com.prof18.rssparser.RssParserBuilder;
  • com.prof.rssparser.Channel has been moved and renamed to com.prof18.rssparser.model.RssChannel;
  • com.prof.rssparser.Article has been moved and renamed to com.prof18.rssparser.model.RssItem;
  • com.prof.rssparser.HTTPException has been moved and renamed to com.prof18.rssparser.exception.HttpException;
  • com.prof.rssparser.Image has been moved and renamed to com.prof18.rssparser.RssImage;
  • com.prof.rssparser.ItunesOwner has been moved to com.prof18.rssparser.model.ItunesOwner;
  • com.prof.rssparser.ItunesArticleData has been moved and renamed to com.prof18.rssparser.model.ItunesItemData;
  • com.prof.rssparser.ItunesChannelData has been moved to com.prof18.rssparser.model.ItunesChannelData;
  • getChannel() has been renamed to getRssChannel();
  • cancel() is not available anymore, the cancellation can be handled by the caller.

Changelog

From version 1.4.4 and above, the changelog is available in the release section.

  • 14 December 2017 - Little fixes on Error Management - Version 1.3.1
  • 13 December 2017 - Improved Error Management - Version 1.3
  • 10 December 2017 - Added support for the categories - Version 1.2
  • 12 August 2017 - Fixed the Library Manifest and updated the dependencies - Version 1.1
  • 18 June 2016 - First release - Version 1.0

License

Copyright 2016-2023 Marco Gomiero

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Apps using RSS Parser

If you are using RSS Parser in your app and would like to be listed here, please open a pull request!

List of Apps using RSS Parser
* [FeedFlow](https://www.feedflow.com)

More Repositories

1

feed-flow

FeedFlow is a minimalistic RSS Reader available on Android, iOS and macOS. Built with Kotlin Multiplatform, Jetpack Compose and SwiftUI.
Kotlin
338
star
2

MoneyFlow

A money management app wrote with Kotlin Multiplatform, Jetpack Compose and Swift UI. Work in Progress
Kotlin
335
star
3

YoutubeParser

An Android library to get video's information from Youtube channels.
Kotlin
88
star
4

Database-Backup-Restore

A simple Android app that performs local and cloud backup/restore of a database
Java
71
star
5

Secure-QR-Reader

Privacy Focused and Secure QR Reader
Kotlin
41
star
6

Friends-Tournament

Tournament creation and management made easy
Dart
34
star
7

shared-hn-android-ios-backend

A sample of Android app, iOs app and backend that share some common code via Kotlin Multiplatform
Kotlin
30
star
8

kmp-fatframework-cocoa

A Gradle plugin to generate and publish an iOs FatFramework or XCFramework on Kotlin Multiplatform projects.
Kotlin
27
star
9

ktor-chuck-norris-sample

A Ktor sample project that returns Random Chuck Norris jokes
Kotlin
24
star
10

kmp-framework-bundler

A Gradle plugin for Kotlin Multiplatform projects that generate a XCFramework for Apple targets or a FatFramework for iOS targets, and manages the publishing process in a CocoaPod Repository.
Kotlin
21
star
11

BottomAppBarSwipeableTabs

A simple example app with a BottomAppBar with Swipeable Tabs and a Menu for changing tabs.
Dart
14
star
12

Filmatic

Filmatic shows you some popular movies of the moment. The project is a playground application that I use to catch up with modern Android development. In particular, I've used it to learn modularization and Dependency Injection with Dagger and then Hilt.
Kotlin
14
star
13

CyberRobotBrain

Android App that provide a "brain" to the Cyber Robot, a cheap sensorless toy robot sell by Clementoni
Java
7
star
14

shared-deserialization

A small sample to showcase the usage of the Kotlin Serialization library with Retrofit and Alamofire in a Kotlin Multiplatform project.
Swift
7
star
15

Filmatik

A minimal Kotlin Multiplatform project with Jetpack Compose and SwiftUI that shows some popular movies of the moment
Kotlin
5
star
16

DistributedFIleSystemRMI

Java
3
star
17

imperative-vs-declarative

A simple app to showcase declarative and imperative style.
Swift
2
star
18

TweetCounter

Python
1
star
19

marcogomiero.com

The repo of my personal website
HTML
1
star
20

kmp-xcframework-sample

A simple Kotlin Multiplatform sample project to show how to build an XCFramework
Kotlin
1
star
21

IoTSempliceDemo

A simple Android app that shows how to turn on the led of "IoT Semplice".
Java
1
star
22

kmp-framework-bundler-test-project

Just a simple Kotlin Multiplatform sample project to test the KMP Framework Bundler Gradle Plugin: https://github.com/prof18/kmp-framework-bundler
Kotlin
1
star
23

prof18.com

HTML
1
star
24

NewsReaderKMPWorkshop

Kotlin
1
star