INTERACT FORUM

Please login or register.

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

Author Topic: How deep can nested Expressions go?  (Read 1241 times)

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
How deep can nested Expressions go?
« on: October 30, 2018, 04:42:03 pm »

I am trying to make an expression that will tag some imported videos (live TV imported from another server) with a custom tag.  I have been experimenting, and have my proof of concept working (see below):

Code: [Select]
if(isequal([Series], DC's Legends of Tomorrow, 1), Compress Now,
   if(isequal([Series], Speechless, 1), ,
   if(isequal([Series], Recorded Movies, 1), Compress_Movie,
   if(isequal([Series], Teen Mom OG, 1), ,
   if(isequal([Series],The Goldbergs, 1), ,
   if(isequal(Media Sub Type], Movie, 1), Compress_Movie, Compress))))))

The problem is that I probably have another 15-20 series deep that I need to go.  Will that work, or is there a better way to do what I want? 

I used to have this built into the recording subscription, but I have cancelled cable, and am recording off site, and transferring the files using OneDrive.  When they are auto imported from the OneDrive folder locally, I am applying the above expression on a custom field that I use to determine whether to auto compress the show after watching.

EDIT: Added some line feeds in the code section above for clarity.
Logged

swiv3d

  • Guest
Re: How deep can nested Expressions go?
« Reply #1 on: October 30, 2018, 06:35:00 pm »

Best way to find out is to keep adding them until it fails. Still don't quite get what you are doing though - you want to compress some series but not others after you have watched them?
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #2 on: October 30, 2018, 06:43:15 pm »

Still don't quite get what you are doing though - you want to compress some series but not others after you have watched them?
Exactly.  Things like Teen Mom, Flip or Flop, and some other things, I don't archive.  But some shows I compress after watching them in HD.  I use an application that Glynor developed called MCAutoQue, and it basically looks at a library field and will do some action based on what is in that field.

I have 4 options:

1. Compress - this will compress the show the night after it was watched.  That way, I watch in HD, but compress down to 480p for archving.
2. Compress_Movie - only difference here is that the path that it gets written to is different.  Otherwise, the same as above.
3. Compress Now - this is for shows that I determine I may want to watch some day, but don't have time now.  So I compress them the night they are recorded.
4. Blank field - this will do nothing...this is basically for those shows that I don't want to save.

The process works well.
Logged

swiv3d

  • Guest
Re: How deep can nested Expressions go?
« Reply #3 on: October 30, 2018, 06:54:38 pm »

Aah! I see - I would just buy a bigger and bigger storage device ?. One thing about your code
You should use ifelse(test1,action1,test2,action2)
Someone else has a similar question https://yabb.jriver.com/interact/index.php/topic,118034.0.html
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #4 on: October 30, 2018, 07:30:56 pm »

Trying to figure out how to use Ifelse but still have a default.  Probably 85% of what I record is the simeple 'Compress' option, so I don't want to have to specify all of those.  I'm thinking I can use an If statement, in conjuntion with the IfElse, but I haven't been able to wrap my head around the syntax yet.
Logged

swiv3d

  • Guest
Re: How deep can nested Expressions go?
« Reply #5 on: October 30, 2018, 07:35:51 pm »

