prof18 / rss-parser Goto Github PK
View Code? Open in Web Editor NEWA Kotlin Multiplatform library to parse a RSS Feed
License: Apache License 2.0
A Kotlin Multiplatform library to parse a RSS Feed
License: Apache License 2.0
Hi, I have a problem with images in articles. The parser doesn't recognize some images in < img /> tag in content.
I sent you a pictures with sucess image in article and null image in article.
The feed is it: https://instatecno.com/feed
When trying to parse https://www.mmafighting.com/rss/current it returns an empty list :(
E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.limitless.limitless.applicationunivercity, PID: 17238
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:330)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:255)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient;
at com.prof.rssparser.Parser.doInBackground(Parser.java:61)
at com.prof.rssparser.Parser.doInBackground(Parser.java:34)
at android.os.AsyncTask$2.call(AsyncTask.java:316)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:255)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.OkHttpClient" on path: DexPathList[[zip file "/data/app/com.limitless.limitless.applicationunivercity-1/base.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.limitless.limitless.applicationunivercity-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.limitless.limitless.applicationunivercity-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.prof.rssparser.Parser.doInBackground(Parser.java:61)
at com.prof.rssparser.Parser.doInBackground(Parser.java:34)
at android.os.AsyncTask$2.call(AsyncTask.java:316)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:255)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
Until now, as Parser was just an AsyncTask, I would call parser.cancel(boolean mayInterruptIfRunning). However, this is no longer possible. Is there a way to interrupt or cancel the background processing with the new system?
How can we stop parser once created?
Parse a rss feed whose items contain pubDate
tags with a child tag (time
). Eg:
<item>
<title>Sample title</title>
<link>http://www.sample-link.com</link>
<description>Sample description</description>
<pubDate>
<time datetime="2019-05-12T10:00:00Z">Sun, 05/12/2019 - 10:00</time>
</pubDate>
</item>
Expected result: Item whose pubDate
equals to Sun, 05/12/2019 - 10:00
Actual result: App crashed.
Is there a way to know if the article has updated?
for example an error when run on android studio v 3.4.1 gradle version 5
Thanks for creating this parser. :)
When I try to parse the Android Developer Blog RSS, I get zero articles back:
http://feeds.feedburner.com/blogspot/hsDu
Cannot Parse Greek Characters. Returns irrelevant symbols. Any suggestions?
Any plans to add a filter for the RSS feed?
please check this rss feed.
It cannot parse links correctly if there is more than one link in article
www.aif.ru/rss/news.php
Hello,
Please add a "source" attribute to your Article model, as it appears in the google news api:
https://news.google.com/rss?hl=fr&gl=BE&ceid=BE:fr
Some rss feeds have the path to the audio file in the <link> element of the item and some are missing the <link> element altogether or do not have the url to the audio file in that element. However, many have the path to the audio file as url attribute in the <enclosure> element. Can a check for type audio be added to the enclosure part of CoreXMLParser.kt, so that the path to the audio file is included in Article?
Please refer to the rss feed: https://feeds.megaphone.fm/stuffyoushouldknow/
EDIT: see post below for better specif for the error. This was not the real problem, but was caught by the try...catch block.
On API 20 and down, the parser does not parse anything. I get at runtime with a try...catch block
I/dalvikvm: Could not find method java.time.Duration.toMillis, referenced from method okhttp3.OkHttpClient$Builder.readTimeout
W/dalvikvm: VFY: unable to resolve virtual method 42983: Ljava/time/Duration;.toMillis ()J
I compile with Java 8 support, which is, to the best of my knowledge, the recommended version for Android development. I would like to target API 16+. I am using Kotlin. In my build.gradle there is:
compileSdkVersion 29
buildToolsVersion "29.0.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
It's odd that no error is raised on API21+. I assume it is because of the transition to Android Runtime (ART) instead of the Dalvik VM. I am a bit surprised since I saw on your Readme that your library was compliant with API15+.
Where did things go wrong? Should I use a newer version of Java? (is it even possible for Android?). Is your library actually limited to API21+?
Thank you very much.
when I run with url feed from blogspot with url https://www.halimlab.com/feeds/posts/default?alt=rss article displays null
Any chance of adding Atom support ?
I'm thinking of replacing my project with this one. I have rss reader android app (app is monetized with admob). Is it allowed to use this project. I do not understand licence. I apologize for posting this.
Hey, thanks for your library!
I'm still coding with a Java stack so I've tried to include your gradle variant.
The issue is that gradle has recently deprecated the 'compile' option - so I replaced it with the
implementation ("com.prof.rssparser:rssparser:2.0.4") {
exclude group: 'org.jetbrains', module: 'annotations'
}
section - 'exclude' option is because i've already had an
implementation 'org.jetbrains:annotations-java5:15.0'
line - that issued a ton of a
Duplicate class org.intellij.lang.annotations.Flow found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
errors, so I bypassed em by staying with already present annotations.
Cheers!
The application can no longer be built when the application has android:allowBackup="false"
because the library has android:allowBackup="true"
:
Error:Execution failed for task ':app:processFreeDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:30:9-36
is also present at [com.prof.rssparser:rssparser:1.0] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:28:5-166:19 to override.
Suggestion: remove the android:allowBackup="true"
from the lib manifest.
Additional, maybe also remove android:label="@string/app_name"
and android:supportsRtl="true"
I have experience a UI block in my project when upgrading the library from 1.4.4 to 2.0.1. The layout stops responding until all articles are parsed. The parser would make the call here to be represented in this layout.
I also tried parsing only one url with the same code and the UI stills blocks.
Please check this feed:
http://feeds.rsc.org/rss/bm
The creators are in the xml, but appear nowhere in an Article object. even when looking at the "toString()" data.
Is there a way to ask for specific attributes?
Thanks.
Hi, is there a way to get the title of the RSS channel from your library?
Or can you only get the data for new entries.
Thanks.
Thanks for the very useful library =)
Can you please add more channel related info? In particular:
<lastBuildDate>Mon, 20 Jan 2020 22:40:08 +0000</lastBuildDate>
<sy:updatePeriod>hourly</sy:updatePeriod>
It would be convenient to check first, whether it is time to grab new articles from a feed. Could reduce requests count.
is there step by step for beginners like me, honestly I'm confused because I'm still a beginner so please complete the tutorial, thank you
Hi, testing this url http://www.prensa-latina.cu/index.php?o=vc&id=principal&SEO=canalrss-principal the library throws this error:
W/System.err: java.net.ProtocolException: Expected leading [0-9a-fA-F] character but was 0x1f
09-07 11:24:34.088 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okhttp3.internal.http.Http1xStream$ChunkedSource.readChunkSize(Http1xStream.java:448)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okhttp3.internal.http.Http1xStream$ChunkedSource.read(Http1xStream.java:422)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.RealBufferedSource.read(RealBufferedSource.java:50)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.RealBufferedSource.request(RealBufferedSource.java:71)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.RealBufferedSource.require(RealBufferedSource.java:64)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.GzipSource.consumeHeader(GzipSource.java:114)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.GzipSource.read(GzipSource.java:73)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.Buffer.writeAll(Buffer.java:956)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:92)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okhttp3.ResponseBody.bytes(ResponseBody.java:83)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at okhttp3.ResponseBody.string(ResponseBody.java:109)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at com.prof.rssparser.Parser.doInBackground(Parser.java:68)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at com.prof.rssparser.Parser.doInBackground(Parser.java:34)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
09-07 11:24:34.093 18673-20271/cu.entumovil.barrosofeedsnews W/System.err: at java.lang.Thread.run(Thread.java:818)
Is there any way to fix it?
Thanks for this awesome library. Was wondering if there's a way to achieve pagination with this library.
java.util.concurrent.ExecutionException: java.text.ParseException: Unparseable date: "
Wed, 02 Jan 2019 07:03:36 GMT " (at offset 0)
Please Help
Hi @prof18 !!
Thanks so much, for sharing this useful library. I'm just started to use it in my app and I have found one problem. The RSS that I'm using (https://www.kitmaker.net/rss/rss_0.xml) includes some accented characters like in this title:
Armorama : Dnepromodel: Big Scale Zrínyi II
When showing this text in the app, those characters appear like a diamond with a question mark. Do you know how to solve this issue? I have tried some parsing after retrieving the contents but I had no luck with it so far.
Best regards
Juan
Hi,
is there a way to parse xml with xsl formatting?
For example :
ww.skysports.com/feeds/11669/news.xml
this xml page is transformed by an xsl stylesheet
Hi,
I am using list of urlstring and each time loading takes so much time. Is there any way in which we can cache the parsed data...?
So basically, whenever I try to actually use the artcile list, II get an error and nothing loads. But when I put some Toast or Log in the on finish it works.
Having trouble adding this to my project.
I add the dependency to my app bundle but then attempt a re-sync it gives a big old 👎
Error:(88, 13) Failed to resolve: com.prof.rssparser:rssparser:1.1
Doesn't seem like its on JCenter.
How to parse multiple RSS URL. And wait for each to finish.
Hi , First thanks for the great library .
i am trying to fetch an rss from this url : https://www.skynewsarabia.com/web/rss/markets.xml
or this : http://gulf.argaam.com/rss/home/sectionid/0?entityId=3
but the application crashes and give me this error :
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.alrabei.myproject, PID: 6136 java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference at com.alrabei.myproject.ArticleAdapter.onBindViewHolder(ArticleAdapter.java:100) at com.alrabei.myproject.ArticleAdapter.onBindViewHolder(ArticleAdapter.java:44)
i am wondering if i can fetch the rss from any website and how
"channelDescription" is not set, if "RSSKeywords.RSS_CHANNEL_IMAGE" comes before "RSSKeywords.RSS_ITEM_DESCRIPTION".
Possible fix (didn't check):
In "CoreXMLParser.kt" remove "insideChannel = false" from "RSSKeywords.RSS_CHANNEL_IMAGE" and add it to "eventType == XmlPullParser.END_TAG && xmlPullParser.name.equals("channel", ignoreCase = true)".
Please refer to this rss:
http://joeroganexp.joerogan.libsynpro.com/rss
Image is returning null always.
Every time I use this library it can only show me several posts.
Hi I was using your library with your example and I noticed that all the pages I put to parse the RSS don't get an image and the webView gets a null value.
Thanks for your work.
Is possible have pubDate as String and not as Date type?
with this I can parse pubDate with format I want.
https://www.mkb.nl/rss/dossier/1318
onError: java.text.ParseException: Unparseable date: "08/06/2018 - 08:00"
or in case the articleslist with pubDate = null
Hi,
Great library you've made there. I am using it on my app with minsdk 17, which
makes default tlsv1.2 support a bit of a pain. It would be great, if there was a way to set
a custom OkHttpClient for the library to be used.
I would do a pull request but i dont know Kotlin :(
But i think its not that hard of a feature to implement.
Just make the constructor take an OkHttpClient instance as an argument or do a setter for the client.
I've done it in java and it wokrs fine .
`
private OkHttpClient myclient;
private OnTaskCompleted onComplete;
public Parser() {
xmlParser = new XMLParser();
xmlParser.addObserver(this);
}
public Parser(OkHttpClient client) {
this.myclient = client;
xmlParser = new XMLParser();
xmlParser.addObserver(this);
}
public interface OnTaskCompleted {
void onTaskCompleted(ArrayList<com.prof.rssparser.Article> list);
void onError(Exception exception);
}
public void onFinish(OnTaskCompleted onComplete) {
this.onComplete = onComplete;
}
@Override
protected String doInBackground(String... ulr) {
Response response = null;
OkHttpClient client = null;
if(myclient!=null)
client=myclient;
else
client=new OkHttpClient();
Request request = new Request.Builder()`
App crashes after using version 1.4 works fine in 1.3.1
Hi , i try to load Rss feeds items from this url http://nasrnews.ir/%D8%A2%D8%B1%D8%B4%DB%8C%D9%88-%D8%A7%D8%AE%D8%A8%D8%A7%D8%B1/tabid/390/rssid/59/Default.aspx . the xml file doesn't actually start with so i get this error : org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT @1:2 in java.io.StringReader@c9503cd)
how can i solve this problem ?
thank
I'd like to filter out fetched RSS items when there is already an item with the same title which was fetched before
Hi, i have a problem with your library. If in the rss page there is "&" char (not &) an exception is raised.
For example trythis link http://insubs.com/rss
"onError()" isn't called, but even if there is an Exception, library tell me "RSS Parser: RSS parsed correctly!"
W/System.err: org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT @1:195 in java.io.StringReader@93bd24d)
W/System.err: at org.kxml2.io.KXmlParser.readEntity(KXmlParser.java:1219)
W/System.err: at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1401)
W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:393)
W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
W/System.err: at org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2075)
W/System.err: at com.prof.rssparser.XMLParser.parseXML(XMLParser.java:66)
W/System.err: at com.prof.rssparser.Parser.onPostExecute(Parser.java:79)
W/System.err: at com.prof.rssparser.Parser.onPostExecute(Parser.java:34)
W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:651)
W/System.err: at android.os.AsyncTask.-wrap1(AsyncTask.java)
W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err: at android.os.Looper.loop(Looper.java:148)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I/RSS Parser: RSS parsed correctly!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.