It is currently March 28th, 2024, 7:03 pm

Help with Reg Exp

Get help with creating, editing & fixing problems with skins
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Help with Reg Exp

Post by jminternelia »

I'm a bit new to this.

I downloaded this skin and intend to make some changes.
https://kilofoxtrot.deviantart.com/art/KF-Radar-for-Rainmeter-334914463

To do so requires me to download quite a few (inanimate) .gifs from here:
https://radar.weather.gov/ridge/RadarImg/NCR/TWX/

Thus far, I've failed to come up with the correct RegExp. The issue is that these are all named with dates instead of numbers.

TWX_20180519_1418_NCR.gif

On top of that, I sort of need to be able to substitute TWX with a variable key based on the user's selected local radar site. Are register expressions compatible with that sort of thing?

The primary reason for this specific site is because the layers are all downloaded separately, and as such I can apply various effects like blur or other images to the background, with the radar itself, the counties, highways, etc all showing on a transparent backdrop.

Here is the code I have been tinkering with thus far. I saw a couple of old posts, and did try to figure this out, but have come up short so far. I didn't modify anything past the MeasureImage3, as I keep getting errors.

https://forum.rainmeter.net/viewtopic.php?t=9862

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=0

[Variables]
;closest radar site name, from http://forecast.weather.gov/jetstream/doppler/ridge_download.htm
Site=TWX
;update rate multiplier (i.e., seconds... formula: Update x Rate)
Rate=60
;Radar range (can be Short or Long)
Range=Short
;product type, from http://forecast.weather.gov/jetstream/doppler/ridge_download.htm
;if using Long range, Type MUST be N0Z
Type=NCR
;Desired Width variable, to keep all layers uniform
;550 pixels normal width, 600 pixels normal height
Width=600

[MeasureImages]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/
RegExp="(?siU)TWX_(.*)"

