It is currently April 23rd, 2024, 8:21 pm

Converting Generic Text to a Time

Get help with creating, editing & fixing problems with skins
Docta
Posts: 8
Joined: November 26th, 2016, 4:16 am

Converting Generic Text to a Time

Post by Docta »

I'm currently trying to make a "Now Playing" skin that uses the Untamed Now Playing firefox plugin. The plugin provides individual .txt files that contain artist, title, song length, and (real world) time the song started playing (for example, 2:30pm. In reality it is in 24h time). I'm trying to make my skin have a progress meter for the song. In Code that would look like:

Code: Select all

[MeasureProgress]
Measure=Calc
Formula=([MeasureTimeCurrent]-[MeasureSongStart]) / [MeasureSongLength]
The problem is that [MeasureSongStart] and [MeasureSongLength] are not time measures. Instead they are plugin measures tied to a .txt file that contains a time that looks like "01:26".

I'm not sure how to get that text and convert it to a value that I can use in a calc measure.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Converting Generic Text to a Time

Post by balala »

You have to add a few measures, which will convert the appropriate strings, to numbers.
Eg, to convert the [MeasureSongStart], add the following measures:

Code: Select all

[MeasureSongStartHours]
Measure=String
String=[MeasureSongStart]
RegExpSubstitute=1
Substitute="^(\d{2}):(\d{2})$":"\1"
DynamicVariables=1

[MeasureSongStartMinutes]
Measure=String
String=[MeasureSongStart]
RegExpSubstitute=1
Substitute="^(\d{2}):(\d{2})$":"\2"
DynamicVariables=1

[MeasureSongStartNum]
Measure=Calc
Formula=( 3600 * [MeasureSongStartHours] + 60 * [MeasureSongStartMinutes] )
DynamicVariables=1
The [MeasureSongStartHours] and [MeasureSongStartMinutes] measures, get the number of hours and minutes. The last measure, [MeasureSongStartNum], uses the values got by the other two measures, to calculate a numeric value of the song start moment. This represents the number of seconds from midnight to the moment of start.
A similar approach can be applied to convert the length to a numeric value.
This measures will work if the [MeasureSongStart] and [MeasureSongLength] have the mentioned format (01:26). Are you sure that the seconds is not included into these values (eg. 01:26:31)? Because if it is, the substitution won't work.
The substitutions used on the two string measures also won't work, if the leading zero is missing from the number of hours. In such cases, the substitutions should be Substitute="^(\d{1,2}):(\d{2})$":"\1" (and a similar form on the [MeasureSongStartMinutes] measure).
Now [MeasureSongStartNum] (and a similarly created value of the length) can be used in the [MeasureProgress] measure, instead of [MeasureSongStart].
Depending on its format, probably the [MeasureTimeCurrent] measure will also be converted. Please post it.
Docta
Posts: 8
Joined: November 26th, 2016, 4:16 am

Re: Converting Generic Text to a Time

Post by Docta »

The seconds are not included with the plugin for some reason. I've messaged the creator so that maybe one day it'll be changed.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Converting Generic Text to a Time

Post by balala »

Docta wrote:The seconds are not included with the plugin for some reason. I've messaged the creator so that maybe one day it'll be changed.
In this case I think calculations won't be too precise.
But finally my reply helped somehow?
Docta
Posts: 8
Joined: November 26th, 2016, 4:16 am

Image not Updating

Post by Docta »

Code: Select all

[Rainmeter]
Update=10
 
[MeasureFile]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg
Subfolders=0
UpdateDivider=1

[MeterAlbum]
Meter=IMAGE
ImageName=C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg
X=0
Y=0
W=100
H=100 
Tile=0 
PreserveAspectRatio=2
This skin is supposed to display song art but does not refresh at all even when the image file changes. It will only update when I manually refresh.

The following code does not update it either.

Code: Select all

LeftMouseUpAction=!Update]
Help?
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Image not Updating

Post by balala »

Docta wrote:

Code: Select all

[Rainmeter]
Update=10
 
[MeasureFile]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg
Subfolders=0
UpdateDivider=1

[MeterAlbum]
Meter=IMAGE
ImageName=C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg
X=0
Y=0
W=100
H=100 
Tile=0 
PreserveAspectRatio=2
This skin is supposed to display song art but does not refresh at all even when the image file changes. It will only update when I manually refresh.

The following code does not update it either.

Code: Select all

