It is currently April 25th, 2024, 3:10 pm

OnchangeAction Webparser issue

Get help with creating, editing & fixing problems with skins
User avatar
Kaz28100
Posts: 67
Joined: May 3rd, 2012, 3:59 pm
Location: France

OnchangeAction Webparser issue

Post by Kaz28100 »

Hi, i'm using last.fm api to get cover art from Spotify so i get a fully working spotify skin (the only thing thats missing it's the track duration), but i have a issue with OnChangeAction it's seems that if i swich tracks too fast the Webparser fail and get stuck downloading nothing all, even after a refresh of the skin or a refresh of rainmeter, The only workarround i found is to close and restart rainmeter.

Is there something i can do to fix this?

So this is the part of the code, when the track change it send the request to download the cover art from last.fm. But when i change tracks too fast things get stuck.

Code: Select all

[mTrack]
Measure=NowPlaying
PlayerName=Spotify
PlayerType=TITLE
OnChangeAction=[!EnableMeasure mCover][!CommandMeasure mCover "UpDate"]

[mCover]
Measure=WebParser
UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Url=https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=username&api_key=MYAPIKEY&nowplaying=true&limit=1
RegExp=(?siU)<image size="extralarge">(.*)</image>
StringIndex=1
FinishAction=[!DisableMeasure #CURRENTSECTION#][!Redraw][!Update]
DynamicVariables=1
Flags=ForceReload
Download=1
DownloadFile=CoverSpotify.png
Disabled=1
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OnchangeAction Webparser issue

Post by balala »

Kaz28100 wrote: April 6th, 2022, 1:57 pm Hi, i'm using last.fm api to get cover art from Spotify so i get a fully working spotify skin (the only thing thats missing it's the track duration), but i have a issue with OnChangeAction it's seems that if i swich tracks too fast the Webparser fail and get stuck downloading nothing all, even after a refresh of the skin or a refresh of rainmeter, The only workarround i found is to close and restart rainmeter.

Is there something i can do to fix this?
There is a known issue of WebParser measures: when you refresh a skin using WebParser measure repeatedly it may hang and stop working. When this happens, the only way to fix it is a complete restart of Rainmeter. Neither a refresh of the skin, nor a refresh all doesn't help such in case.
If you only update too frequently the WebParser measure, but don't refresh the skin, still can lead to hang the measure. Usually it's not a good idea to repeatedly update the measure, what the skin does when you quickly switch tracks. Unfortunately such in a case there is no solution other then restarting Rainmeter.
User avatar
Kaz28100
Posts: 67
Joined: May 3rd, 2012, 3:59 pm
Location: France

Re: OnchangeAction Webparser issue

Post by Kaz28100 »

balala wrote: April 7th, 2022, 7:59 pm There is a known issue of WebParser measures: when you refresh a skin using WebParser measure repeatedly it may hang and stop working. When this happens, the only way to fix it is a complete restart of Rainmeter. Neither a refresh of the skin, nor a refresh all doesn't help such in case.
If you only update too frequently the WebParser measure, but don't refresh the skin, still can lead to hang the measure. Usually it's not a good idea to repeatedly update the measure, what the skin does when you quickly switch tracks. Unfortunately such in a case there is no solution other then restarting Rainmeter.
Thanks for the info that's what i was afraid to heard, so i guess i'm locked in this situation, if there a way to tell rainmeter to execute the webparser only 10 seconds after the track start so this avoid this issue when i switch track fast.
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OnchangeAction Webparser issue

Post by balala »

Kaz28100 wrote: April 8th, 2022, 7:45 pm if there a way to tell rainmeter to execute the webparser only 10 seconds after the track start so this avoid this issue when i switch track fast.
Try to add a !Delay bang to the OnChangeAction option of the [mTrack] measure, something like this: OnChangeAction=[!EnableMeasure mCover][!Delay "10000"][!CommandMeasure mCover "UpDate"]. The red colored 10000 above is the delay time in milliseconds, so 10000 means 10 seconds. Unfortunately I'm not sure at all this helps, because once the track changed, after 10 seconds the !CommandMeasure bang (which follows the !Delay bang) is executed and there is no way to prevent this.
A better solution is to use an ActionTimer plugin measure which should be started when you change the track and if you change it again before the set waiting period, the measure should be restarted. Could work I assume. If the above !Delay bang solution does work, please let me know. If it doesn't and you don't know how to implement the ActionTimer plugin measure solution, please let me know this as well, for further assistance.
User avatar
Kaz28100
Posts: 67
Joined: May 3rd, 2012, 3:59 pm
Location: France

