It is currently April 27th, 2024, 1:25 am

ImageMeter managed by Lua script

Get help with creating, editing & fixing problems with skins
neuroverflow
Posts: 7
Joined: August 2nd, 2011, 9:27 am

ImageMeter managed by Lua script

Post by neuroverflow »

Hello everyone !
I hope you are feeling great for the end if that year :)

I'm trying to have an Image Meter that show an image with the url coming from a LUA script (I simplify).
My String meter display the proper url but webparser don't download the image.
I also tried by adding OnUpdateAction=[!UpdateMeasure "MeasureImage"] in [MeasureLua] but without success :oops:

Lua.lua

Code: Select all

PROPERTIES={}
function Initialize()	
end
function Update()
	return "https://www.pocketables.com/images/2018/12/hub2-800x445.jpg";
end

skin.ini :

Code: Select all

[MeasureLua]
Measure=Script
ScriptFile=Lua.lua

[meterTitle]
Meter=STRING
Y=80
w=1500
MeasureName=MeasureLua
FontColor=FFFFFF99
Text="%1"
FontSize=15

[MeasureImage]
Measure=Plugin
Plugin=WebParser
URL=[MeasureLua]
Download=1
DownloadFile=image.png

[MeterImage]
Meter=Image
MeasureName=MeasureImage
X=5
Y=250
W=200
H=200
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ImageMeter managed by Lua script

Post by jsmorley »

Try this:

Code: Select all

[MeasureImage]
Measure=Plugin
Plugin=WebParser
URL=[&MeasureLua]
DynamicVariables=1
Download=1
DownloadFile=image.png
https://docs.rainmeter.net/manual/measures/webparser/#Dynamic
SparkShredder
Posts: 50
Joined: November 17th, 2017, 12:00 pm

Re: ImageMeter managed by Lua script

Post by SparkShredder »

Instead of measurename,
You can try Imagename=#CurrentPath#image.png
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ImageMeter managed by Lua script

Post by balala »

SparkShredder wrote: December 31st, 2018, 12:54 pm Instead of measurename,
You can try Imagename=#CurrentPath#image.png
Doesn't help too much. MeasureName is a much better option if the image is downloaded by a WebParser measure, like in this case. First, the posted ImageName option is wrong, correctly it would be Imagename=#CurrentPath#DownloadFile\image.png, because the downloaded images are always stored into the DownloadFile folder, created in the root config.
Secondly your solution even if used correctly, requires a DynamicVariables=1 option to be added to the Image meter. Without this option the meter doesn't show the image when it's not downloaded previously and doesn't show the new image if it changes in the meanwhile.
So, basically MeasureName is better to be used then ImageName.
neuroverflow
Posts: 7
Joined: August 2nd, 2011, 9:27 am

Re: ImageMeter managed by Lua script

Post by neuroverflow »

:? ok ... hum ... :thumbup: you rock!

But let me add some complexity to the situation :Whistle
I download the defautl image but when the webparser CoverMeasure value change and my Lua script change properly my url the ImageMeter isn't updated and still display the original image (the first value returned by my Lua script).

FYI I'm try to recover the thumbnail of the current playing of KODI (movie).

Code: Select all

function Initialize()
	Measures={SKIN:GetMeasure('CoverMeasure');}
end

function Update()
	Var=Measures[1]:GetStringValue();
	Var = Var:gsub("%%2f", "%%252f");
	Var = Var:gsub("%%3a", "%%253a");
	Var = Var:gsub(".jpg/", ".jpg%%2F");
	Var = Var:gsub("image://", "http://localhost:8080/image/image%%3A%%2F%%2F");
	
	if ( Var == nil or Var == '') then
	  Var = "https://www.lua.org/pil/capa.jpg"
	end
	
	return	Var;
end

Code: Select all

	[PropertiesPlayer]
Measure=Plugin
Plugin=WebParser
UpdateRate=1
URL=http://localhost:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetItem","params":{"properties":%5B"title","album","artist","season","episode","duration","showtitle","tvshowid","thumbnail","file","fanart","streamdetails"%5D,"playerid":1},"id":"VideoGetItem"}
RegExp=(?siU)"label":"(.*)",.*"thumbnail":"(.*)",
DynamicVariables=1
Debug=1
StringIndex=2
FinishAction=[!CommandMeasure Parents1 Update]

[meterTitle]
Meter=STRING
Y=80
w=1500
MeasureName=MeasureLua
FontColor=FFFFFF99
Text="%1"
FontSize=15

[CoverMeasure]
Measure=WebParser
URL=[PropertiesPlayer]
DynamicVariables=1
StringIndex=2
Group=Parents1

[MeasureLua]
Measure=Script
ScriptFile=Lua.lua
DynamicVariables=1

[MeasureImage2]
Measure=Plugin
Plugin=WebParser
URL=[&MeasureLua]
DynamicVariables=1
Download=1
DownloadFile=image.png

[MeterImage]
Meter=Image
MeasureName=MeasureImage2
X=5
Y=250
W=200
H=200
DynamicVariables=1


SparkShredder
Posts: 50
Joined: November 17th, 2017, 12:00 pm

Re: ImageMeter managed by Lua script

Post by SparkShredder »

From where Image is actually loaded from? the Name of Website?
What exactly PropertiesPlayer is?

Edit: Okay , the KUDO movie's thumbnail, well, that's a quite very complex work.
Well, I see you used StringIndex=2 on the parent webparser, it should work, but for best and bugless results. Try using a new chlid with StringIndex=2
neuroverflow
Posts: 7
Joined: August 2nd, 2011, 9:27 am

Re: ImageMeter managed by Lua script

Post by neuroverflow »

Actually I'm using a child meter.
CoverMeasure is the child and the Lua script retrieve properly the value (so coming from Kodi website). Then the Lua script re-encode the url to be accissible from 'outside'...
All parts work fine individually, I mean after Lua execution the url is correct and updated in case of changes. Only the ImageMeter always display the old image (the default one in the script, when the url is empty, aka not parsed yet).
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ImageMeter managed by Lua script

Post by balala »

neuroverflow wrote: December 31st, 2018, 1:22 pm But let me add some complexity to the situation
The posted URL doesn't work for me. Please check it. Without it, I can't verify what's going on.

EDIT: It's a local resource? Maybe that's why I can't access it. Am I right?
neuroverflow
Posts: 7
Joined: August 2nd, 2011, 9:27 am

Re: ImageMeter managed by Lua script

Post by neuroverflow »

Indeed, it's a local ressource. Kodi application host a web-server with a restful API.
Like I said it's a refresh issue; I guess I can create a lua script that generate random valid url to simplify my config and help the troubleshooting :???:
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ImageMeter managed by Lua script

Post by balala »

neuroverflow wrote: December 31st, 2018, 3:07 pm Indeed, it's a local ressource. Kodi application host a web-server with a restful API.
Like I said it's a refresh issue; I guess I can create a lua script that generate random valid url to simplify my config and help the troubleshooting :???:
Ok, please post the content of the resource, as you have it.