It is currently July 17th, 2019, 1:43 pm

a few days left for Google Reader

Tips and Tricks from the Rainmeter Community
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

a few days left for Google Reader

moshi » June 20th, 2013, 12:27 pm

it is less than ten days to the date that Google announced it will end Google Reader. this has a little impact on Rainmeter as it no longer can be used as a tool to build feed readers that support both RSS and Atom sources (as the Illustro skin does for example).

now there is Kaelri's Reader skin and it is an awesome piece of work which you should try. the bad part is that it uses Lua, so if you want to use a non-Latin feed you are out of luck as Lua does not support Unicode.

fortunately there is another way to build an universal feed reader in Rainmeter, and it does not use Lua. for this we have to use the webparser plugin to parse webparser measures. basically we do not only have parent and child measures, but also grandchildren and their offsprings as well.

first of all we have to get the whole feed, this will be our parent measure. we use this regular expression for that task: RegExp="(?siU)^(.*)$"

Code: Select all

[MeasureBase]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#UniNewsFeedURL#
RegExp="(?siU)^(.*)$"
Debug=1
StringIndex=1
DecodeCharacterReference=0
CodePage=#UniNewsCodePage#

then we'll tear what this measure returns apart, step by step. first we'll get the content of each item of this feed:

Code: Select all

[MeasureItem1RSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureBase]
RegExp="(?siU).*<item>(.*)</item>"
StringIndex=1
DecodeCharacterReference=0

[MeasureItem2RSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureBase]
RegExp="(?siU).*<item>(.*)</item>.*<item>(.*)</item>"
StringIndex=1
DecodeCharacterReference=0

...
this will only return something if the feed is an RSS feed. Atom feeds do not use <item> tags.

so we need to add measures for Atom feeds as well:

Code: Select all

[MeasureItem1Atom]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureBase]
RegExp="(?siU).*<entry>(.*)</entry>"
StringIndex=1
DecodeCharacterReference=0

[MeasureItem2Atom]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureBase]
RegExp="(?siU).*<entry>(.*)</entry>.*<entry>(.*)</entry>"
StringIndex=1
DecodeCharacterReference=0

...
now we can start to add measures to get the content inside these measures, let's get the descriptions of an evantual RSS feed first:

Code: Select all

[MeasureDescription1RSSPre]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureItem1RSS]
RegExp="(?siU).*<description>(.*)</description>"
StringIndex=1
DecodeCharacterReference=1

[MeasureDescription1RSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureDescription1RSSPre]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#UniNewsSubstitute#

[MeasureDescription2RSSPre]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureItem2RSS]
RegExp="(?siU).*<description>(.*)</description>"
StringIndex=2
DecodeCharacterReference=1

[MeasureDescription2RSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureDescription2RSSPre]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#UniNewsSubstitute#

...
of course we need the same for Atom feeds. Most Atom feeds use <summary> tags:

Code: Select all

[MeasureSummary1AtomPre]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureItem1Atom]
RegExp="(?siU).*<summary.*>(.*)</summary>"
StringIndex=1
DecodeCharacterReference=1

[MeasureSummary1Atom]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureSummary1AtomPre]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#UniNewsSubstitute#

...
but this will not work for all Atom feeds. some use <content> tags. let's add this as well:

Code: Select all

[MeasureContent1AtomPre]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureItem1Atom]
RegExp="(?siU).*<content.*>(.*)</content>"
StringIndex=1
DecodeCharacterReference=1

[MeasureContent1Atom]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureContent1AtomPre]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#UniNewsSubstitute#

...
fine, so we got the description of the first item. but it's three different measures. how does a meter know which of the three measures it shall display?
we'll create another measure. just a calc measure that returns 1, and then we'll use substitute to replace that little number:

Code: Select all

[MeasureDescription1]
Measure=Calc
Formula=1
DynamicVariables=1
Substitute="1":"[MeasureDescription1RSS]","":"[MeasureSummary1Atom]","":"[MeasureContent1Atom]","€€€€":'"'

...
what it does is replacing 1 with the first measure, if the first measure is empty it replaces it with the second, etc.

