You are not logged in.

#1 2015-05-17 22:58:15

zacariaz
Member
From: Denmark
Registered: 2012-01-18
Posts: 539

Conky and RSS

This is obviously a topic which has been discussed a lot, and yet I've been unsuccessful in finding a solution to my rather simple problem.

In short:
* I want to follow various different RSS feeds.
* I need only titles.
* I only want updates from within a given time period, or the most recent N updates.
* I need the ability to wrap lines to a given width.
* I want to disregard any formatting, html or otherwise.

It seems simple enough, an I've been trying to find a text based RSS parser or whatever to help in my endeavors, but as I said, I haven't been very successful.

My current, and very temporary solution, for the Arch News feed alone, using the tools I know, looks like this:

curl -s https://www.archlinux.org/feeds/news/ | tr -d '\n' | sed 's/<link>[^<>]*<\/link><description>[^<>]*<\/description><dc:creator[^>]*>[^<>]*<\/dc:creator>//g;s/<title>\|<\/title>/___/g;s/<pubDate>\|<\/pubDate>\|<guid[^>]*>[^<>]*<\/guid>\|<\/\?item>\|^.*<\/lastBuildDate>\|<\/channel>.*$\|\+0000//g' | awk -F "___" 'END{for(i=0;i<20;i+=2){sub(/Jan/,"01",$(i+3));sub(/Feb/,"02",$(i+3));sub(/Mar/,"03",$(i+3));sub(/Apr/,"04",$(i+3));sub(/May/,"05",$(i+3));sub(/Jun/,"06",$(i+3));sub(/Jul/,"07",$(i+3));sub(/Aug/,"08",$(i+3));sub(/Sep/,"09",$(i+3));sub(/Oct/,"10",$(i+3));sub(/Now/,"11",$(i+3));sub(/Dec/,"12",$(i+3));$(i+3)=substr($(i+3),12,4) " " substr($(i+3),9,2) " " substr($(i+3),6,2) " " substr($(i+3),17,2) " " substr($(i+3),20,2) " " substr($(i+3),23,2);$(i+3)=mktime(strftime("%Y %m %d %H %M %S"))-mktime($(i+3));if($(i+3)<3600*24*7)printf "%s\n",$(i+2)}}'| fold -s -w60

So you can imagine my annoyance that I haven't been able to do better. Sure it works, but man it's ugly. Well, I could probably do a little better, but the main point is that the approach is simply wrong.


So, getting to the point, I'd be very interested in hearing your recommendations.


Best regards.


I am a philosopher, of sorts, not a troll or an imbecile.
My apologies that this is not always obvious, despite my best efforts.

Offline

#2 2015-05-18 00:35:31

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Conky and RSS

Numerous languages have XML and even RSS parsing libraries. If you don't already know one of these then this would be a perfect little project to learn one. I would recommend starting with Python and the feedparser module. The module is available under the name python-feedparser in the official repos.

It should be straight-forward to do what you want. In any case I doubt that it will be anywhere near as complex as the pipe in your post.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2015-05-18 01:45:37

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Offline

#4 2015-05-18 02:29:16

zacariaz
Member
From: Denmark
Registered: 2012-01-18
Posts: 539

Re: Conky and RSS

Xyne wrote:

Numerous languages have XML and even RSS parsing libraries. If you don't already know one of these then this would be a perfect little project to learn one. I would recommend starting with Python and the feedparser module. The module is available under the name python-feedparser in the official repos.

It should be straight-forward to do what you want. In any case I doubt that it will be anywhere near as complex as the pipe in your post.

I seem to recall messing about with feedparser back in the day, and having a bunch of trouble due to py2/3 complications. In any case that is probably where I'll end up, if nothing else shows up, but I was thinking more along the lines of a text based news aggregator or something, from which I can simply take the output, clean it up a bit and be done with it.

Sadly none of those I've tried have worked out for me.


Anyway, thanks for your input.


I am a philosopher, of sorts, not a troll or an imbecile.
My apologies that this is not always obvious, despite my best efforts.

Offline

#5 2015-05-18 02:30:38

zacariaz
Member
From: Denmark
Registered: 2012-01-18
Posts: 539

Re: Conky and RSS

Perhaps.

Thanks for your input.


I am a philosopher, of sorts, not a troll or an imbecile.
My apologies that this is not always obvious, despite my best efforts.

Offline

Board footer

Powered by FluxBB