INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: New function request - timestamp (updated)  (Read 1025 times)

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
New function request - timestamp (updated)
« on: August 19, 2024, 01:37:54 pm »

I would like the ability to capture the time that a field has been updated.  Much like [Date Tagged] but I want to be able to specify a specific field.  I am thinking something like this:

timestamp(fieldname, mode)

Available mode values:
0 write time value if empty
1 write time value any time field is updated

Examples

timestamp([TMDB Rating], 1)
Writes the date that the TMDB Rating was last updated.

fomatdate(timestamp([Awards], 1),date)
Writes the date that the Awards field was last updated.

Thank you for your consideration.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: New function request - timestamp
« Reply #1 on: August 20, 2024, 11:44:04 am »

This would require MC to essentially double the number of existing fields in order to store the [<field_name>_last_updated] value for each field on each file. This would slow down DB write operations and potentially double the DB size.

A single [last updated] field that gets updated whenever any metadata changes for a given file is better, but it's also tricky as it would also get updated when a file is played (because [number plays] changes).
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: New function request - timestamp
« Reply #2 on: August 20, 2024, 12:42:00 pm »

Fair enough.  Then maybe we can come up with a different solution to the problem I want to solve.

I wanted this function primarily so that I could capture the date that an item was added to a playlist.  Here is why. 

I have a watchlist playlist that I add movies to that I want to watch.  For example, I am scrolling through my movies and see a movie I have been meaning to watch, but I am not in the mood for at the moment, I add it to my watchlist playlist.  I then have a smartlist that uses that watchlist and filters it by number of plays, if the number of plays is zero, display the movie, if it's greater than zero, hide it.  This works pretty great except that if I want to re-watch a movie then the number of plays is not zero and it won't display.  This old thread has details of my current setup if the above isn't sufficient.

One solution I came up with was the timestamp idea. I wanted to use timestamp to capture the date a movie was added to a playlist so that I could compare that date against the date that a movie was last played, if the date added to playlist was later than last played then it would appear on my watchlist.

Maybe an alternative solution would be a function that could be used in an after playback expression that removes an item from a playlist.  Or a new date/time function such as:

timestamp()
The timestamp() function returns a floating-point value representing the current system date and time. Very similar to the now() function except that the value is static.

Example
if(isequal(FilePlaylists(), Watchlist, 8), formatdate(timestamp(), date),)

I am open to any kind of solution.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2036
Re: New function request - timestamp (updated)
« Reply #3 on: August 20, 2024, 01:07:23 pm »

I think that to tackle what Moe is wanting to achieve is best solved with pair of new functions:

AddFileToPlaylist(path, mode 0,1)
 - return value probably doesn't add value in context these are used
RemoveFileFromPlaylist(path)
 - return value probably doesn't add value in context these are used

maybe mode 1 to addfiletoplaylist function to create new playlist like path given if it doesn't exist already.

Add is not required so solve this particular task but could be useful for some other tasks and when doing remove it is logical to implement also add. MCWS already have these so shouldn't be too big of a task

E:
so workflow would be:
1. add some movie to your MyLists\WatchList playlist like you do today
2. watch the movie
3. When playback is completed after playback expression kicks in with expression: RemoveFileFromPlaylist(MyLists\WatchList)
4. movie just watched is removed from MyLists\WatchList
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: New function request - timestamp (updated)
« Reply #4 on: August 20, 2024, 02:42:11 pm »

Nice idea.
When adding a file to a playlist there's usually the option to allow adding duplicates. If these functions are added, they should NOT add duplicates as the expression functions can sometimes be executed many times per second (specially while testing), so that would be dangerous.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2036
Re: New function request - timestamp (updated)
« Reply #5 on: August 21, 2024, 04:18:05 am »

Yeah, used "wrongly" it would be a little dangerous like the grouping or IO expressions
Logged

markf2748

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 849
Re: New function request - timestamp (updated)
« Reply #6 on: August 21, 2024, 12:17:03 pm »

Consider a naming scheme similar to that used for List manipulation functions:

PlaylistAdd(...) 
PlaylistRemove(...)

This way a new family of Playlist manipulation functions could be built up over time if there is future interest, analogous to List functions:

PlaylistShuffle(...)
PlaylistCombine(...)
PlaylistClean(...)
PlaylistSort(...)
PlaylistCount(...)
etc.

There are many such options already available in the Playlist RMB context menu.  The functions would just add programmability.

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: New function request - timestamp (updated)
« Reply #7 on: August 21, 2024, 01:37:45 pm »

PlaylistAddFile() and PlaylistRemoveFile() to avoid ambiguous meaning.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42441
  • Shoes gone again!
Re: New function request - timestamp (updated)
« Reply #8 on: August 21, 2024, 02:24:21 pm »

A little bit of a left turn from the original request!

But here's what I was thinking about the add function.

PlaylistAddFile(
Key of the file to add,
Playlist path or ID,
Whether you're using a playlist path (default 0) or playlist ID (1),
No duplicates (default to 0),
Position in playlist (defaults to -1 which means end))

Example adding the current file to the top hits playlist if it's not already there:
PlaylistAddFile(FileKey(), Playlist Group\Top Hits, 0, 1)

Thoughts?  Thanks.
Logged
Matt Ashland, JRiver Media Center

markf2748

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 849
Re: New function request - timestamp (updated)
« Reply #9 on: August 21, 2024, 02:35:56 pm »

Maybe an optional position parameter, for example:
0 or not specified = add to bottom of the list (default)
1 = add to top of Playlist
N = insert as Nth entry, or last if N > (length of Playlist) +1
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42441
  • Shoes gone again!
Re: New function request - timestamp (updated)
« Reply #10 on: August 21, 2024, 02:58:48 pm »

Maybe an optional position parameter, for example:
0 or not specified = add to bottom of the list (default)
1 = add to top of Playlist
N = insert as Nth entry, or last if N > (length of Playlist) +1

Good idea.  Added that as well.
Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: New function request - timestamp (updated)
« Reply #11 on: August 21, 2024, 03:42:29 pm »

A little bit of a left turn from the original request!

Indeed, but as long as it solves my problem I am happy :)

But I think

PlaylistAddFile()
PlaylistRemoveFile()

Will be nice additions.

Thank you for considering.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: New function request - timestamp (updated)
« Reply #12 on: August 21, 2024, 03:42:54 pm »

I think it should be "AllowDuplicates" defaulting to 0, or "NoDuplicates" defaulting to 1. Allowing duplicates by default can be dangerous if the expression is executed on a View, which can run many times per second.
Logged
Pages: [1]   Go Up