did you notice "€€€€":'"' at the end of the substitution? quotes are likely to break substitions. this is why i am using this: UniNewsSubstitute='"':"€€€€" to encode them before and decode them back when everything is finished.


the attached example skin supports RSS, RDF, Atom and OPML feeds. it uses Poiru's Illustro design, so it can be used as a substitute until the dev team finds a better solution.

this method of parsing measures can also be adapted to feeds that are not strictly keeping their layout (some items have an image in <image> tags, others don't for example.) which would usually break the "traditional" method of feed reading in Rainmeter.

==================================================================

edit: support for RDF feeds added

edit 2: made the whole thing resource friendlier

edit 3: fix for some feeds that include links in <![CDATA[ tags
You do not have the required permissions to view the files attached to this post.
Last edited by moshi on July 4th, 2013, 6:18 pm, edited 5 times in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3405
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: a few days left for Google Reader

eclectic-tech » June 21st, 2013, 2:24 am

Thanks for this moshi! :great:

I've been looking for ways to modify some of my older reader skins... now I have a starting point!
User avatar
fonpaolo
Moderator
Posts: 1351
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: a few days left for Google Reader

fonpaolo » June 30th, 2013, 5:09 pm

That's really great and I'll try to create a new RSS skin using your code. :thumbup:

Just tried with this feed: http://www.renderosity.com/mod/p2p_rss/feed.php?id=28
It's an xml type, but nothing is showing and I don't have the time to try to modify it to match the new scheme without break something... :oops:
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: a few days left for Google Reader

moshi » June 30th, 2013, 7:59 pm

actually that's an RDF (not RSS) feed which is indeed not supported by my skin.
i'll add support for that soon. it won't work with Kaelri's Reader as well (first title is wrong)
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: a few days left for Google Reader

moshi » June 30th, 2013, 8:22 pm

ok, support for RDF feeds has been added
User avatar
fonpaolo
Moderator
Posts: 1351
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: a few days left for Google Reader

fonpaolo » July 1st, 2013, 2:16 pm

moshi wrote:actually that's an RDF (not RSS) feed which is indeed not supported by my skin.
i'll add support for that soon. it won't work with Kaelri's Reader as well (first title is wrong)
Ooops... sorry, I have given a very quick look into it and didn't noticed that "little" difference... :oops:

Thanks anyway for the update! :thumbup: :D

P.S. now I know the reason why my modifies didn't worked... :lol:
gffmac
Posts: 19
Joined: July 3rd, 2013, 2:37 pm

Re: a few days left for Google Reader

gffmac » July 3rd, 2013, 3:20 pm

Thanks for the work on this. I have duplicated the skin so I can have 4 feeds but rainmeter crashes when ever I refresh in rainmeter, works fine on starting of rainmeter...

Image
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: a few days left for Google Reader

moshi » July 3rd, 2013, 5:30 pm

gffmac wrote:Thanks for the work on this. I have duplicated the skin so I can have 4 feeds but rainmeter crashes when ever I refresh in rainmeter, works fine on starting of rainmeter...
there is nothing i can do about that. there is more going on then in a usual feed reader skin, but in the end it is your computer that can't handle that.
what you could try is putting a semicolon in front of UniNewsSubstitute like this:

Code: Select all

;UniNewsSubstitute=...
. it should require less processing power then.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3405
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: a few days left for Google Reader

eclectic-tech » July 3rd, 2013, 6:02 pm

gffmac wrote:Thanks for the work on this. I have duplicated the skin so I can have 4 feeds but rainmeter crashes when ever I refresh in rainmeter, works fine on starting of rainmeter...

Image
I just created a 5 feed skin using Moshi's code and it works flawlessly on my old beater of a PC...
You might try removing the space in your folder name 'UniNews1' instead of 'UniNews 1' or put the link inside Quotatation marks. :confused:
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: a few days left for Google Reader

moshi » July 3rd, 2013, 9:11 pm

i uploaded a new version of the example skin. this should be a little resource-friendlier as all meters and measures except the update counter are set to UpdateDivider=-1. this might make it a little harder to adapt it to other skins though, so have a closer look if you want to get your hands dirty.