[MeasureImage1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/TWX_[MeasureImages]_NCR.gif
RegExp=(?siU)TWX_(.*)
StringIndex=1
Download=1

[MeasureImage2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/TWX_[MeasureImages]_NCR.gif
RegExp=(?siU)TWX_(.*)
StringIndex=2
Download=1

[MeasureImage3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/TWX_[MeasureImages]_NCR.gif
RegExp="(?siU)TWX_="_NCR"
StringIndex=1
Download=1

[Highways]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://radar.weather.gov/ridge/Overlays/Highways/#Range#/#Site#_Highways_#Range#.gif
Download=1
DownloadFile=highways.gif

[Cities]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://radar.weather.gov/ridge/Overlays/Cities/#Range#/#Site#_City_#Range#.gif
Download=1
DownloadFile=cities.gif

[Counties]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://radar.weather.gov/ridge/Overlays/County/#Range#/#Site#_County_Short.gif
Download=1
DownloadFile=counties.gif


;[Meter_TopoDisplay]
;Meter=Image
;ImageName="#CURRENTPATH#DownloadFile\topo.jpg"
;X=0
;Y=0
;W=#Width#
;PreserveAspectRatio=1

[Meter_RadarDisplay]
Meter=Image
MeasureName=RadarImage
ImageName="#CURRENTPATH#DownloadFile\radar.gif"
X=0
Y=0
W=#Width#
PreserveAspectRatio=1

[Meter_CountiesDisplay]
Meter=Image
MeasureName=Counties
ImageName="#CURRENTPATH#DownloadFile\counties.gif"
X=0
Y=0
W=#Width#
PreserveAspectRatio=1

[Meter_HighwaysDisplay]
Meter=Image
ImageName="#CURRENTPATH#DownloadFile\highways.gif"
X=0
Y=0
W=#Width#
PreserveAspectRatio=1

[Meter_CitiesDisplay]
Meter=Image
ImageName="#CURRENTPATH#DownloadFile\cities.gif"
X=0
Y=0
W=#Width#
PreserveAspectRatio=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Reg Exp

Post by balala »

I'm not sure I completely understood what would you need. Why would you want to substitute the TWX with a variable? I think instead, you might want to create the appropriate URLs based on the date. Or I am wrong? Please give me a few details on your needs.
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Re: Help with Reg Exp

Post by jminternelia »

balala wrote:I'm not sure I completely understood what would you need. Why would you want to substitute the TWX with a variable? I think instead, you might want to create the appropriate URLs based on the date. Or I am wrong? Please give me a few details on your needs.
I would want to substitute TWX so that at a settings menu, the user could choose their station. Then the radar would reflect their local weather. That is an issue I can probably get around, but it would take more effort.

As far as create url's on date, sort of. I need to download every file in that directory for the radar overlay. Since the date and time are the only variables that change, I'm assuming there is a way to ignore those via regexp and download every .gif in that directory. Then use some type of calc to arrange them into a loop.
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Re: Help with Reg Exp

Post by jminternelia »

balala wrote:I'm not sure I completely understood what would you need. Why would you want to substitute the TWX with a variable? I think instead, you might want to create the appropriate URLs based on the date. Or I am wrong? Please give me a few details on your needs.
I managed to make a bit of progress...

RegExp=(?siU)N0R.gif">(.*)</a></td> singles out TWX_20180521_1028_N0R.gif

Code: Select all

RSite=https://radar.weather.gov/ridge/RadarImg/N0R/#Site#/

[MeasureImage1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>
StringIndex=1
Download=1
DownloadFile=radar.gif
That managed to download the first file. now i need to get it to download 19 more.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Reg Exp

Post by balala »

Have you checked the RegExp in the skin? Or just in the RainRegExp app? Because it seems that instead of the above RegExp, (right now at least) I'd have to use this: RegExp=(?siU)N[color=#FF0000]C[/color]R.gif">(.*)</a></td>.
On the other hand to download an image, when you have its URL, you have to make a few changes to your code. Below I post only the code of the [MeasureImages] and [MeasureImage1] measures. [MeasureImages] gets the URL of the image and after this, the [MeasureImage1] measure downloads the image. See that initially the [MeasureImage1] measure is disabled (I added a Disabled=1 option to it). When the [MeasureImages] measure gets the URL, its FinishAction option first enables the [MeasureImage1] measure, then immediately updates it, to download the image. Take care that I modified the URL option of the [MeasureImage1] measure (and removed its RegExp option). I added a & character to the name of the used measure (read the last paragraph here).

Code: Select all

[MeasureImages]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/
RegExp=(?siU)NCR.gif">(.*)</a></td>
FinishAction=[!EnableMeasure "MeasureImage1"][!CommandMeasure "MeasureImage1" "Update"]

[MeasureImage1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/[&MeasureImages]
DynamicVariables=1
StringIndex=1
Download=1
Disabled=1
Please test this code and let me know if it does work. The other measures which also should have to download images, I think will have to be modified as well.
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Re: Help with Reg Exp

Post by jminternelia »

balala wrote:Have you checked the RegExp in the skin? Or just in the RainRegExp app? Because it seems that instead of the above RegExp, (right now at least) I'd have to use this: RegExp=(?siU)N[color=#FF0000]C[/color]R.gif">(.*)</a></td>.
On the other hand to download an image, when you have its URL, you have to make a few changes to your code. Below I post only the code of the [MeasureImages] and [MeasureImage1] measures. [MeasureImages] gets the URL of the image and after this, the [MeasureImage1] measure downloads the image. See that initially the [MeasureImage1] measure is disabled (I added a Disabled=1 option to it). When the [MeasureImages] measure gets the URL, its FinishAction option first enables the [MeasureImage1] measure, then immediately updates it, to download the image. Take care that I modified the URL option of the [MeasureImage1] measure (and removed its RegExp option). I added a & character to the name of the used measure (read the last paragraph here).

Code: Select all

[MeasureImages]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/
RegExp=(?siU)NCR.gif">(.*)</a></td>
FinishAction=[!EnableMeasure "MeasureImage1"][!CommandMeasure "MeasureImage1" "Update"]

[MeasureImage1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=https://radar.weather.gov/ridge/RadarImg/NCR/TWX/[&MeasureImages]
DynamicVariables=1
StringIndex=1
Download=1
Disabled=1
Please test this code and let me know if it does work. The other measures which also should have to download images, I think will have to be modified as well.
I do believe I got it working as you were posting this:

Code: Select all

[Rainmeter]
Author=Kyle F.
Update=1000
BackgroundMode=0

[Variables]
;closest radar site name, from http://forecast.weather.gov/jetstream/doppler/ridge_download.htm
Site=ICT
;update rate multiplier (i.e., seconds... formula: Update x Rate)
Rate=60
;Radar range (can be Short or Long)
Range=Short
;product type, from http://forecast.weather.gov/jetstream/doppler/ridge_download.htm
;if using Long range, Type MUST be N0Z
Type=N0R
;Desired Width variable, to keep all layers uniform
;550 pixels normal width, 600 pixels normal height
RSite=https://radar.weather.gov/ridge/RadarImg/#type#/#Site#/

[MeasureImage1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=10
Download=1
DownloadFile=radar0.gif

[MeasureImage2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=11
Download=1
DownloadFile=radar1.gif

[MeasureImage3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=12
Download=12
DownloadFile=radar2.gif

[MeasureImage4]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=13
Download=13
DownloadFile=radar3.gif

[MeasureImage5]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=14
Download=1
DownloadFile=radar4.gif

[MeasureImage6]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=15
Download=1
DownloadFile=radar5.gif

[MeasureImage7]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#rsite#
RegExp=(?siU)N0R.gif">(.*)</a></td>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>.*N0R.gif">(.*)</a>
StringIndex=16
Download=1
DownloadFile=radar6.gif

[Highways]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://radar.weather.gov/ridge/Overlays/Highways/#Range#/#Site#_Highways_#Range#.gif
Download=17
DownloadFile=highways.gif

[Cities]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://radar.weather.gov/ridge/Overlays/Cities/#Range#/#Site#_City_#Range#.gif
Download=1
DownloadFile=cities.gif

[Counties]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://radar.weather.gov/ridge/Overlays/County/#Range#/#Site#_County_Short.gif
Download=1
DownloadFile=counties.gif

;[Meter_RadarDisplay]
;Meter=Image
;MeasureName=RadarImage
;ImageName="#CURRENTPATH#DownloadFile\radar.gif"
;X=0
;Y=0

[ImageNumberCalc]
This formula value is determined by the number of frames for the animation
Measure=Calc
Formula=Counter % 7
Update=80

[ImageMeterRadar]
Meter=Image
ImageName=#CURRENTPATH#DownloadFile\radar[ImageNumberCalc].gif
AntiAlias=1
DynamicVariables=1


[Meter_CountiesDisplay]
Meter=Image
MeasureName=Counties
ImageName="#CURRENTPATH#DownloadFile\counties.gif"
X=0
Y=0

[Meter_HighwaysDisplay]
Meter=Image
ImageName="#CURRENTPATH#DownloadFile\highways.gif"
X=0
Y=0

[Meter_CitiesDisplay]
Meter=Image
ImageName="#CURRENTPATH#DownloadFile\cities.gif"
X=0
Y=0
I'll continue to test. Thanks!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Reg Exp

Post by balala »

jminternelia wrote:I do believe I got it working
Yes, it seems to be working for me, too.
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Re: Help with Reg Exp

Post by jminternelia »

balala wrote:Yes, it seems to be working for me, too.
Thanks for your help!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Reg Exp

Post by balala »

Glad to help, if I did.