Re: OnchangeAction Webparser issue

Post by Kaz28100 »

balala wrote: April 8th, 2022, 8:15 pm Try to add a !Delay bang to the OnChangeAction option of the [mTrack] measure, something like this: OnChangeAction=[!EnableMeasure mCover][!Delay "10000"][!CommandMeasure mCover "UpDate"]. The red colored 10000 above is the delay time in milliseconds, so 10000 means 10 seconds. Unfortunately I'm not sure at all this helps, because once the track changed, after 10 seconds the !CommandMeasure bang (which follows the !Delay bang) is executed and there is no way to prevent this.
A better solution is to use an ActionTimer plugin measure which should be started when you change the track and if you change it again before the set waiting period, the measure should be restarted. Could work I assume. If the above !Delay bang solution does work, please let me know. If it doesn't and you don't know how to implement the ActionTimer plugin measure solution, please let me know this as well, for further assistance.
Just tried with !Delay command and like you said the bang is still being executed for each track change so Webparser get stuck again. But the action timer seems like a better Workaround so it will execute the bang only if the song is played for at least 10seconds.
User avatar
Kaz28100
Posts: 67
Joined: May 3rd, 2012, 3:59 pm
Location: France

Re: OnchangeAction Webparser issue

Post by Kaz28100 »

Hi i tried to figure out by myself how to use ActionTimer for this but i can't get this to works, can you give me some example on how to implement this?
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OnchangeAction Webparser issue

Post by balala »

Kaz28100 wrote: April 12th, 2022, 9:05 pm can you give me some example on how to implement this?
Sorry, in meantime I completely forgot this. My bad, apologies...
But here is a solution. Thinking a little bit deeper in meantime, I think I realized that we don't even need an ActionTimer plugin measure. A simple Calc measure would be even better, because it is much easier in this case to restart it. So, here is my solution. Please test it and let me know if does work:

Code: Select all

[mTrack]
Measure=NowPlaying
PlayerName=Spotify
PlayerType=TITLE
OnChangeAction=[!DisableMeasure "MeasureDelay"][!UpdateMeasure "MeasureDelay"][!EnableMeasure "MeasureDelay"]

[MeasureDelay]
Measure=Calc
Formula=( MeasureDelay + 1 )
IfCondition=(#CURRENTSECTION#=10)
IfTrueAction=[!DisableMeasure "MeasureDelay"][!EnableMeasure "mCover"][!CommandMeasure "mCover" "Update"]
Disabled=1

[mCover]
Measure=WebParser
...
See the newly added [MeasureDelay] measure and the updated OnChangeAction option of the [mTrack] measure. Also see that the value 10 used in the IfCondition measure of the [MeasureDelay] measure is the delay after which you get the WebParser measure updated (at least assuming the Update value in the [Rainmeter] section is the default Update=1000). You can change it freely if needed.
Sorry again for the delay...
User avatar
Kaz28100
Posts: 67
Joined: May 3rd, 2012, 3:59 pm
Location: France

Re: OnchangeAction Webparser issue

Post by Kaz28100 »

No need to be sorry, this can happen to everyone and we all have others things to do ;)
I tried your solution and good news everything works as intended :bow:
Thank you so much for your help ;-)
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OnchangeAction Webparser issue

Post by balala »

Kaz28100 wrote: April 13th, 2022, 8:39 pm No need to be sorry, this can happen to everyone and we all have others things to do ;)
I tried your solution and good news everything works as intended :bow:
Thank you so much for your help ;-)
You're welcome. :thumbup: