It is currently April 28th, 2024, 1:54 pm

If text is x then

Get help with creating, editing & fixing problems with skins
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

If text is x then

Post by Nachtschade »

Hiya,

I'm trying to add last played data from MediaMonkey to my Now Playing skin.

I have managed to get the data using a script in MM that writes the data into a txt file after song change and I have Rainmeter using Luascript to read that data and display it. Works great.

However when a song has not been played before MM scripts writes 00:00:00 into the txt file. How can rewrite my script in such a way that when it reads "00:00:00" in writes "Last Played Never" instead of "Last Played On %1"?

It's probably easy but I'm not that smart.

Thnx
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: If text is x then

Post by Yincognito »

Nachtschade wrote: December 4th, 2023, 12:18 am Hiya,

I'm trying to add last played data from MediaMonkey to my Now Playing skin.

I have managed to get the data using a script in MM that writes the data into a txt file after song change and I have Rainmeter using Luascript to read that data and display it. Works great.

However when a song has not been played before MM scripts writes 00:00:00 into the txt file. How can rewrite my script in such a way that when it reads "00:00:00" in writes "Last Played Never" instead of "Last Played On %1"?

It's probably easy but I'm not that smart.

Thnx
Not sure if MediaMonkey works with NowPlaying, there are some plugins for their interaction though probably not for the most recent versions of MM. If it doesn't, maybe you have better luck trying the WebNowPlaying plugin and see what you get.

As for the answer to your question, I assume that the code you have in the skin's .ini file is something like this:

Code: Select all

...

[MeasureProvidingData]
Measure=...
...

...

[MeterDisplayingData]
Meter=...
...
MeasureName=MeasureProvidingData
Text=Last Played On %1
...

...
If so, then you should change it to something like:

Code: Select all

...

[MeasureProvidingData]
Measure=...
...
RegExpSubstitute=1
Substitute="^(.*)$":"On \1","^On (?:00:00:00|\\1)$":"Never"

...

[MeterDisplayingData]
Meter=...
...
MeasureName=MeasureProvidingData
Text=Last Played %1
...

...
If by any chance the [MeasureProvidingData] equivalent in your code already has the RegExpSubstitute and Substitute lines, you can simply add the contents of the above one to what you already have, separating the existing contents and the addition using a , (comma), like this:

Code: Select all

RegExpSubstitute=1
Substitute=...your existing substitutions...,"^(.*)$":"On \1","^On (?:00:00:00|\\1)$":"Never"
That's one way of doing things, other ways might involve IfConditions or IfMatches, depending on the circumstances in your code and the type of output (number or string) from the relevant measure(s).

If you do the above correctly, it should yield the expected result. If it doesn't - and for the next time you ask something else on the forum - please provide the code you're having issues with (along with all its dependencies, like image resources, fonts, whatever is in the @include= lines, and so on) or just pack your skin and upload it here. It's only rarely that a coding issue can be solved without having access to the code in the first place - it's like asking someone to fix your computer without that someone being able to see the computer and figure out what's wrong with it. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

Re: If text is x then

Post by Nachtschade »

Excellent. Thank you so much.

This works fine. I've edited it a little more to make it say either "Last Played On 10-12-2019 00:14:11" or "Never Played Before", which is even more clean.

As for your question about MM working with NowPlaying. It does. At least MM4 does. I don't use 5 since all the great MM custom scripts for 4 don't work with 5 and many have not yet been ported and I rely on a few.

I've had a small Now Playing thingy going on in the corner of my second screen for years but I've gifted myself a dedicated Now Playing screen last week so now I'm trying to make my script better and more beautiful. ;-)

Image

Work in progress: the screen will be mounted to the wall and I need to redesign fonts and stuff but it's coming along. I figured it was finally time to have some payoff for all the work I've put into perfectly tagging every last music file I have.
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: If text is x then

Post by Yincognito »

Nachtschade wrote: December 4th, 2023, 2:39 pm Excellent. Thank you so much.

This works fine. I've edited it a little more to make it say either "Last Played On 10-12-2019 00:14:11" or "Never Played Before", which is even more clean.

As for your question about MM working with NowPlaying. It does. At least MM4 does. I don't use 5 since all the great MM custom scripts for 4 don't work with 5 and many have not yet been ported and I rely on a few.

I've had a small Now Playing thingy going on in the corner of my second screen for years but I've gifted myself a dedicated Now Playing screen last week so now I'm trying to make my script better and more beautiful. ;-)
Ah, I see - if you're happy with it, then it's all good (what we do for ... ourselves, right?). 8-)
Your adjustment does indeed sounds more natural, glad you managed to make it, that's the spirit. :thumbup:

EDIT: Just saw your edit and image - looks great. Next time I go to Sweden I'll make sure to check it out... :p
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth