A cup of library to Parse RSS for android. Also available as a ConverterFactory for Retrofit & Fuel

Overview

ParseRSS

CodeFactor codebeat badge

RSS Parser for android


Simple, concise, and extensible RSS Parser in the entire coffee shop. It can capture these information from the RSS article:

  • Title
  • Description
  • Link
  • Publication Date
  • Image
  • Item GUId
  • Language
  • Media
  • Author
  • Categories

ParseRSS mainly has two main objects. RSSFeedObject and RSSItemObject. You can create your own parsing strategy by implementing RSSFeed and RSSItem.

Usage

ParseRSS depends on XmlPullParser, so feed it at least once in a lifetime. First thing first, the initialization part. You can put it on your Application onCreate function.

ParseRSS.init(XmlPullParserFactory.newInstance())

Be aware that XmlPullParser could throw an exception even in initialization step.

Next, feed the RSS string into ParseRSS

val feed: RSSFeedObject = ParseRSS.parse(xml)
feed.items.forEach {
    print(it.title)
}

ParseRSS as a Converter

ParseRSS does not have its own networking mechanism. Instead, it benefits from infamous networking library such as Retrofit, and Fuel. By using ConverterFactory, ParseRSS is ready to ship without breaking your project design pattern.

Fuel

Convert Fuel Response into RSSFeed by using responseRss function.

Fuel.get(URL).responseRss<RSSFeedObject> { result ->
        result.fold({ feed ->
            feed.items.forEach {
                print(it.title)
            }
        }, { error ->
            print(error)
        })
}

Retrofit

Convert Retrofit Response into RSSFeed by using ParseRSSConverterFactory

} ">
interface MyRssService {
    @GET("rss")
    fun rss(): Call<RSSFeedObject>
}
val retrofit = Retrofit.Builder()
    .addConverterFactory(ParseRSSConverterFactory.create<RSSFeedObject>())
    .baseUrl(BASE_URL)
    .build()

val rssService = retrofit.create(MyRssService::class.java)
rssService.rss().enqueue(object : Callback<RSSFeedObject> {
    override fun onFailure(call: Call<RSSFeedObject>, t: Throwable) {
    }
    override fun onResponse(call: Call<RSSFeedObject>, response: Response<RSSFeedObject>) {
    }
})

Gradle Dependency

Add jitpack repository in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Used on Fuel

// ParseRSS as Fuel Converter Factory
implementation "com.github.muhrifqii.ParseRSS:parserss:$version"
implementation "com.github.muhrifqii.ParseRSS:fuel:$version"

Used on Retrofit

// ParseRSS as Retrofit Converter Factory
implementation "com.github.muhrifqii.ParseRSS:parserss:$version"
implementation "com.github.muhrifqii.ParseRSS:retrofit:$version"

License

Copyright (c) 2019 Muhammad Rifqi Fatchurrahman

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.
You might also like...
Android Market In-app Billing Library

Update In-app Billing v2 API is deprecated and will be shut down in January 2015. This library was developed for v2 a long time ago. If your app is st

An Android library allowing images to exhibit a parallax effect that reacts to the device's tilt
An Android library allowing images to exhibit a parallax effect that reacts to the device's tilt

Motion An Android library allowing images to exhibit a parallax effect. By replacing static pictures and backgrounds with a fluid images that reacts t

Android library to easily serialize and cache your objects to disk using key/value pairs.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Form Validator Library for Android

Android-Validator Form Validator Library for Android [](https://flattr.com/submit/auto?user_id=throrin19&url=https://github.com/throrin19/Android-Vali

Very easy to use wrapper library for Android SharePreferences

Treasure English document Treasure是一个Android平台上基于SharePreferences的偏好存储库,只需要定义接口,无需编写实现,默认支持Serializable和Parcelable。运行时0反射,不仅使用方便而且性能和原生写法几乎无差别。 使用方法 1

Error handling library for Android and Java

ErrorHandler Error handling library for Android and Java Encapsulate error handling logic into objects that adhere to configurable defaults. Then pass

Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app
Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app

DroidMVP About DroidMVP is a small Android library to help you incorporate the MVP pattern along with Passive View and Presentation Model (yes, those

A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

Android library that regroup bunch of dateTime utilities

DateTimeUtils This library is a package of functions that let you manipulate objects and or java date string. it combine the most common functions use

Comments
  • 0.7.1

    0.7.1

    • added missing encloure tag for image urls
    • added a try/catch into parse block to avoid an exception on malformed tags
    • added a test to test specific rss scenarios
    • updated dependencies
    • fixed ktlint project warnings
    • fixed some typos on property names
    opened by davide1945 0
  • Worng with parse <link> tag in <channel> level

    Worng with parse tag in level

    Example RSS url: https://rsshub.app/github/repos/DIYgod

    In this case, actually we saw that the '<link>' tag in '<channel>' level is 'https://github.com/DIYgod', but after serialization parse, we found 'link' value in 'RssFeedObject' is 'https://rsshub.app/github/repos/DIYgod'.

    How can I fix this problem please :)

    opened by CharmingCheung 0
Releases(0.6.0)
Owner
Muhammad Rifqi Fatchurrahman
software engineer
Muhammad Rifqi Fatchurrahman
LearningRegex - Parse links from text via RegEx

Parse links from text via RegEx Supported types: Hashtags Urls emails Using in p

Boris 0 Feb 16, 2022
Multi-module, Kotlin, MVI, Compose, Hilt, Navigation Component, Use-cases, Room, Retrofit

Work in progress Multi-module demo app that gets data from dota2 api. API https://docs.opendota.com/ Players by rank (GET) https://api.opendota.com/ap

Mitch Tabian 321 Dec 27, 2022
Dagger Hilt, MVP Moxy, Retrofit, Kotlin coroutine, Sealed class

Dagger Hilt, MVP Moxy, Retrofit, Kotlin coroutine, Sealed class

Dostonjon 1 Nov 2, 2021
Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

API Calling Flow API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service)

Rohit Surwase 19 Nov 9, 2021
Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Shahid Iqbal 4 Nov 29, 2022
A robust native library loader for Android.

ReLinker A robust native library loader for Android. More information can be found in our blog post Min SDK: 9 JavaDoc Overview The Android PackageMan

Keepsafe 2.9k Dec 27, 2022
Joda-Time library with Android specialization

joda-time-android This library is a version of Joda-Time built with Android in mind. Why Joda-Time? Android has built-in date and time handling - why

Daniel Lew 2.6k Dec 9, 2022
UPnP/DLNA library for Java and Android

Cling EOL: This project is no longer actively maintained, code may be outdated. If you are interested in maintaining and developing this project, comm

4th Line 1.6k Jan 4, 2023
:iphone: [Android Library] Get device information in a super easy way.

EasyDeviceInfo Android library to get device information in a super easy way. The library is built for simplicity and approachability. It not only eli

Nishant Srivastava 1.7k Dec 22, 2022
Android library for viewing, editing and sharing in app databases.

DbInspector DbInspector provides a simple way to view the contents of the in-app database for debugging purposes. There is no need to pull the databas

Infinum 924 Jan 4, 2023