It is currently April 16th, 2024, 11:07 pm

Dynamic URL in WebParser (without refreshing the skin)

Tips and Tricks from the Rainmeter Community
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Dynamic URL in WebParser (without refreshing the skin)

Post by ~Faradey~ »

Hey guys) here is another trick for you

Dynamic URL (link) in WebParser
(if it allowed to be called so, Dynamic WebParser... :D )

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
Url=file://#CURRENTPATH#Configs\Variables\MyVariables.inc - this line where you put path to your variable's file.

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
UpdateDivider=3600 - this value is actual update rate of RSS feed. Means how often you need data to be updated. Current value is 3600 ms which means once per hour.

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#"
Url=http://www.google.co.uk/reader/view/feed/[mParsURL]?n=9 - as you see i used parsed line from [mParsURL] measure and puted it in url of second measure. This method is well described here http://rainmeter.net/cms/Tips-WebParserImageRelative

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#"
Url=file://#CURRENTPATH#DownloadFile\zxc1.xml - as you see from here this measure reads data from file too. The file what has been downloaded by [mDownload] measure. In the end measure [RSS1] should be disabled! it is needed measure for future use! Actually you can find another way of triggering between measures, i've showed you one of them.

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
You do not have the required permissions to view the files attached to this post.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Dynamic URL in WebParser (without refreshing the skin)

Post by poiru »

I think you will like Rainmeter 2.3. Just sayin'... :sly:
User avatar
XANCI
Posts: 104
Joined: September 18th, 2011, 6:37 am
Location: Nanjing, China

Re: Dynamic URL in WebParser (without refreshing the skin)

Post by XANCI »

poiru wrote:I think you will like Rainmeter 2.3. Just sayin'... :sly:
DynamicVariables in plugin measure?
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Dynamic URL in WebParser (without refreshing the skin)

Post by poiru »

XANCI wrote: DynamicVariables in plugin measure?
Maybe, maybe not :p
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Dynamic URL in WebParser (without refreshing the skin)

Post by ~Faradey~ »

poiru wrote: Maybe, maybe not :p
eeeee)) it's not fair, now i wouldn't sleep, thinking about : what the he** there will be? i'm so intrigued)))
How many aces do you have in your pocket? ha))..?
Guys, good luck with new release, i know how hard it is :bow: