It is currently April 27th, 2024, 4:49 pm

Help with Toodledo RSS parsing [RegEx, Reader.lua, Enigma]

Get help with creating, editing & fixing problems with skins
gogetit
Posts: 6
Joined: December 18th, 2011, 10:06 pm

Help with Toodledo RSS parsing [RegEx, Reader.lua, Enigma]

Post by gogetit »

Hi,
I'm trying to modify reader.lua code, part of Enigma, to support Toodledo RSS [to-do list].

First, here's what the feed look like:

Code: Select all

<title>Toodledo :: to-do list</title>
	<link>http://www.toodledo.com/</link>
	<description>Your to-do list </description>
	<lastBuildDate>Fri, 06 Jan 2012 00:00:01 GMT</lastBuildDate>
	<language>en-us</language>
	<ttl>300</ttl>
			<item>
		<title>some task #1</title>
		<link>http://www.toodledo.com/tasks/...</link>
		<guid>http://www.toodledo.com/tasks/...</guid>
		<pubDate>Fri, 06 Jan 2012 00:00:01 GMT</pubDate>
		<description><![CDATA[												Due Date: By Jan 05<br />		Repeat: Every 1 month<br />		 Priority: Top<br />										]]></description>
		</item>
			<item>
		<title>some task #2</title>
		<link>http://www.toodledo.com/tasks/...</link>
		<guid>http://www.toodledo.com/tasks/...</guid>
		<pubDate>Fri, 06 Jan 2012 00:00:01 GMT</pubDate>
		<description><![CDATA[												Due Date: By Jan 06<br />				 Priority: High<br />										]]></description>
		</item>
		
		

I would like to extract the due date, right after Due By:... in the description node.
So I added the following code to Reader.lua

Code: Select all

	elseif string.match(sRaw, '<title>Toodledo') then
		sRawCounted, iNumberOfItems = string.gsub(sRaw, '<item', "")
		sPatternFeedLink = '.-<link.->(.-)</link>'
		sPatternItem = '<item.-</item>'
		sPatternItemLink = '.-<link.->(.-)</link>'
		sPatternItemDesc = '.-<description.->(.-)</description>'
		sPatternItemDate = '.-<description.->.*Due Date: By(.-)<br.*</description>'
However, I keep getting Jan 05 [the first die date] for all items. So what am I doing wrong?

Am I right to think the issue is with the RegEx expression, or am I missing something out? Shouldn't sPatternItemDate = '.-<description.->.*Due Date: By(.-)<br.*</description>' cover it right?

Thanks a lot, I hope I explained it correctly.
gogetit
Posts: 6
Joined: December 18th, 2011, 10:06 pm

Re: Help with Toodledo RSS parsing [RegEx, Reader.lua, Enigm

Post by gogetit »

Can anyone please help out?
How can I parse Due Date in the description note? Thanks.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Help with Toodledo RSS parsing [RegEx, Reader.lua, Enigm

Post by poiru »

What you posted works fine here. Did you modify the skin correctly?

I tested with the following.

Code: Select all

[Item1]
Meter=STRING
MeterStyle=StyleReaderText | StyleReaderTextFirst
Text=#ItemTitle1# #ItemDate1#
LeftMouseUpAction=!Execute ["#ItemLink1#"]
ToolTipText=#ItemLink1#