INTERACT FORUM

Please login or register.

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

Author Topic: Calculating MCWS file field values in MC?  (Read 1645 times)

Northernmost

  • Recent member
  • *
  • Posts: 7
Calculating MCWS file field values in MC?
« on: April 14, 2011, 01:54:10 am »

Background:
I'm writing a webOS app to wirelessly sync playlists to a device using MCWS. To uniquely identify files on the device compared to those appearing in one or more playlists I'm downloading them and naming them [key]-[date modified].[extension] e.g. 17404-1299850178.jpg. This then gets used when processing playlists and figuring out what needs downloading.

Problem(s):
I'm looking at a way of sideloading files (over USB to save potentially syncing 10GB+ on an initial wirelesss sync) onto the device using a copy operation in MC. I need to be able to rename files in the copy operation to match the naming convention above but I'm now stuck as I cannot get the filename rule in the Rename, Move & Copy Files dialog to generate the same naming convention.

#1 - I can't find a way to get a files "Key" value as returned from MCWS using Playlist/Files.

#2 - Similarly, I can't find a way to get a files "Date Modified" value as returned from MCWS using Playlist/Files.

My feeble attempts:
#1 has me stuck. Perhaps the Key field isn't exposed within MC itself? I've been through the list of fields and tried using the Fields function on all the permutations I could think of for the internal value e.g. "Key", "key", "_key", "ID" and so on.

#2 I've been trying out using the Field(Date Modified,0) function which does return a numerical value but it's not the same as the corresponding MCWS value e.g. MCWS returns "1302599881" while the Field function returns "40268.65937449999956344". I can't figure out how to turn one in to the other. The results are the same for each version in Setup below for both files stored in a local library and those accessed over Media Network. All files are stored on NTFS volumes... if that makes any odds.

Setup:
MC 15.0.174, 16.0.60 and 16.0.64.

So, in a nutshell: is there a way to get the Key and Date Modified values as returned by MCWS within MC itself?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42047
  • Shoes gone again!
Re: Calculating MCWS file field values in MC?
« Reply #1 on: April 20, 2011, 04:59:44 pm »

#1 - I can't find a way to get a files "Key" value as returned from MCWS using Playlist/Files.

Coming in 16.0.73 and newer:
NEW: Added FileKey() function to expression language to return the integer key of a file in the database.


Quote
#2 - Similarly, I can't find a way to get a files "Date Modified" value as returned from MCWS using Playlist/Files.

You're bumping into the fact that there are two internal date types used by Media Center:
1) Seconds after 1970 (integer)
2) Days after 1900 (decimal)

To build a filename, you could use something like:
FormatDate([Date Modified, 0], yyMMdd)

The expression engine takes care of the two types of dates for you.

Does that help?
Logged
Matt Ashland, JRiver Media Center

Northernmost

  • Recent member
  • *
  • Posts: 7
Re: Calculating MCWS file field values in MC?
« Reply #2 on: April 20, 2011, 11:30:31 pm »

Brilliant, thanks Matt :)

For #2 it looks like MCWS is giving you seconds after 1970 and the expression editor is using the other, so I should be able to work it out from there. I'll be waiting for the coffee to kick in before I go looking more closely at it though ;)
Logged

Northernmost

  • Recent member
  • *
  • Posts: 7
Re: Calculating MCWS file field values in MC?
« Reply #3 on: April 21, 2011, 12:30:42 am »

Here's the formula I used in MC:

FormatDate([Date Modified, 0], yyMMdd)PadNumber(FormatDate([Date Modified,0],Hour),2)PadNumber(FormatDate([Date Modified,0],Minute),2)

This gets you a sortable 10 digit date modified value. Thanks again Matt.
Logged
Pages: [1]   Go Up