Dynamic URL (link) in WebParser
(if it allowed to be called so, Dynamic WebParser... )
In this trick i'll show you how to change link in your WebParser measure without refreshing skin, interested?
Lets go on!
• First you need WebParser measure which will parse a url from file where your variables are stored. This measure is used for reading changes on our url, for example by bang !WriteKeyValue, or other way.
Code: Select all
[mParsURL]
Measure=Plugin
Plugin=WebParser.dll
Url=file://#CURRENTPATH#Configs\Variables\MyVariables.inc
RegExp="(?siU)RSSURL1=(.*)RSSURL2"
UpdateDivider=3600
UpdateRate=1
;CodePage=1200 (optional)
Disabled=1
StringIndex=1
○ RegExp="(?siU)RSSURL1=(.*)RSSURL2" - regular expression to pars URL (according to your set of variables this expression is different, example is below)
- for example (MyVariables.inc)
Code: Select all
[Variables]
RSSURL1=http://rainmeter.net/forum/feed.php
RSSURL2=http://feeds.gawker.com/lifehacker/full
○ CodePage=1200 (optional) - you can use code page when reading data from file, use this in case of different encoding type of file.
• Then we need second WebParser measure for dumping data of all content to file. This file will be needed to parse titles, link, anything. This example uses google reader advantages (say thanx to poiru for sharing with us).
Code: Select all
[mDownload]
Measure=Plugin
Plugin=WebParser.dll
Url=http://www.google.co.uk/reader/view/feed/[mParsURL]?n=9
StringIndex=1
Download=1
DownloadFile=zxc1.xml
FinishAction=!EnableMeasure RSS1 "#CURRENTCONFIG#"
this measure downloads all content in zxc1.xml file, as you see from ○ DownloadFile=zxc1.xml, after measure [mDownload] finished downloading it will enable main measure FinishAction=!EnableMeasure RSS1 "#CURRENTCONFIG#" which we need for (as i wrote earlier) parsing titles, links, etc. and showing information in Meters.
I know that this meter "#CURRENTCONFIG#" has been fixed and is not needed but sometimes i stumbling upon strange behavior of how all thing should work and they don't. Any way it is not a mistake it is more sort of precaution.
• And finally the third measure (main) for showing info in meters
Code: Select all
[RSS1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=file://#CURRENTPATH#DownloadFile\zxc1.xml
RegExp="(?siU)<h1>(.*)</h1>#feed_i##feed_i#"
UpdateRate=2
StringIndex=1
Disabled=1
DecodeCharacterReference=1
FinishAction=!DisableMeasure RSS1 "#CURRENTCONFIG#"
Now, when you know how thing are working, welcome to try example skin.
Note, you need to download and install it due to additional file which skin is using (download below)
Code: Select all
[Rainmeter]
Author=Faradey
Update=1000
; Skin-example of dynamically changing url in WebParser
[Variables]
feed_i=.*(?(?=.*<div class="item">).*<div class="item">.*<a href="(.*)">(.*)</a>)
[Back]
Meter=Image
SolidColor=1,1,1,180
W=300
H=200
[BackInput]
Meter=Image
SolidColor=100,100,100,180
X=10
Y=8
W=280
H=20
LeftMouseUpAction=!PluginBang "RSSMeasureInput ExecuteBatch 1"
[RSSMeasureInput]
Measure=Plugin
Plugin=InputText.dll
SolidColor=250,250,250,215
FontColor=2,2,2,250
FontFace="Seqoe UI"
AntiAlias=1
StringStyle=Normal
StringAlign=LEFT
FontSize=12
X=10
Y=8
W=280
H=20
FocusDismiss=1
DefaultValue="type in your url..."
Command1=!Execute [!WriteKeyValue Variables RSSURL1 "$UserInput$" "#CURRENTPATH#Variables\MyVariables.inc"][!UpdateMeasure mParsURL "#CURRENTCONFIG#"]
Substitute="":"type in the url to start test"
[mParsURL]
Measure=Plugin
Plugin=WebParser.dll
Url=file://#CURRENTPATH#Variables\MyVariables.inc
RegExp="(?siU)RSSURL1=(.*)RSSURL2"
UpdateDivider=3600
UpdateRate=1
;CodePage=1200 (optional)
Disabled=0
StringIndex=1
[mParsLines]
Measure=Plugin
Plugin=WebParser.dll
Url=http://www.google.co.uk/reader/view/feed/[mParsURL]?n=9
StringIndex=1
Download=1
DownloadFile=zxc1.xml
FinishAction=!EnableMeasure RSS1 "#CURRENTCONFIG#"
[RSS1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=file://#CURRENTPATH#DownloadFile\zxc1.xml
RegExp="(?siU)<h1>(.*)</h1>#feed_i##feed_i#"
UpdateRate=2
StringIndex=1
Disabled=1
DecodeCharacterReference=1
FinishAction=!DisableMeasure RSS1 "#CURRENTCONFIG#"
[MeasureRSS1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[RSS1]
StringIndex=3
DecodeCharacterReference=1
[MeasureURL1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[RSS1]
StringIndex=2
[MeasureRSS2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[RSS1]
StringIndex=5
DecodeCharacterReference=1
[MeasureURL2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[RSS1]
StringIndex=4
[MainMeter]
Meter=STRING
MeasureName=RSSMeasureInput
MeasureName2=RSS1
MeasureName3=MeasureRSS1
Measurename4=MeasureRSS2
X=20
Y=40
Text="URL: %1#CRLF##CRLF##CRLF#Title: %2 #CRLF##CRLF# - %3#CRLF##CRLF# - %4"
StringStyle=BOLD
StringAlign=LEFT
FontColor=155,255,205
FontSize=10
FontFace=Arial
AntiAlias=1
W=260
H=150
ClipString=1