It is currently May 19th, 2019, 7:42 am

New OnDownloadErrorAction for WebParser

Changes made during the Rainmeter 3.2 beta cycle.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New OnDownloadErrorAction for WebParser

jsmorley » March 15th, 2015, 2:17 pm

We have added a new OnDownloadErrorAction option to WebParser measures, to detect and take action when a measure with Download=1 fails to download or save the target file.

Note that there are several different ways that Download=1 can be used with WebParser parent and / or child measures:

=======
[MeasureDirectDownload]
Measure=Plugin
Plugin=WebParser
URL=http://SomeSite.com/img/SomeImage.png
Download=1
FinishAction=[!Log "Download succeeded!"]
OnDownloadErrorAction=[!Log "Download error"]

If the site can't be reached or the file doesn't exist or it can't be downloaded or saved, OnDownloadErrorAction alone will be fired. If the download succeeds, FinishAction will be fired.

=======
[MeasureRegExpDownload]
Measure=Plugin
Plugin=WebParser
URL=http://SomeSite.com
RegExp=(?siU)src="(.*)"
StringIndex=1
Download=1
FinishAction=[!Log "Download succeeded!"]
OnConnectErrorAction=[!Log "Connect error"]
OnRegExpErrorAction=[!Log "RegExp error"]
OnDownloadErrorAction=[!Log "Download error"]

If the site can't be reached, OnConnectErrorAction alone will be fired. If the RegExp fails, OnRegExpErrorAction alone will be fired. If all else succeeds, but the download fails, OnDownloadErrorAction alone will be fired. If all succeed, FinishAction will be fired.

=======
[MeasureChildDownload]
Measure=Plugin
Plugin=WebParser
URL=[MeasureRegExpDownload]
StringIndex=1
Download=1
DownloadFile=SomeImage.png
FinishAction=[!Log "Download succeeded!"]
OnDownloadErrorAction=[!Log "Download error"]

If the parent measure succeeds in connecting and parsing the site then the Download=1 function is executed, and if that fails OnDownloadErrorAction alone on this child measure will be fired. If the download succeeds, FinishAction will be fired.