It is currently September 29th, 2024, 7:22 am

WebParser, Images, and Download

General topics related to Rainmeter.
Bobburt444
Posts: 13
Joined: November 11th, 2011, 12:05 am

WebParser, Images, and Download

Post by Bobburt444 »

I'll try my best to explain. My latest skin involves downloading images with WebParser and then displaying the downloaded images, not the ones from the URL/WebParser. By doing this, the update rate of the skin would hopefully be -1.

Is there a way to have WebParser run only once to download the images, and then never run again? I don't want to download the same image over and over, I only need it to download once.

It's kind of hard to explain I think. Ideally, I have this launcher basically set to Update=-1, perhaps on a mouse click, the skin updates once and parses for any new games in the library, downloads only new images that haven't been downloaded yet into a permanent folder, and then the pre-made meters fill in with the new images.

The reason I don't want to rely on the WebParser-generated images is the delay when coming out of "hide" or being "activated." With using the downloaded images, there would be no delay. That and I'd rather not re-download the same images every time I unhide or activate the skin.
User avatar
balala
Rainmeter Sage
Posts: 16602
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser, Images, and Download

Post by balala »

Bobburt444 wrote:I'll try my best to explain. My latest skin involves downloading images with WebParser and then displaying the downloaded images, not the ones from the URL/WebParser. By doing this, the update rate of the skin would hopefully be -1.

Is there a way to have WebParser run only once to download the images, and then never run again? I don't want to download the same image over and over, I only need it to download once.
"Update rate of the skin", means its Update value in the [Rainmeter] section? Generally t's not a good idea to set it to 0, if the skin has WebParser measures. And that's because a skin with this update value is never updated, but reading the appropriate string and showing them is a more steps process.
On the other hand if you have a default Update=1000, you have more possibilities to determine the parent WebParser measure to run just once, with any of the following options:
  • UpdateRate=-1
  • FinishAction=[!DisableMeasure "#CURRENTSECTION#"]
Bobburt444 wrote:It's kind of hard to explain I think. Ideally, I have this launcher basically set to Update=-1, perhaps on a mouse click, the skin updates once and parses for any new games in the library, downloads only new images that haven't been downloaded yet into a permanent folder, and then the pre-made meters fill in with the new images.
There is a method to achieve these, even with Update=-1. On the mouse click you'll have to add something like: LeftMouseUpAction=[!CommandMeasure "ParentWebParserMeasure" "Update"][!UpdateMeasure "ChildWebParserMeasure1"]"][!UpdateMeasure "ChildWebParserMeasure1"]"][!UpdateMeasure "ChildWebParserMeasure2"](and all child WebParser measures)[!UpdateMeter "MeterShowingTheResults"][!Redraw].
But that's not a desirable method. I recommend to use the default Update=1000. It'll save you from a lot of troubles.
Bobburt444 wrote:The reason I don't want to rely on the WebParser-generated images is the delay when coming out of "hide" or being "activated." With using the downloaded images, there would be no delay. That and I'd rather not re-download the same images every time I unhide or activate the skin.
Using a delay is possible. You'll need some measures to do it.

For more help, please post a code. Without it, I can talk just about some generalities.
Bobburt444
Posts: 13
Joined: November 11th, 2011, 12:05 am

Re: WebParser, Images, and Download

Post by Bobburt444 »

Thanks for the reply.

I basically rewrote my entire skin from scratch. I've achieved what I had a hard time explaining.

So what I've done is this-

The skin itself doesn't really do anything except display up to (for testing purposes) 30 images that are Steam game thumbnails.

I've set the entire skin's "Update" (Rainmeter section) to 1000, but I did also get it to work with -1, but 1000 gives me more options for...flashy unnecessary stuff? Haha.

All my WebParser measures are set to UpdateRate=-1 and Disabled=1. I've got 30 of each kind of measure: Steam game "Titles", "ID" (so you can actually launch the game) and "Picture" (thumbnail).

Each child WebParser measure has a FinishAction that writes a key value ("[itself]") to my variables.inc file. This is where I store all the Titles, IDs, and Picture URLs. I realized late into the game that I don't need to store the picture URLs here but it doesn't really matter.

When the skin loads, it loads the images from a permanent DownloadFile folder and not from any WebParser measures. It reads the Titles and IDs from variables.inc.

I've added a button that when clicked enables and updates all the WebParser measures via group (meaning they rewrite themselves in the .inc) and redownloads the game thumbnails in proper order in case there might be a newly added game to the library. When they're done doing their jobs, the Source parent measure has a FinishAction that disables all the same measures.

And because of the skin's Update of 1000, it's allowed me to add a couple status messages of parsing, parsing complete, and refreshing skin.
User avatar
balala
Rainmeter Sage
Posts: 16602
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser, Images, and Download

Post by balala »

Bobburt444 wrote:Each child WebParser measure has a FinishAction that writes a key value ("[itself]") to my variables.inc file.
I doubt those FinishActions are working. FinishAction must be used on the parent WebParser measure, not on child ones.
Do you have any other question?
User avatar
jsmorley
Developer
Posts: 22783
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser, Images, and Download

Post by jsmorley »

balala wrote:I doubt those FinishActions are working. FinishAction must be used on the parent WebParser measure, not on child ones.
Do you have any other question?
Don't know if it applies in this case, but when a child measure has Download=1 on it, the download part of the functionality makes that measure appear to be a "parent" to the FinishAction function, and it will be executed.

https://docs.rainmeter.net/manual-beta/plugins/webparser/#OnDownloadErrorAction

The Download=1 function turns a child measure into a hybrid parent / child in a sense. It is a child that will receive a URL to a remote image from its parent, and a parent in that it connects to the remote resource and does the download action itself, and does not depend on its parent to do that for it.
Bobburt444
Posts: 13
Joined: November 11th, 2011, 12:05 am

Re: WebParser, Images, and Download

Post by Bobburt444 »

I didn't realize that FinishAction only works on the parent measure. Now I know why a few FinishActions weren't working in another skin I've been messing around with.

These FinishActions are working just fine on these child measures.
User avatar
balala
Rainmeter Sage
Posts: 16602
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser, Images, and Download

Post by balala »

Bobburt444 wrote:These FinishActions are working just fine on these child measures.
jsmorley's previous reply explains why.