Giter Club home page Giter Club logo

syndication's Introduction

Build Status

Syndication feed

A Kotlin library for reading RSS 2.0 and ATOM 1.0 syndication feeds.

Usage

You're willing to consume ATOM 1.0 or RSS 2.0 feed? Start by creating and interface

interface RssReader {

  fun readRss(): RssFeed

  fun readAtom(): AtomFeed
}

then let Syndication class generates an implementation of that interface RssReader:

val reader = syndicationReader.create(RssReader::class.java)
val rssFeed = reader.readRss() // this is synchronous
val atomFeed = reader.readAtom() // this is synchronous

each call from the created RssReader will make an HTTP request and return the expected syndication feed.

By default only RssFeed and AtomFeed are accepted as return type.

If you would like to do things asynchronously then take a look to existing adapters in this repo.

  • kotlin-coroutines-adapter for example let you return Deferred<RssFeed> or Deferred<AtomFeed>.
  • rxjava2-adapter let you return RxJava 2.x types (Flowable, Maybe, Single).
  • rxjava3-adapter let you return RxJava 3.x types (Flowable, Maybe, Single).

Custom syndication feed

By default only RssFeed and AtomFeed are accepted as return type but If you would like to return your own custom type then see wiki.

Syndication specifications

Download

Download the latest JAR or grab via Gradle:

implementation 'com.ouattararomuald:syndication:2.1.1'

or Maven:

<dependency>
  <groupId>com.ouattararomuald</groupId>
  <artifactId>syndication</artifactId>
  <version>2.1.1</version>
</dependency>

Snapshots of the development version are available in Sonatype's snapshots repository.

Contributing

Contributions you say? Yes please!

Bug report?

If at all possible, please attach a minimal sample project or code which reproduces the bug. Screenshots are also a huge help if the problem is visual.

Send a pull request!

If you're fixing a bug, please add a failing test or code that can reproduce the issue.

License

Copyright 2018 Ouattara Gninlikpoho Romuald

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.

syndication's People

Contributors

gumichan01 avatar ouattararomuald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

syndication's Issues

Add possibility to parse custom syndication feed

In the current state, if the user wants to parse a feed that contains non-conventional fields, it is not possible. Also the API has lots of nullable fields, which is not very good for consumer.

It will be good to have some annotations:

  • @Atom
  • @Rss

that can be used to mark custom classes. If a class is marked with the annotations above then the adapters will not enforce the return type to be AtomFeed or RssFeed.

Usage:

@Atom
data class MyRss(
  @param:Element
  @field:Element
  val channel: MyChannel
)

and you're now able to have an interface like this:

@Atom
interface MyReader {
  fun readRss(): MyRss
}

Because we all have responsibilities, we trust you on the implementation of your custom class (MyRss here).

NULL when R8 optimization

Hello, When using R8 always get an exception with null when reading a RSS in the try catch block. If I don't use the problem does not happend. I don't understand if the problem is with an internal optimization that R8 tries to do., a Are you seen the same problem with R8 optimization eneabled ?

This is the part of the code:

fun getRssFedd(host:String):List<TwitterData>{

    val trustManager = TrustAllX509TrustManager.INSTANCE
    val client = OkHttpClient.Builder()
        .sslSocketFactory(
            sslContext(
                null,
                arrayOf<TrustManager>(trustManager)
            ).socketFactory,
            trustManager)
        .hostnameVerifier(TrustAllX509TrustManager.allowAllHostNames())
        .build()


    val mySyndication = Syndication(
        url = host,
        httpClient =client )
    val reader = mySyndication.create(RssReader::class.java)
    var lista : List<TwitterData>
    try {
        val rssFeed = reader.readRss()
        lista = convRssFeed(rssFeed)
    }
    catch (e:Exception){
        Log.e("Error reading RSS","${e.message}")
        lista = mutableListOf<TwitterData>()
    }
    return lista
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.