It is currently April 22nd, 2019, 11:06 am

WebParser OnDownloadErrorAction

Help with creating, editing & fixing problems with skins
simsrw73

WebParser OnDownloadErrorAction

simsrw73 » February 5th, 2019, 1:27 pm

First skin. Still trying to wrap my head around a lot. My biggest issue atm is error handling. Well, it's not so much the OnDownloadErrorAction as it is the bang and flow. If I set my computer clock a few months ahead (July) with the code below, I get a failure in MeasureVotDImage and OnDownloadErrorAction fires. It correctly sets the Background to a different color (just there for testing), but it does not load in the saved image in MeterVotDImage. The saved image (VotD.jpg) is there from previous successful run. I'm hoping to fall back on the last good download image when offline or otherwise can't download the next image. What am I doing wrong and is this the correct approach? I looked at WebParserTester code which seems to do almost exactly the same thing but... works. TIA.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
Debug=1

[Metadata]
Name=Faithlife Verse of the Day
Author=Randy W. Sims
Information=
Version=0.1.8
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
Width=320
Height=(#Width# / 16) * 9

[Background]
Meter=Image
BackgroundMode=2
SolidColor=5fbc39
W=#Width#
H=#Height#

[MeasureDate]
Measure=Time
Format=%Y-%m-%d

[MeasureImageURL]
Measure=String
String=https://biblia.com/verseoftheday/image/[MeasureDate]?width=#Width#
DynamicVariables=1

[MeasureBibleURL]
Measure=String
String=http://bible.faithlife.com/verseoftheday/lightbox/[MeasureDate]
DynamicVariables=1

[MeasureVotDImage]
Measure=WebParser
;;;;;;;;;;;;;;;;;;;;;;;;;;Why do I need &
URL=[&MeasureImageURL]
Download=1
DownloadFile=VotD.jpg
DynamicVariables=1
UpdateRate=30
FinishAction=[!ShowMeter MeterVotDShadow]
OnConnectErrorAction=[!SetOption MeterVotDImage ImageName VotD.jpg][!SetOption Background SolidColor ffff00][!UpdateMeter *][!Redraw]
OnDownloadErrorAction=[!SetOption MeterVotDImage ImageName VotD.jpg][!SetOption Background SolidColor ff0000][!UpdateMeter *][!Redraw]

[MeterVotDShadow]
Meter=Image
SolidColor=00000033
X=4
Y=4
W=#Width#
H=#Height#
Hidden=1

[MeterVotDImage]
Meter=Image
MeasureName=MeasureVotDImage
ImageName=VotD.jpg
PreserveAspectRatio=1
LeftMouseUpAction=[MeasureBibleURL]
DynamicVariables=1

User avatar
ikarus1969
Posts: 322
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: WebParser OnDownloadErrorAction

ikarus1969 » February 6th, 2019, 10:14 am

If there's a quote for the date in MeasureDate, then the measure MeasureVotDImage has the complete path to the picture (=file VotD.jpg in the sub-directory "DownloadFile" in your skins directory)
SS #1 Date OK CompletePath.jpg
BUT: if you have a date for which no quote-picture exists, the measure MeasureVotDImage has an complete empty result. The meter MeterVotDImage then tries to access the empty path, which obviously doesn't exist.
SS #2 Date KO Empty.jpg
You can do the following: change the Image-meter MeterVotDImage so no MeasureName is used (which probably can result in an empty path) and specify the ImagePath (set it to "DownloadFile"). Then, if there's a date for which no quote exists, the previously downloaded picture will be used.

Code: Select all

[MeterVotDImage]
Meter=Image
; MeasureName=MeasureVotDImage
ImagePath=DownloadFile
ImageName=VotD.jpg
PreserveAspectRatio=1
LeftMouseUpAction=[MeasureBibleURL]
DynamicVariables=1
...and: you don't have to use

Code: Select all

[!SetOption MeterVotDImage ImageName VotD.jpg]
on your webparser-measure actions if you have it set explicitly in the meter itself.
You do not have the required permissions to view the files attached to this post.
simsrw73

Re: WebParser OnDownloadErrorAction

simsrw73 » February 6th, 2019, 3:30 pm

Thank you, Ikarus. I see where I went wrong. That bang that you mentioned wasn't need was to set the image was in there because I was trying different variants to load the image. I completely missed that ImageName was being ignored because it was bound to a measure by specifying MeasureName. And I read I remember reading that in the docs, now. Just didn't sink in. Thank you.