prof18 / RSS-Parser

A Kotlin Multiplatform library to parse a RSS Feed
Apache License 2.0
499 stars 127 forks source link

support simple atom rss #94

Closed Haoxiqiang closed 1 year ago

Haoxiqiang commented 2 years ago

As the issue https://github.com/prof18/RSS-Parser/issues/38 I have a pr simple support.

more work should be done. e.g. atom file has a diff time format( 2021-11-11T00:00:00+00:00Z) which the android does not support well. I need more atom XML files to optimize the compatibility.

Haoxiqiang commented 2 years ago

And I have the file. https://jakewharton.com/atom.xml that JakeWharton's blog. I have fallen in

<entry>
    <title>The state of managing state (with Compose)</title>
    <link href="https://code.cash.app/the-state-of-managing-state-with-compose"/>
    <updated>2021-11-11T00:00:00+00:00</updated>
    <id>https://jakewharton.com/the-state-of-managing-state-with-compose</id>
    <content type="html">
        This post was published externally on Cash App Code Blog. Read it at
        <a href="https://code.cash.app/the-state-of-managing-state-with-compose">https://code.cash.app/the-state-of-managing-state-with-compose</a>
        .
    </content>
</entry>

I have to add a try-catch to ignore the crash.

try {
    val content = xmlPullParser.nextTrimmedText()
    articleBuilder.content(content)
    imageUrlFromContent = getImageUrl(content)
} catch (throwable: Throwable) {
    // TODO some content tag with the no CDATA html that like this:
    // <content type="html">
    //  This post was published externally on Cash App Code Blog. Read it at
    //  <a href="https://code.cash.app/the-state-of-managing-state-with-compose">https://code.cash.app/the-state-of-managing-state-with-compose</a>
    //  .
    // </content>
    continue@loop
}
prof18 commented 2 years ago

Ah interesting, thank you very much for the work! 🙏

I will look at what's missing and try to complete the feature!

Haoxiqiang commented 2 years ago

You know the 2021-11-11T00:00:00+00:00Z format and others time format was supported by joda time, but it is a little large for the android platform. I have tried some atom files, the vexed question of content format, as the HTML but without <![CDATA[]]> I'm wondering if the XmlPullParser wasn't enough.

ashishb commented 1 year ago

What's the plan to merge this in the branch?

ashishb commented 1 year ago

e.g. atom file has a diff time format( 2021-11-11T00:00:00+00:00Z) which the android does not support well.

I believe this is Zulu time format and you can parse this with

new SimpleDateFormat("yyyy-MM-d'T'HH:mm:ss", Locale.ENGLISH).parse(date)
prof18 commented 1 year ago

What's the plan to merge this in the branch?

I'm planning to integrate it in the future but I don't have an ETA yet.

ashishb commented 1 year ago

@prof18 Happy to help if you would like.

prof18 commented 1 year ago

@prof18 Happy to help if you would like.

Thanks! I'm planning a bit of refactor before integrating this. But if I need help, I'll let you know 🙏

ashishb commented 1 year ago

@prof18 friendly ping to look into this again :)

j-roskopf commented 1 year ago

I believe the format mentioned above would also support The Verge's format (https://www.theverge.com/rss/index.xml) if i'm not mistaken. Any chance this can be merged?

prof18 commented 1 year ago

Sorry for not getting back to you sooner, but I was focusing more on the migration to Kotlin Multiplatform. Since this seems to be a very requested feature, I will start working on that! A reasonable ETA for a new release could be around 2/3 weeks 💪