Actually if you look into PowershellRM(can be used for scripting) or Lua Scripting you can do it without having to use 30 measures.SlowCircuit wrote: ↑April 18th, 2021, 9:47 pm That definitely worked, thanks! It's a shame I have to use a workaround like this though, because there are 30 images I need to do this with, so I need 30 more measures for getting the URL, 30 variables to store the URLs, etc.
It is currently April 24th, 2024, 5:58 am
How to substitute part of url for image webparser download
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: How to substitute part of url for image webparser download
from the Realm of Death
-
- Rainmeter Sage
- Posts: 16164
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to substitute part of url for image webparser download
Don't contest it can be done, however an example always would be nice. Post it please.death.crafter wrote: ↑May 13th, 2021, 1:22 pm Actually if you look into PowershellRM(can be used for scripting) or Lua Scripting you can do it without having to use 30 measures.
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: How to substitute part of url for image webparser download
Skin file:
Code: Select all
[Variables]
RSSLink0=
RSSLink1=
RSSLink2=
...
[MeasureScript]
Measure=Script
ScriptFile=ImageParser.lua
ImageCount=30
UpdateDivider=-1
[Feed]
Measure=WebParser
Url=[#RSSLink[#CurrentNum]]
RegExp="(?siU)#RegexPattern#
[ItemImage]
Measure=WebParser
Url=[Feed]
StringIndex=3
DynamicVariables=1
DecodeCharacterReference=1
Substitute=#Substitutes#
[MeasureDownloadImage]
Measure=WebParser
Url=[ItemImage]
Download=1
DownloadFile=[#CurrentNum].png
UpdateRate=600
DynamicVariables=1
Disabled=1
[Item0Thumbnail]
Meter=Image
ImageName=0.png
Code: Select all
function Initialize()
local imageCount=SELF:GetOption("ImageCount")
for i=0, imageCount-1, 1 do
SKIN:Bang('!SetVariable', 'CurrentNum', i)
SKIN:Bang('!UpdateMeasure', 'Feed')
SKIN:Bang('!CommandMeasure', 'ItemImage', 'Update')
SKIN:Bang('!EnableMeasure', 'MeasureDownloadImage')
SKIN:Bang('!CommandMeasure', 'MeasureDownloadImage', 'Update')
SKIN:Bang('!UpdateMeter', 'Item'..i..'Thumbnail')
SKIN:Bang('!Redraw')
end
end
from the Realm of Death
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: How to substitute part of url for image webparser download
Since lua is fast and download may not commence at this rate, there is a probability this lua may not work. And honestly I don't know how to add delay to a chain of action in lua. So I am attaching a PSRM script too...
Measure:
Code: Select all
[PSRM]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=GetImages.ps1
UpdateDivider=-1
Code: Select all
function GetImages {
$imageCount=30
for ($i=0; $i -lt $imageCount; $i++) {
$RmAPI.Bang("!SetVariable CurrentNum $i")
$RmAPI.Bang("!UpdateMeasure Feed")
Start-Sleep -Milliseconds 50
$RmAPI.Bang("!UpdateMeasure ItemImage")
$RmAPI.Bang("!UpdateMeasure MeasureDownloadImage")
$Start-Sleep -Milliseconds 100
$RmAPI.Bang("[!UpdateMeter Item$("$i"+'Thumbnail')][!Redraw]")
Start-Sleep -Milliseconds 100
}
}
And since we have to execute this script, we can add an action somewhere,
for example:
Code: Select all
OnRefreshAction=!Command Measure PSRM "GetImages"
from the Realm of Death
-
- Rainmeter Sage
- Posts: 7151
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to substitute part of url for image webparser download
You can do it in native Rainmeter as well - just reuse the WebParser measure sequentially, once it finishes getting the current Web resource.death.crafter wrote: ↑May 13th, 2021, 1:22 pm Actually if you look into PowershellRM(can be used for scripting) or Lua Scripting you can do it without having to use 30 measures.