It is currently April 28th, 2024, 1:15 am

Parsing troubles

Get help with creating, editing & fixing problems with skins
Ali1331
Posts: 7
Joined: February 21st, 2011, 11:25 pm

Parsing troubles

Post by Ali1331 »

Hi so I started using Rainmeter last week some time and I've been trying to create a WebParser skin to make up a list of the recently added content to SkyPlayer (link to the page I'm parsing). So I've been trying it in Lua for the most part and it's been hanging as soon as I open it, I've narrowed it down to the actual string.match call so I figured something was wrong with me regex pattern.

So this is what I have for the Lua pattern:

Code: Select all

".-<div class=\"listRows \">.-<div class=\"promoItem .-\">.-<a href=\"(.-)\".-onclick=\"show_waiting\(\);\".-onmouseup=\"trackLink\('View Details: (.-)','ROW1_LISTROW'\)\".-<span class=\"broadcastChannel\">(.-)</span>"
I also took it out of Lua and tried a direct WebParser RegExp= approach using:

Code: Select all

"(?siU).*<div class=\"listRows \">.*<div class=\"promoItem .*\">.*<a href=\"(.*)\".*onclick=\"show_waiting\(\);\".*onmouseup=\"trackLink\('View Details: (.*)','ROW1_LISTROW'\)\".*<span class=\"broadcastChannel\">(.*)</span>"
Now the direct WebParser attempt is a little more helpful, it prints a match error (-8) in the log, whatever that means.
I'm not too experienced at regex in general, so basically I was hoping someone could shed some light as to what my problem is.

Thanks!
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing troubles

Post by jsmorley »

(?siU).*<div class=\"listRows \">.*<div class=\"promoItem .*\">.*<a.*href=\"(.*)\".*onclick=\"show_waiting\(\);\".*onmouseup=\"trackLink\('View Details: (.*)','ROW1_LISTROW'\)\".*<span class=\"broadcastChannel\">(.*)</span>

The problem was in that bolded part which was <a href before. In the actual HTML, there are a ton of spaces after the "a" and before the "href" for some reason, so I added .* to skip the spaces.

It returns:

01=> /vod/content/SKYENTERTAINMENT/content/videoId/9ecec1b77543e210VgnVCM1000002c04170a________/content/default/videoDetailsPage.do
02=> Ep 8 House of Mirrors
03=> Sky1

If you are planning to click on that link and go to it, you will need to put the site info on the front of it, as it is a "relative" link.

You want to end up sending:

"http://skyplayer.sky.com/vod/content/SKYENTERTAINMENT/content/videoId/9ecec1b77543e210VgnVCM1000002c04170a________/content/default/videoDetailsPage.do"

So you will need to append "http://skyplayer.sky.com" to the front. This little sample seems to work:

Code: Select all

[Rainmeter]
DynamicWindowSize=1
Update=1000

[MeasureSky]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=http://skyplayer.sky.com/vod/content/Showcase/Browse_Showcase/Just_Added/content/default/promoPage.do
RegExp="(?siU).*<div class=\"listRows \">.*<div class=\"promoItem .*\">.*<a.*href=\"(.*)\".*onclick=\"show_waiting\(\);\".*onmouseup=\"trackLink\('View Details: (.*)','ROW1_LISTROW'\)\".*<span class=\"broadcastChannel\">(.*)</span>"

[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSky]
StringIndex=1

[MeasureName]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSky]
StringIndex=2

[MeasureStation]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSky]
StringIndex=3

[MeterInfo]
Meter=String
MeasureName=MeasureName
MeasureName2=MeasureStation
X=0
Y=0
FontSize=12
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Show: %1 | Station: %2
LeftMouseUpAction=!Execute ["http://skyplayer.sky.com[MeasureLink]"]
P.S. You actually don't have to escape quotes " in a RegExp. These are the reserved characters for Regular Expression that need to be escaped:

[ ] \ ^ $ . | ? * + ( ) { }
Ali1331
Posts: 7
Joined: February 21st, 2011, 11:25 pm

Re: Parsing troubles

Post by Ali1331 »

Ahh thank you so much! The one place I haven't accounted for giant gaps! Direct WebParser method works perfectly.

Is this kind of thing a no go in Lua btw? I changed the pattern to your fixed version but it just hangs and I don't know why.

Edit: Maybe this means something for the Lua? I wasn't quite sure

DEBUG: (00:03:49.540) WebParser: [SkyCheck] (Index 0) "-
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing troubles

Post by jsmorley »

Should be possible in Lua for sure.

Start up the Rainmeter log from the system tray icon context menu and watch the log for errors from the Lua.
Ali1331
Posts: 7
Joined: February 21st, 2011, 11:25 pm

Re: Parsing troubles

Post by Ali1331 »

Well there are no errors in the log, after I start up the skin Rainmeter freezes entirely and I have to kill it from Task manager.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing troubles

Post by jsmorley »

Well. That's not good.

You want to post your skin .ini file and lau .lua file here in " tags? I can take a peek. I don't care if it is wearing lipstick and has shaved its legs.
Ali1331
Posts: 7
Joined: February 21st, 2011, 11:25 pm

Re: Parsing troubles

Post by Ali1331 »

It started off as a copy of your LuaRainRSS tutorial skin so alot of it is still like that.

Skin .ini:

Code: Select all

[SkyCheck]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://skyplayer.sky.com/vod/content/Showcase/Browse_Showcase/Just_Added/content/default/promoPage.do
RegExp="(.*)"
Debug=2
Debug2File=#CURRENTPATH#LuaRainRSS.txt
UpdateRate=55
FinishAction=!RainmeterEnableMeasure SkyCheckLua #CURRENTCONFIG#

[SkyCheckLua]
Measure=Script
ScriptFile="#CURRENTPATH#LuaRainRSS.lua"
TableName=LuaRainRSS
FileToParse="#CURRENTPATH#LuaRainRSS.txt"
NumberToDisplay=1
UpdateDivider=60
Disabled=1

[MeterTitle1]
Meter=String
MeterStyle=TextStyle | Color2Style
Text=#Title1#
Y=54
LeftMouseUpAction=#Link1#
LuaRainRSS.lua

Code: Select all

PROPERTIES =
{
	FileToParse = "";
	NumberToDisplay = 0;
}

function Initialize()
	sFileToParse = PROPERTIES.FileToParse
	iNumberToDisplay = PROPERTIES.NumberToDisplay
	
	itemPattern = ".-<div class=\"promoItem odd\">.-<a.-href=\"(.-)\".-onclick=\"show_waiting\(\);\".-onmouseup=\"trackLink\('View Details: (.-)','ROW1_LISTROW'\)\".-<span class=\"broadcastChannel\">(.-)</span>.-</div>"

	pattern = ".-<div class=\"listRows \">"
	for i=1, iNumberToDisplay do
		pattern = pattern..itemPattern
	end
	
	tNames = {}
	tChannel = {}
	tLinks = {}
end 

function Update()
	hReadingFile = io.input(sFileToParse)
	
	sAllText = io.read("*all")
	
	tLinks[1], tNames[1], tChannel[1] = string.match(sAllText, pattern)
	
	for i = 1, iNumberToDisplay do
		print(tLinks[i].."\n"..tNames[i].."\n"..tChannel[i].."\n\n")
	end
	io.flush(hReadingFile)
end

function GetStringValue()
	return "Success"
end 
Last edited by Ali1331 on February 22nd, 2011, 12:26 am, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing troubles

Post by jsmorley »

Ok, give me a few to poke at this with a stick.
Ali1331
Posts: 7
Joined: February 21st, 2011, 11:25 pm

Re: Parsing troubles

Post by Ali1331 »

Doh I had the RegExp field of the WebParser as "(.-)" instead of "(.*)", it still hangs, but now there's

Code: Select all

DEBUG: (00:00:06.349) WebParser: [SkyCheck] (Index  0) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

DEBUG: (00:00:06.349) WebParser: [SkyCheck] (Index  1) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
in the log file.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing troubles

Post by jsmorley »

Yeah, I was just coming here to tell you that. Still looking...