INTERACT FORUM

Please login or register.

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

Author Topic: Help with an expression  (Read 1967 times)

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Help with an expression
« on: November 10, 2013, 05:18:05 pm »

I have this close, but not perfect...I need help with an expression that will do the following:

(note: I have a custom library field that will be a value of 1 if the program is over 90% watched...it is 'Watched')

If Watched is 1 and Number plays is >0 then Output 1 (Video is watched)
If Number Plays is 0 (or empty) and Watched is 0 then Output 2 (Unwatched)
If Watched is 1 and Number Plays 'isempty' then Output 1 (Video is Watched - special case...this happens when I convert format)
If Watched is 0 and Number Plays is > 0 then Output 3 (Video is started, but not finished)

This will be going in the 'Video' Name expression field so that I can control how the Recent Shows field looks (bold white for new, different color for started, and grey for watched, plus some special symbols)

If anyone can help, I would appreciate it...here is what I have so far, but this only works on the 1st, 2nd, and 4th scenario.

if(!isempty([Number Plays]), if([watched], <font color="888888">√ [Series] [SeasonEpisode]-[Name], <font color="C3FFB3">! [Series] [SeasonEpisode]-[Name] <//font>), <font color="FFFFFF">>[Series] [SeasonEpisode] - [Name]</font>)
Logged

RJC

  • Junior Woodchuck
  • **
  • Posts: 56
Re: Help with an expression
« Reply #1 on: November 11, 2013, 06:45:13 am »

It's a tricky one but this might help:

IfElse(
Math(Compare([Watched], =, 1) & Compare([Number Plays], >, 0)), Watched,
Math(Compare([Watched], =, 0) & Compare([Number Plays], =, 0)), Unwatched,
Math(Compare([Watched], =, 1) & Compare([Number Plays], =, 0)), Special Case,
Math(Compare([Watched], =, 0) & Compare([Number Plays], >, 0)), Started
)

I'll leave you to do the formatting.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Help with an expression
« Reply #2 on: November 11, 2013, 11:50:30 am »

This seems to work, so thanks!

But, I have noticed that sometimes (I'm guessing when a show is recorded back to back) my watched library field is showing as 1, even though I haven't watched it (so number of plays is 0, which marks is as watched)...so I guess I have to figure that out.  If you have any suggestions, that would be great...I actually am using the following, which I got from another thread:

Math(!formatnumber([Bookmark]) | above(formatnumber([Bookmark]) / [Duration,0], 900))

The problem is, I really don't know what it is doing...ultimately, I want to set this up so that is it is <20% watched, it is considered unwatched, but >90% watched, it is considered watched.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Help with an expression
« Reply #3 on: November 11, 2013, 12:27:01 pm »

so why won't this work...I'm trying to create an expression that will determine the percentage watched...what I have is this:

Library Field "Test Duration": Math(formatnumber([duration,0], 2))  <-this converts the duration to seconds...so instead of 2:12, it would be 132.31.
Library Field "Test Bookmark":math(formatnumber([Bookmark], 2)/1000)  <-this converts the bookmark to seconds (I am assuming the bookmark is in milliseconds)
Library Field "Test Calculated Position": Math([Test Bookmark]/[Test Duration])  <-this should return a percentage of how far it has been watched, but instead it returns an expression error.

If I replace the '[[Test Duration]' in the 'Test Calculated Position' with a real number, then it works, which leads me to believe that the problem lies in the Test Duration output not being a number, but a string or something...but I don't know where to go from here...if I could get this working, then I could make my original goal much easier.
Logged

RJC

  • Junior Woodchuck
  • **
  • Posts: 56
Re: Help with an expression
« Reply #4 on: November 11, 2013, 12:48:52 pm »

You could make it even simpler by using this in a 'Watched' Expression Column.

IfElse(
Compare(Watched(1), =, 0), Not Watched,
Compare(Watched(1), =, 1), Partly Watched,
Compare(Watched(1), =, 2), Watched
)
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Help with an expression
« Reply #5 on: November 11, 2013, 12:53:15 pm »

not sure I follow that...my 'Watched' field only currently returns 0 or 1. 
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Help with an expression
« Reply #6 on: November 11, 2013, 01:31:21 pm »

so why won't this work...I'm trying to create an expression that will determine the percentage watched...what I have is this:

Library Field "Test Duration": Math(formatnumber([duration,0], 2))  <-this converts the duration to seconds...so instead of 2:12, it would be 132.31.
Library Field "Test Bookmark":math(formatnumber([Bookmark], 2)/1000)  <-this converts the bookmark to seconds (I am assuming the bookmark is in milliseconds)
Library Field "Test Calculated Position": Math([Test Bookmark]/[Test Duration])  <-this should return a percentage of how far it has been watched, but instead it returns an expression error.

If I replace the '[[Test Duration]' in the 'Test Calculated Position' with a real number, then it works, which leads me to believe that the problem lies in the Test Duration output not being a number, but a string or something...but I don't know where to go from here...if I could get this working, then I could make my original goal much easier.

Got it...it needed a space around the '/'.
Logged

RJC

  • Junior Woodchuck
  • **
  • Posts: 56
Re: Help with an expression
« Reply #7 on: November 11, 2013, 02:50:04 pm »

Watched() is a built-in MC Function which does most of what you want.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Help with an expression
« Reply #8 on: November 11, 2013, 03:01:52 pm »

Thanks...I will play around with it, but my feeling is I will want more control over it, so this is what I came up with.  It appears that the only thing it doesn't do that I would like it to do is if I convert a video, and import it, it is marked as unwatched...which it technically is (but I only convert format once I have watched a TV show and I am archiving)...I just can't seem to come up with a way to reliably detect that scenario without screwing up other scenarios...but here it is...if anyone has suggestions, please let me know!

Custom Library Fields:
SeasonEpisode = if([Episode], <font color="888888">S[Season]EPadNumber([Episode], 2), )
SCW Bookmark = math(formatnumber([Bookmark], 2)/1000)
SCW Calculated = Math([SCW Bookmark] / [SCW Duration])
SCW Duration = formatnumber([duration,0], 2)&datatype=[number]

The expression in the 'Custom File Info Panel|TV Show":
Code: [Select]
IfElse(Math(Compare([SCW Calculated], >=, .92)), <font color="888888">√ [Series] [SeasonEpisode]-[Name]</font>, Math(Compare([SCW Calculated], >=, .07) & Compare([SCW Calculated], <, .92)), <font color="C3FFB3">! [Series] [SeasonEpisode]-[Name] </font>, Math(Compare([SCW Calculated], >=, 0) & Compare([SCW Calculated], <, .07)), <b><font color="FFFFFF">[Series] [SeasonEpisode] - [Name]</font><b>)
Broken out, it is:
Code: [Select]
IfElse(
    Math(Compare([SCW Calculated], >=, .92)), <font color="888888">√ [Series] [SeasonEpisode]-[Name]</font>,
    Math(Compare([SCW Calculated], >=, .07) & Compare([SCW Calculated], <, .92)), <font color="C3FFB3">! [Series] [SeasonEpisode]-[Name] </font>,
    Math(Compare([SCW Calculated], <, .07)), <b><font color="FFFFFF">[Series] [SeasonEpisode] - [Name]</font></b>
    )
The nice thing, is if I manually set the file back to the beginning (rewind), then it marks it as not watched, which is what I want.

I've only done limited testing, but it appears to work fine.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Help with an expression
« Reply #9 on: November 11, 2013, 04:27:20 pm »

The first Math() function in your expression is a no-op, and can be removed.

The < .07 case can be tested second in the IfElse, thereby leaving the final "everything else" case.

Be sure to escape forward slashes, as in the <//font> closing tags.

IfElse(
    Compare([SCW Calculated], >=, .92),  <font color="888888">√ [Series] [SeasonEpisode]-[Name]<//font>,
    Compare([SCW Calculated], <, .07),   <font color="FFFFFF">;[Series] [SeasonEpisode] - [Name]<//font><//b>
    1,                                                    <font color="C3FFB3">! [Series] [SeasonEpisode]-[Name] <//font>
    )
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up