LeftMouseUpAction=!Update]
I'm not very sure what would you like to do, but take into account the followings: the PathName of a Quote plugin measure can indicate a file or a folder. In first case, the file should be a text file and as such, the plugin will return a random part of this file (a line of it). Usually image files are not allowed. In second case (when the path indicates a folder) the path of a random file from that folder will be returned. If you've entered the path of an image into the PathName option of the [MeasureFile] measure, it won't work properly. I suppose you should use here the appropriate folder (C:\Users\Docta\Documents\Rainmeter? - but you should know this). With this, the measure will return the path of a randomly chosen file within the folder.
On the other hand, the visible part of a skin is given by its meters. In your case the only existing meter is [MeterAlbum], which shows the C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg image (through the ImageName option). This is a well specified file, the meter shows it and despite it is updated, it'll show always the same file and you see as it wouldn't be updated (you see no changes). In reality, the skin (and the [MeterAlbum] meter) is updated on each update cycle.
About the update cycle: the Update=10 used in the [Rainmeter] section is totally wrong, the lowest possible value of the Update is 16 (read the second paragraph here). But at least for the posted code, a such low value isn't needed, I don't see anything which would require it. I suggest to replace it with the default Update=1000.
And one more: although the Plugin option of the [MeasureFile] measure is working, it's not needed in this form, the Plugin=QuotePlugin form is entirely enough. Not absolutely necessary to modify it, but is desirable.
Docta wrote:The following code does not update it either.

Code: Select all

LeftMouseUpAction=!Update]
The opening bracket of the bang is missing, the correct form would be either LeftMouseUpAction=!Update, or even better LeftMouseUpAction=[color=#FF0000][[/color]!Update].
User avatar
sephirotess
Posts: 332
Joined: December 8th, 2016, 6:45 am

Re: Converting Generic Text to a Time

Post by sephirotess »

If it's for a cover album, the code should looks like something like this:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Player=Winamp

[Wplayer]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#Player#
PlayerType=Title
OnChangeAction=[!UpdateMeasure WCover][!UpdateMeter Cover][!Redraw]

[WCover]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[Wplayer]
PlayerType=COVER
UpdateDivider=-1

[Cover]
Meter=IMAGE
MeasureName=WCover
W=100
H=100 
AntiAlias=1
UpdateDivider=-1
Docta
Posts: 8
Joined: November 26th, 2016, 4:16 am

Re: Image not Updating

Post by Docta »

balala wrote:I'm not very sure what would you like to do,
I'm sorry I should have been more specific about my problem.I have web plugin that downloads song art from songs on Soundcloud (you helped me with a problem with it earlier). The meter detects the image file and displays it, but only if I manually refresh the skin (as in right clicking and hitting refresh). If I change songs, the song name/artist name updates and displays the new song properly. The image skin does not, even though the actual image file updates correctly. Am I using my [MeterAlbum] incorrectly? I just want the image to update when the image file changes just like the song name/artist.

Also, the folder is correct, I have the plugin set to download it's data to my rainmeter folder for easy access. And the open bracket at the end is simply a typo that only exists because of copy/pasting incorrectly. Thanks for the help.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Image not Updating

Post by balala »

Docta wrote:I'm sorry I should have been more specific about my problem.I have web plugin that downloads song art from songs on Soundcloud (you helped me with a problem with it earlier). The meter detects the image file and displays it, but only if I manually refresh the skin (as in right clicking and hitting refresh). If I change songs, the song name/artist name updates and displays the new song properly. The image skin does not, even though the actual image file updates correctly. Am I using my [MeterAlbum] incorrectly? I just want the image to update when the image file changes just like the song name/artist.

Also, the folder is correct, I have the plugin set to download it's data to my rainmeter folder for easy access. And the open bracket at the end is simply a typo that only exists because of copy/pasting incorrectly. Thanks for the help.
Could you please post your code? It'd be much easier.
Docta
Posts: 8
Joined: November 26th, 2016, 4:16 am

Re: Converting Generic Text to a Time

Post by Docta »

I did earlier, here it is again. I think, from what you said earlier, that the plugin portion is completely unnecessary for what I'm trying to accomplish.

Code: Select all

[Rainmeter]
Update=10
 
[MeasureFile]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg
Subfolders=0
UpdateDivider=1

[MeterAlbum]
Meter=IMAGE
ImageName=C:\Users\Docta\Documents\Rainmeter\unp_album_art.jpg
X=0
Y=0
W=100
H=100
Tile=0
PreserveAspectRatio=2