INTERACT FORUM

Please login or register.

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

Author Topic: Expression Question for Smart People  (Read 2031 times)

jgreen

  • Citizen of the Universe
  • *****
  • Posts: 2419
Expression Question for Smart People
« on: November 02, 2011, 02:41:20 pm »

I have a fair number of library books in EPUB and PDF formats that I am now managing with MC.  This is working well for me, although I've had to make some configurations myself, and I am by nature fairly lazy.  This question, however, requires not just energy but brains, so I've pretty much thrown up my hands.

Each of these files has DRM that will prohibit reading of the file after 21 days.  I want to create an expression field that will read the "date modified" field of each file, and report a countdown from "21 Days" to "Expired".  This is pretty much what you see in the "Adobe Digital Editions" software reader for this format, although on the last day they calculate it by the hour, and in the last hour they calculate it down to the minute. 

Getting REALLY fancy (although risky) this expression could delete the file on day 22 (Expired +1).

Any ideas?  I believe the EPUB format has machine-readable tags that provide this info (along with other interesting stuff), and if JRiver were ever to enhance their current state of eBook support this is where they'd start.  But I think an expression field based on the "Date Modified" value of the file will serve just fine.  Beyond that I am completely at sea here, so if someone has any suggestions on how to start I'd be grateful.

Thanks!
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: Expression Question for Smart People
« Reply #1 on: November 02, 2011, 07:46:09 pm »

I have no business posting, based on the subject.

But here's an expression that shows how old something is and switches to 'Expired' after some number of days:
If(Compare(Math(Now() - [Date Modified, 0]), >, 21), Expired, FormatDate([Date Modified, 0], Elapsed))

You can filter any view to only show things modified recently (in last 21 days) using a search like this:
[Date Modified]=<21d
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Question for Smart People
« Reply #2 on: November 03, 2011, 01:59:57 am »

If(IsMissing([wiki page],Compare/(/)),Update Page,Page is up to date)

Where did you dig Compare() up from? :D

I've added it to the list of v17 updates that need doing and will get on to that at the weekend!

-marko

jgreen

  • Citizen of the Universe
  • *****
  • Posts: 2419
Re: Expression Question for Smart People
« Reply #3 on: November 03, 2011, 11:12:55 am »

Thanks Matt, this works great!  Expressions are really easy if all I have to do is cut&paste!

Once I put this column in my "BOOKS" view I realized that I'm only concerned about EPUBs and PDFs that reside on my "C" drive (down a complex path).  All the other books in that view will not expire.  So I tried to bracket your "If" test with an additional "If" test (If file type is EPUB, <Use Matt's test>, otherwise print "owned").  But no matter how simple a meta-test I tried, I couldn't get anything to conditionalize your test.  Would you use an additional "If", and use your expression as the result for a true case?  (Go easy, I was an English major in college.)
Logged

rick.ca

  • Citizen of the Universe
  • *****
  • Posts: 3729
Re: Expression Question for Smart People
« Reply #4 on: November 03, 2011, 03:13:38 pm »

Quote
Would you use an additional "If", and use your expression as the result for a true case?

Yes, a nested-If (i.e., If({Condition1}, If({Condition2}, 2True, 2False), 1False) ) should work fine.
In this case, If({IsDRM}, {Matt's expression}, Owned}.

Quote
But no matter how simple a meta-test I tried, I couldn't get anything to conditionalize your test.

So it seems the issue must be finding a suitable condition for {IsDRM}. You can't use [File Type]=[EPUB] because they're not all EPUB (and maybe some EPUB aren't limited in this way). But it sounds like all these files are segregated in a separate folder, so that path should provide a suitable condition. There are a number of different functions you could use to test that, for example...

  • IsEqual([Filename (path)], {substring unique to the DRM files}, 8) – the '8' for a substring search (case insensitive), or
  • IsEqual(ListItem([Filename (path)], {number of DRM folder in folder hierarchy}, \), {DRM folder name})
Logged
Pages: [1]   Go Up