I think your code would become -
ifelse(isequal([Series], DC's Legends of Tomorrow, 1), Compress Now,
  (isequal([Series], Speechless, 1), ,
   (isequal([Series], Recorded Movies, 1), Compress_Movie,
   (isequal([Series], Teen Mom OG, 1), ,
   (isequal([Series],The Goldbergs, 1), ,
   (isequal(Media Sub Type], Movie, 1), Compress_Movie, Compress
)

Easy to add to or take away from.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #6 on: October 30, 2018, 07:40:10 pm »

I just figured it out, but mine is slightly different.

Code: [Select]
ifelse(isequal([Series], DC's Legends of Tomorrow, 1), Compress Now,
  isequal([Series], Speechless, 1), ,
  isequal([Series], Recorded Movies, 1), Compress_Movie,
  isequal([Series], Teen Mo, 8), ,
  isequal([Series],The Goldbergs, 1), ,
  isequal(Media Sub Type], Movie, 1), Compress_Movie,
  1, Compress)

I found it in the docs, where 1 always evaluates to true, so in effect, the '1, Compress' will be the final result if no other conditions are true.
Logged

swiv3d

  • Guest
Re: How deep can nested Expressions go?
« Reply #7 on: October 30, 2018, 07:44:06 pm »

You are quite right. I'm getting too old I think! :-X
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #8 on: October 30, 2018, 07:45:40 pm »

Thanks a ton for your help.  I'm creating the expression in notepad right now...
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: How deep can nested Expressions go?
« Reply #9 on: October 30, 2018, 08:54:04 pm »

Help yourself in maintaining all that by removing all instances of Series names from the expression.

Then create a new field that is an Integer Checkbox type field, relational with respect to [Series], and for any current or future series that you want to be compressed, just tick the checkbox on the Series or any Episode and all Episodes will the marked for compression. Then use the status of that field in your expression.

I also would be surprised if MCAutoQue couldn't determine which path to save the compressed video, so that "Compress" and "Compress_Movie" could be combined into one script.

It also looks like you tag recorded movies with a [Series] of "Recorded Movies", which is an extra step. Recorded movies are all going to have a [Media Sub Type] of "Movie", if MC guesses correctly. Sometimes it doesn't of course. So you should only need to test for the [Media Sub Type] of "Movie" and not for a [Series] of "Recorded Movies".

BTW, did you know that all recordings made have a value in the [Recording Rule ID] field? This is how MC determines if a show is a recording or not. The tag is saved to the file if possible, so even a recording made on another MC Server should have a value in that tag. This could help with determining the path for a recorded movie, for example, compared to movies sourced elsewhere.

You could also create two checkbox fields, one for "Compress" and one for "Compress Now", and use those plus the source type (recorded or not) and  [Media Sub Type] for MCAutoQue to decide what to do.


Basically, I think you could do some simplification that would make maintenance much easier. But I am guessing about the stuff you are doing in the background.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #10 on: October 31, 2018, 09:31:23 am »

Help yourself in maintaining all that by removing all instances of Series names from the expression.

Then create a new field that is an Integer Checkbox type field, relational with respect to [Series], and for any current or future series that you want to be compressed, just tick the checkbox on the Series or any Episode and all Episodes will the marked for compression. Then use the status of that field in your expression.
Very helpful.  I can't do a checkbox, but I can do a field that only accepts 1, 2, 3, or 4; and I can determine the value of the 'Needs Processing' field based on that number.

Quote
I also would be surprised if MCAutoQue couldn't determine which path to save the compressed video, so that "Compress" and "Compress_Movie" could be combined into one script.
It can't. but my script that I run could (with the help of MCAutoQue passing an argument), but it has evolved over the years, and it was (at the time) simple to have it run a different script for each condition.

Quote
It also looks like you tag recorded movies with a [Series] of "Recorded Movies", which is an extra step. Recorded movies are all going to have a [Media Sub Type] of "Movie", if MC guesses correctly. Sometimes it doesn't of course. So you should only need to test for the [Media Sub Type] of "Movie" and not for a [Series] of "Recorded Movies".

There are actually 2 tags being written on import, and the other is the tag 'Recorded Movies' in [Series] if it is a movie.  At the time I wasn't 100% sure when the tags would be applied ( and in what order), so I put both in just to cover my bases. 

Quote
BTW, did you know that all recordings made have a value in the [Recording Rule ID] field? This is how MC determines if a show is a recording or not. The tag is saved to the file if possible, so even a recording made on another MC Server should have a value in that tag. This could help with determining the path for a recorded movie, for example, compared to movies sourced elsewhere.

It doesn't seem to (I record in .ts).  At least based on my delete options after watching something.  It is different now that I am not recording on the server I am watching from.  I did know that this is how it functions prior to this setup.

Quote
Basically, I think you could do some simplification that would make maintenance much easier. But I am guessing about the stuff you are doing in the background.

Agreed...I have already created the new library field that will allow me to set the 'mode' per series, thanks for that.  I will leave it as I have it for a week, just to make sure that the field will work when the next set of recordings for a specific series happen.

Again, thanks!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: How deep can nested Expressions go?
« Reply #11 on: October 31, 2018, 11:48:49 am »

Kind of 'off-topic' now I suppose, but to answer the title question... "How deep can nested expressions go?"

We don't know because we never hit the boundary yet...
Before I switched age calculation to a more efficient system of letting MC do the math for me, twelve years ago, before we had the ability to set "date type" custom fields, I used this system for our four grandkids. Each child had a corresponding field that covered them to 14 years old! At one point, I think Matt posted that this resulted in thumbnail text expression totalling 73,000 characters :)

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: How deep can nested Expressions go?
« Reply #12 on: October 31, 2018, 03:18:49 pm »

It doesn't seem to (I record in .ts).  At least based on my delete options after watching something.  It is different now that I am not recording on the server I am watching from.  I did know that this is how it functions prior to this setup.

My mistake. I just checked the [Recording Rule ID] field setting using "Manage Library Fields" in one of my test libraries, and it isn't marked to "Save in file tags (when possible)". My HTPC Library does have that checkbox ticked so that the tag is saved into the recordings. I must have changed that along the way sometime.

You could turn on that setting for the Server where recordings are done ( I assume that is a MC Server), and then it should be available on the Server you play from. I'm pretty sure that sort of tag can be saved to a TS file. I use JTV files, and I know it is saved to them on my HTPC. Well, into the Sidecar file actually.

If you turn on saving that tag, you could do some more simplification. But existing recordings wouldn't have the value, and as this is a non-editable field, I'm not even sure an "Update tags from Library" on the recording Server would update it. It might, but I understand that may not be practical in your setup. However, if the field is stored in a Sidecar file as in my situation, it would be easy to put a value in there for any existing recordings, and the "Update Library from tags" function would probably write them to the Library correctly. Just thinking aloud here.


BTW, I suspect you now know, but Yaobing has confirmed a couple of times that tags are written to recording files at the beginning of the recording. So the "Movie" [Media Sub Type] and the [Recording Rule ID] tags should be immediately available for any post-recording processes.


Marko: Argh. Just Arrrggghhhh!
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #13 on: October 31, 2018, 03:44:45 pm »

You could turn on that setting for the Server where recordings are done ( I assume that is a MC Server), and then it should be available on the Server you play from. I'm pretty sure that sort of tag can be saved to a TS file. I use JTV files, and I know it is saved to them on my HTPC. Well, into the Sidecar file actually.

If you turn on saving that tag, you could do some more simplification. But existing recordings wouldn't have the value, and as this is a non-editable field, I'm not even sure an "Update tags from Library" on the recording Server would update it. It might, but I understand that may not be practical in your setup. However, if the field is stored in a Sidecar file as in my situation, it would be easy to put a value in there for any existing recordings, and the "Update Library from tags" function would probably write them to the Library correctly. Just thinking aloud here.
My original plan was to use sidecars on the recording server, but it wasn't creating the sidecar files on my recorded TV folder.  I made a change to the auto-import settings, and just checked, and it does appear that it is working now though.  I'll have to decide if I want to move back to that, or not.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: How deep can nested Expressions go?
« Reply #14 on: November 17, 2018, 08:49:51 am »

I implemented today the simplified way of doing this suggested by RoderickGI a few posts back.  I created a field that was relational to the Series.  I also limited the data that can go into the field (IE: 1-Compress, 2-Compress Movie, or 3-Compress Now are the only accepted input values).  The simplified code is:

Code: [Select]
ifelse(isequal([Compress Mode], 1-Compress, 1), Compress, isequal([Compress Mode], 2-Compress Movie, 1), Compress_Movie, isequal([Compress Mode], 3-Compress Now, 1), Compress Now, 1 , )
Now, anything that doesn't have a value in [Compress Mode] is either a new series that I just started recording, or something that I don't want to compress...everything else should tag correctly.  I'll know for sure within a few days.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: How deep can nested Expressions go?
« Reply #15 on: November 17, 2018, 04:04:53 pm »

Excellent. Much better than an infinitely deep nested expression.

Let us know how it goes.  8)
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner
Pages: [1]   Go Up