It is currently May 1st, 2024, 4:08 pm

Measure won't update

Get help with creating, editing & fixing problems with skins
Rang3r
Posts: 4
Joined: August 13th, 2012, 8:43 am

Measure won't update

Post by Rang3r »

I was create skins which show info from last.fm about music band that i listen in this moment.
It looks like:
Image
Text part won't automatically update (only manual), but art update as need.

Code: Select all

[Rainmeter]
Author=Rang3r
Update=1000

[Variables]
@include=#ROOTCONFIGPATH#/Variables.inc

;--Measures
[MeasureArtist]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerType=ARTIST

[MeasureLastInfoDownload]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://lastfm.ru/
StringIndex=1
RegExpSubstitute=1
UpdateRate=60
FinishAction=[!WriteKeyValue Variables liURL http://www.lastfm.ru/music/[MeasureArtist] #ROOTCONFIGPATH#/Variables.inc][!UpdateMeasure MeasureLastInfo]


[MeasureLastArt]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#lastURL#
RegExp="(?siU)<img height="64" width="64" alt="" src="(.*)" />"
StringIndex=1
UpdateRate=60
Download=1

[MeasureLastInfo]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#liURL#
RegExp="(?siU)<div class="wiki-text">(.*)<span class="hide">"
StringIndex=1
RegExpSubstitute=1
ForceReload=1
UpdateRate=65
Substitute="(\<(/?[^\>]+)\>)":""
DynamicVariables=1


[MeasureLastLifeGroup]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#LiURL#
RegExp="(?siU)<h3 class="remove-top-margin">(.*)</h3>"
StringIndex=1
RegExpSubstitute=1
UpdateRate=60
Substitute="<br />":"","(\<(/?[^\>]+)\>)":""

;--Meters

[MeterInvisBG]
Meter=IMAGE
SolidColor=0,0,0,1
w=172
h=300
x=0
y=0

[MeterNoArt]
Meter=IMAGE
ImageName=NoArt.png
LeftMouseUpAction=!Execute ["#VkPath#"]
w=76
h=76
x=48
y=9

[MeterLastArt]
Meter=IMAGE
MeasureName=MeasureLastArt
LeftMouseUpAction=!Execute ["liURL#"]
w=76
h=76
x=r
y=r

[MeterLastLifeGroup]
Meter=STRING
MeasureName=MeasureLastLifeGroup
FontFace=#UFont#
Fontsize=(#USize#-2)
StringAlign=Left
AntiAlias=1
FontColor=#UColor#
x=9
y=83r
W=154
H=45
ClipString=1
StringStyle="Bold"
LeftMouseUpAction=!Execute ["#LiURL#"]
ToolTipTitle=[MeasureArtist]
ToolTipText=Получить подробную информацию по [MeasureArtist]
Group=Player
DynamicVariables=1

[MeterLastInfo]
Meter=STRING
MeasureName=MeasureLastInfo
FontFace=#UFont#
Fontsize=(#USize#-2)
StringAlign=Left
AntiAlias=1
FontColor=#UColor#
x=9
y=16r
W=154
H=193
ClipString=1
LeftMouseUpAction=!Execute ["#LiURL#"]
ToolTipTitle=[MeasureArtist]
ToolTipText=Получить подробную информацию по [MeasureArtist]
Group=Player
DynamicVariables=1
What's the problem?
And sorry for my English.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Measure won't update

Post by MerlinTheRed »

WebParser doesn't support dynamic variables yet. If you do that !WriteKeyValue, I guess you'll have to refresh the skin, not only update a measure. Also, I guess this is not all of the skin. The MeasureLastArt uses a variable #lastURL# that is not defined or used anywhere else in the ini file. If you want to know why only the art is working, I guess we need to know where that variable comes from.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
Rang3r
Posts: 4
Joined: August 13th, 2012, 8:43 am

Re: Measure won't update

Post by Rang3r »

MerlinTheRed wrote:WebParser doesn't support dynamic variables yet. If you do that !WriteKeyValue, I guess you'll have to refresh the skin, not only update a measure. Also, I guess this is not all of the skin. The MeasureLastArt uses a variable #lastURL# that is not defined or used anywhere else in the ini file. If you want to know why only the art is working, I guess we need to know where that variable comes from.
#LastURL# is for art, all variables in #ROOTCONFIGPATH#/Variables.inc, #liURL# too
#liURL# look like: "liURL=http://www.lastfm.ru/music/Papa Roach"
lastURL="http://www.lastfm.ru/user/Rang3r"
How can skin refresh skin every 60 seconds for example, than MeasureLastInfo and MeasureLastLifeGroup will update too?
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Measure won't update

Post by MerlinTheRed »

What you are trying to do is not an easy task, especially because WebParser doesn't support DynamicVariables yet. I know that some people here have managed to get around it, but I've not yet written any skin that does this, so I'll have to pass this to them.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
Rang3r
Posts: 4
Joined: August 13th, 2012, 8:43 am

Re: Measure won't update

Post by Rang3r »

MerlinTheRed wrote:What you are trying to do is not an easy task, especially because WebParser doesn't support DynamicVariables yet. I know that some people here have managed to get around it, but I've not yet written any skin that does this, so I'll have to pass this to them.
Oh, i get it.
Anyway thanks for help. :thumbup:
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Measure won't update

Post by Kaelri »

You could use a simple Lua script to detect when the Artist changes, then refresh the skin:

Code: Select all

function Initialize()
	MeasureArtist = SKIN:GetMeasure('MeasureArtist')
	LastArtist    = SKIN:GetVariable('LastArtist')
end

function Update()
	CurrentArtist = MeasureArtist:GetStringValue()
	if CurrentArtist ~= LastArtist then
		SKIN:Bang('!WriteKeyValue', 'Variables', 'LastArtist', CurrentArtist)
		SKIN:Bang('!Refresh')
	end
end
Then use the #LastArtist# variable in the URL for [MeasureLastInfo].

Code: Select all

Url=http://www.lastfm.ru/music/#LastArtist#
Rang3r
Posts: 4
Joined: August 13th, 2012, 8:43 am

Re: Measure won't update

Post by Rang3r »

Kaelri wrote:You could use a simple Lua script to detect when the Artist changes, then refresh the skin:

Code: Select all

function Initialize()
	MeasureArtist = SKIN:GetMeasure('MeasureArtist')
	LastArtist    = SKIN:GetVariable('LastArtist')
end

function Update()
	CurrentArtist = MeasureArtist:GetStringValue()
	if CurrentArtist ~= LastArtist then
		SKIN:Bang('!WriteKeyValue', 'Variables', 'LastArtist', CurrentArtist)
		SKIN:Bang('!Refresh')
	end
end
Then use the #LastArtist# variable in the URL for [MeasureLastInfo].

Code: Select all

Url=http://www.lastfm.ru/music/#LastArtist#
It's works! Thank you!