It is currently April 19th, 2024, 3:32 am

Timestamp on refresh

Get help with creating, editing & fixing problems with skins
Bundi
Posts: 20
Joined: October 11th, 2016, 6:46 am

Timestamp on refresh

Post by Bundi »

Hi,

I am trying get a timestamp showing on one of my skins. I have a skin where I am downloading a picture from a web-camera, that part is working well. However I would like to know what time the picture was downloaded, and the options I have found so far only shows current time (clock).

I am only interested in showing a timestamp on the skin when the skin has been refreshed, or more precisely when the new image has been downloaded.

There is no time (clock) on the webpage either, otherwise getting the time using the webparser from there would maybe be an option.


Is there anyone that has a solution to how I could accomplish this?

The simple script I tried most recently looks like this below, but that constantly updates just like a clock, and not when a new image is downloaded:

[Measure24HrTime]
Measure=Time
Format=%H:%M

Meter=String
MeasureName=Measure24HrTime
X=178
Y=5


Many thanks for any suggestion!

Bundi
Last edited by Bundi on April 9th, 2018, 6:54 am, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Timestamp on refresh

Post by balala »

Bundi wrote:I am only interested in showing a timestamp on the skin when the skin has been refreshed, or more precisely when the new image has been downloaded.
Not refreshed, updated.
Add an UpdateDivider=-1 option to the [Measure24HrTime] measure. this option determines the measure to not being updated.
Then add the following option to the WebParser measure which downloads the image: FinishAction=[!UpdateMeasure "Measure24HrTime"]. This option is executed when the measure finish its action, so when it downloads the image. In that moment the option updates the [Measure24HrTime] measure. This way this measure always returns the moment of last image download.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timestamp on refresh

Post by jsmorley »

If the intent is to know when a "new" image has been downloaded, one that isn't the same one you download on the last UpdateRate of the WebParser measure, then I'm not sure there is a way, unless the web page itself has some date / time indication on it.

If you simply save the time that the image was last downloaded, that will by default be every 10 minutes in WebParser, which is in and of itself not terribly useful information.
Bundi
Posts: 20
Joined: October 11th, 2016, 6:46 am

Re: Timestamp on refresh

Post by Bundi »

Thank you balala and jsmorley for your suggestions.

I tried the option you suggested balala, but it does not seem to update the timestamp when the image is downloaded.

I inserted the code as follows:

Code: Select all

[Measure24HrTime]
Measure=Time
Format=%H:%M
UpdateDivider=-1



[MeasureImgpath]
Measure=Plugin
Plugin=WebParser
URL=http://87.237.210.145/%7Echeckpoi/webcam/visby_stora_torget/webcam_10_1280.jpg
StringIndex=1
Download=1
FinishAction=[!UpdateMeasure "Measure24HrTime"
I think the option to get the file-time would maybe be a good option, the file has the same name the whole time.

I looked at the "FileView plugin" if that maybe could be an option for getting the filetime? or is there another way to go to get that?
As I basically want to make sure that the picture is downloaded, getting the file-time would be a good way of knowing when it was fetched.

Best,
Bundi
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timestamp on refresh

Post by jsmorley »

Your code looks right, except you are missing an end "]" on the bang

[strike]FinishAction=[!UpdateMeasure "Measure24HrTime"[/strike]

FinishAction=[!UpdateMeasure "Measure24HrTime"]
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Timestamp on refresh

Post by balala »

jsmorley wrote:Your code looks right, except you are missing an end "]" on the bang

[strike]FinishAction=[!UpdateMeasure "Measure24HrTime"[/strike]

FinishAction=[!UpdateMeasure "Measure24HrTime"]
Or another possibility would be to not use brackets at all. This would work in this case because there is one single bang:
FinishAction=!UpdateMeasure "Measure24HrTime"
However, although this is working, using the brackets can avoid a lot of problems later.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timestamp on refresh

Post by jsmorley »

IF the image you are downloading is taken with a camera that attaches metadata to the image, and most cameras do, you might want to read the camera metadata, which should (not always, but likely) include a CreateDate field, which is the date and time the image was taken.

To do this, you need an external 3-party addon utility, that you call using the RunCommand plugin. Then you can parse the results returned by RunCommand, and get the value you want.

Example skin:
Note, the exiftool.exe utility is included in the @Resources folder. You can also download it yourself at https://www.sno.phy.queensu.ca/~phil/exiftool/.
ImageMetea_1.0.rmskin

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureImageCreateDate "Run"]

[Variables]
; https://www.sno.phy.queensu.ca/~phil/exiftool/

; Example return value from image metadata
; Create Date                     : 2017:12:25 12:44:28

[MeasureImageCreateDate]
Measure=Plugin
Plugin=RunCommand
Parameter=#@#exiftool.exe -exif:CreateDate "#CURRENTPATH#TestMeta.jpg"
OutputType=ANSI
RegExpSubstitute=1
Substitute=".*([\d]{4}):([\d]{2}):([\d]{2}).*([\d]{2}):([\d]{2}):([\d]{2})":"\2 \3 \1 \4:\5:\6"
FinishAction=[!ShowMeter MeterImageDate]

[MeterImage]
Meter=Image
ImageName=#CURRENTPATH#TestMeta.jpg
W=300
PreserveAspectRatio=1

[MeterImageDate]
Meter=String
MeasureName=MeasureImageCreateDate
W=300
X=150
StringAlign=Center
Y=10R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
Text=Image taken: %1
AntiAlias=1
Hidden=1
1.png
You can check to see if the image you are getting has the needed metadata field, by right-clicking it, selecting Properties, and switching to the Details tab:
2.png
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timestamp on refresh

Post by jsmorley »

This could also be done with PowerShell in Windows, and not require a 3rd-party external utility, but one of the other PSGeeks™ around will have to dig into that...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timestamp on refresh

Post by jsmorley »

Probably something using this:

Code: Select all

$file = Get-Item 'C:\Users\Jeffrey\Documents\Rainmeter\Skins\ImageMeta\TestMeta.jpg'
$shellObject = New-Object -ComObject Shell.Application
$directoryObject = $shellObject.NameSpace( $file.Directory.FullName )
$fileObject = $directoryObject.ParseName( $file.Name )

$property = 'Date taken'
for(
  $index = 5;
  $directoryObject.GetDetailsOf( $directoryObject.Items, $index ) -ne $property;
  ++$index ) { }

$value = $directoryObject.GetDetailsOf( $fileObject, $index )
$value
Bundi
Posts: 20
Joined: October 11th, 2016, 6:46 am

Re: Timestamp on refresh

Post by Bundi »

Success!!

Ashamed that I missed that last bracket in the code, but that did the trick balala, works just like intended now.
It updates the timestamp when fetching the image.

Thanks a lot for helping me (again)

And thanks jsmorley for your suggestion on using the metadata, didn´t think of that option at all.
That will for sure come in use as well!

Have a great weekend!

Many thanks,
Bundi