It is currently May 17th, 2022, 10:20 am

BBC Feed Reader - w/ sorting

RSS, ATOM and other feeds, GMail, Stocks, any information retrieved from the internet
User avatar
Mordasius
Posts: 1089
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

BBC Feed Reader - w/ sorting

Post by Mordasius »

The attached skin and accompanying LUA script build on the LuaRainRSS skin by JS Morley ( http://forum.rainmeter.net/viewtopic.php?f=27&t=6395 )

The aim was to overcome the problem that news feeds from the BBC sites don't list the topics with the most recent first. If you use a feed reader that just picks up the first 5-10 <title>(.*)</title> entries you may miss out on the most recent posts and you certainly won't see them in any chronological order .

The Lua Script was therefore updated to list the feed topics with the most recent at the top. The script reads 20 entries and the 10 most recent entries are then displayed by the skin. Any items posted since the skin was last updated are bulleted.

It's still not very elegant so I'd appreciate suggestions on how to tidy it up.
UPDATE: The first version was withdrawn becaues it crashed Rainmeter
The latest (24th July) version seems to work well enough without causing crashes
My apologies to anyone who downloaded the 1st Version
You do not have the required permissions to view the files attached to this post.
Last edited by Mordasius on July 26th, 2011, 12:34 am, edited 8 times in total.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: BBC Feed Reader - w/ sorting

Post by Seahorse »

Was about to say this crashes Rainmeter in a big way, but I see you have updated the OP... :(

Let us know when you get it working as intended.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
Mordasius
Posts: 1089
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: BBC Feed Reader - w/ sorting

Post by Mordasius »

Seahorse wrote:Was about to say this crashes Rainmeter in a big way...
Sorry about that. The problem, which I'd actually flagged in the LUA script, was that I was using SKIN:Bang("!RainmeterSetVariable PubDate"..tostring(n).." \""..Record.iPub.."\"") for all 20 items that had been read rather than just the top 10 displayed by the skin. This wasn't a problem while I was working on the script and refreshing it often but it crashed rainmeter when left doing its own thing on the desktop.

I'll post the corrected version after I've played a little more with the script.
User avatar
jsmorley
Developer
Posts: 22519
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: BBC Feed Reader - w/ sorting

Post by jsmorley »

Mordasius wrote: Sorry about that. The problem, which I'd actually flagged in the LUA script, was that I was using SKIN:Bang("!RainmeterSetVariable PubDate"..tostring(n).." \""..Record.iPub.."\"") for all 20 items that had been read rather than just the top 10 displayed by the skin. This wasn't a problem while I was working on the script and refreshing it often but it crashed rainmeter when left doing its own thing on the desktop.

I'll post the corrected version after I've played a little more with the script.
One thing you have to be careful of, as was just discussed in this thread, http://rainmeter.net/forum/viewtopic.php?p=53042#p53042 is that when you send a value to a skin using the !RainmeterSetVariable (or just !SetVariable in newer betas) you need to "quote" any strings that have spaces in them, or Rainmeter will get very confused and think you are sending optional "Config" parameters on the bang.
User avatar
Mordasius
Posts: 1089
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: BBC Feed Reader - w/ sorting

Post by Mordasius »

jsmorley wrote:One thing you have to be careful of, as was just discussed in this thread, http://rainmeter.net/forum/viewtopic.php?p=53042#p53042 is that when you send a value to a skin using the !RainmeterSetVariable (or just !SetVariable in newer betas) you need to "quote" any strings that have spaces in them....
Yes I learnt that on my only other foray into LUA scripts and you set me right then http://rainmeter.net/forum/viewtopic.php?f=28&t=7190&p=44287#p44287 This time I got the \""..VarNameHere.."\"" bit right but was BANGING to undeclared variables.

It's all sorted now with a one liner to get rid of the unwanted values in the table

Code: Select all

 for i = 1, (iNumberToRead-iNumberToShow) do table.remove(tPubDate_Array) end 
I'm now playing around with findpattern and string.match trying to find a neater way of reading an unknown number of <item> </item> entries from the text file.

P.S. On a realted matter

Is there any converter or wrapper or something that would allow us to quickly paste LUA scripts intended for Rainmeter in to SciTE for debugging and stepping?
User avatar
jsmorley
Developer
Posts: 22519
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: BBC Feed Reader - w/ sorting

Post by jsmorley »

"Is there any converter or wrapper or something that would allow us to quickly paste LUA scripts intended for Rainmeter in to SciTE for debugging and stepping?"

No, not at this time certainly. I'm not sure it would ever be possible given that the Lua is being executed within the larger C++ Rainmeter environment. About the only thing you can do is liberally use "print()" statements in your code, to send the values of variables and such to the Rainmeter log and view them in "About" while the skin is running. Then when all works, you can remove them from the Lua.
User avatar
Mordasius
Posts: 1089
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: BBC Feed Reader - w/ sorting

Post by Mordasius »

Ok Folks. The BBC Feed Reader has been fixed so that it doesn't crash Rainmeter.

The Lua Script reads 20 entries and then displays the 10 most recent entries with 'bullets' for any topics that are new since the feed was last read.

The LUA script is still pretty crude but I accept that this is not a LUA forum and don't expect suggestions on how to improve the bit which reads the text file and slaps it to a LUA table (that said any LUA experts are more than welcome to post or PM me with suggestions).
Last edited by Mordasius on July 22nd, 2011, 10:48 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22519
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: BBC Feed Reader - w/ sorting

Post by jsmorley »

Seems to work fine. I think there is still "something" that Rainmeter doesn't like, as it did crash Rainmeter one time, when it tried to load the skin the very first time when running the .rmskin. Might have been a coincidence as I do a LOT of testing of my own works in progress and stuff to help others, and my Rainmeter may have already been unstable, but I suspect there is something that Rainmeter is not liking.

Edit: I think part of the problem is this:

io.flush(hReadingFile)

That is my fault. It really should be io.close, not io.flush. We are leaving that .txt file "locked" open, even after the skin is unloaded, and I suspect that is causing an issue with runaway file handles or not allowing WebParser to recreate the file when the site updates. When it fails, it may be borking WebParser in general, which is going to cause all kinds of problems. I changed that, and I will beat it up to see if it remains stable.

The other thing I would be tempted to do is to send a bang at the end of the Update() in the Lua to re-"disable" the script measure. In other words, have the WebParser turn on the script using OnFinishAction when it goes out for the web site, and then have the script turn itself off again when it is done. I know you have an UpdateDivider on the script measure, but I'd be more comfortable in this case to have the WebParser measure "drive" things, rather than risk having the script trying to read the file at the same time the WebParser is trying to write it.
User avatar
Mordasius
Posts: 1089
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: BBC Feed Reader - w/ sorting

Post by Mordasius »

jsmorley wrote: Edit: I think part of the problem is io.flush(hReadingFile) ... should be io.close....
Thanks. I've fixed that in the latest version attached to the first post on this topic.
jsmorley wrote: The other thing I would be tempted to do is to send a bang at the end of the Update() in the Lua to re-"disable" the script measure.
I added SKIN:Bang("!DisableMeasure MeasureLuaScript") to the LUA script and there were no errors but there was still a value for MeasureLuaScript showing in the about view. I thought disabled measures showed 0.0 or blank. Just for fun I changed it to SKIN:Bang("!DisableMeasure \""..MeasureLuaScript.."\"") which effectively disabled the measure by crashing Rainmeter! :lol:
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: BBC Feed Reader - w/ sorting

Post by Seahorse »

I'll test the new version as I'm on the BBC website all the time ;) I've tinkered with it to match my current theme and played with font and spacing, seems to be stable so far.
Capture.PNG
You do not have the required permissions to view the files attached to this post.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt