I'm attempting to create a meter that parses a webpage for information for a certain day, and so was toying with using measures in a regexp but was not able to make that work. So i looked up some Lua and am attempting to use a script to insert a variable into my expression and so change the regexp depending on the date.
Thanks in advance
INI
Code: Select all
[MeasureToday]
Measure=Time
[MeasureYesterday]
Measure=Time
TimeStamp=([MeasureToday:]-86400)
Format=%A, %B %d
DynamicVariables=1
[LuaModifyMeasureScoresText]
Measure=Script
ScriptFile=#ScoresTextPath#
mDate1=[MeasureYesterday]
Debug=1
[MeasureScoresText]
Measure=Plugin
Plugin=WebParser
Url=http://www.sportsnetwork.com/merge/tsnform.aspx?c=sportsnetwork&page=nba/stats/monthlyschedSN.aspx
RegExp="(?siU)Sunday, January 27.*FINAL: <strong>(.*)</strong>(.*) </td>"
DynamicVariables=1
Debug=1
[MeasureScore1]
Measure=Plugin
Plugin=WebParser
URL=[MeasureScoresText]
StringIndex=1
[MeasureScore2]
Measure=Plugin
Plugin=WebParser
URL=[MeasureScoresText]
StringIndex=2
[ScoresText]
Meter=String
MeasureName=MeasureScore1
MeasureName2=MeasureScore2
MeterStyle=TextStyle
Text=%1 %2
x=10
y=10
FontColor=255,255,255,255
Code: Select all
function Initialize()
sDate1 = SELF:GetOption('mDate1')
end
function Update()
sDate1 = SELF:GetOption('mDate1')
SKIN:Bang('!SetOption MeasureScoresText RegExp \"(?siU)'..sDate1..'.*FINAL: (.*)<strong>(.*)</strong> </td>\"')
SKIN:Bang('!Refresh')
return ('complete')
end
Code: Select all
...
ign="center">Monday, January 28</td> </tr>
...
nowrap>FINAL: <strong>GSW (114)</strong> - TOR (102) </td> <td class="TSN5" width="30%"
...
nowrap>FINAL: <strong>MEM (103)</strong> - PHI (100) </td> <td class="TSN1"
...
"GSW (114)" and " - TOR (102)"
"MEM (103)"..." - PHI (100)"
and any other sets of scores in that format right after any "FINAL:" , but only for specific dates.
I don't think my script has been able to alter the RegExp= option yet.
Some other things:
Removing "SKIN:Bang('!Refresh') displays the default text from the regexp, which has not been altered by the lua script, so I assume the INI is functioning properly. With the !Refresh in place, the log doesnt show debug from the webparser, and also doesnt show any values for the "LuaModifyMeasureScoresText","MeasureScoresText","MeasureScore1" or "MeasureScore2" measures. When the !Refresh is removed, LuaModifyMeasureScoresText returns a "complete" value, from the script.
Thanks again