Help with MCEBuddy, Manual invoking via Plex Postprocessing script

Hi all,

I’ve run into a quandary: because Plex no longer writes DVR recordings as MKVs, the metadata Plex creates is lost when the filename changes from a .TS file to a .MKV following conversion. If I use MCEBuddy to rename the files, because they pull from different data sources, I often get incorrect results (i.e., Using Season 4 vs season 2017 for @Midnight, though that won’t be much of a problem for too much longer, sniff).

I can preserve the metadata if I invoke MCEBuddy via the postprocessing script option. I’ve got that working, but it creates a new problem for me: right now I make the determination on if a recording should be run through comskip by virtue of where the recording is made (TV vs TV-Commercials). MCEBuddy has a handy-dandy ability to restrict the execution of a particular profile by file monitored location. I don’t seem to have that ability when I invoke it via the script.

Is there a way to selectively run recordings through Comskip via the postprocessing option?

For reference, Plex DVR provides the following:

The script runs in whatever directory you have placed it.
DVR Post processing simply calls your script and passes it a single variable of the full path and filename of the recorded video in the .grab processing folder. That variable (file name) can be referenced in your script with standard input variable names:
Windows: %1
Linux/Unix/Android/Apple: $1
So anywhere in your script where you need to refer to the full path and filename you can use the standard variable. You can also use standard modifiers to refer to pieces of the drive/path/filename with or without the extension:
Windows:
%~d1 = drive only
%~p1 = path only
%~n1 = filename only without path or extension
In Windows %1 should not be in quotes, but you’ll need to quote any partial reference as the path/filename will have spaces in it.

Thanks! Will.

Is there any chance of enhancing MCEBuddy to respect the path that Plex provides as an input for determining what profile is used when it’s invoked via CLI / script?

Can you elaborate a little on what’s happening and what you want to see happen.

In my old set-up, I limit the conversion tasks (either removing commercials or not) to a particular set of locations (recordings with commercials, commercial free recordings). This works pretty well for me.

When Plex DVR shifted back to .ts from .mkv, it means that the metadata that Plex has for that recording is lost unless I use the post-processing script option.

If I use the post-processing script option, there doesn’t seem to be any logic I can apply to choose one conversion task vs another, other than parsing the file name. This is really fragile, and requires me to update it whenever there’s a new recording.

What I’m hoping is that there’s an alternative approach / update to MCEBuddy so that I can pass it a file location (i.e., …/TV-Commercials) and as a result of that, it will choose the correct conversion task when invoked from the CLI / via script.

Hope this is clear - if I’m missing something and this is already possible, please let me know. Thanks! Will.

Let me see if I understood you correctly. You want MCEBuddy to look at the filename passed via the CLI and then determine which Conversion Task to run (and that conversion task has a specific script attached to it)?

If so I think it could be done this way:

  • First setup your (multiple) Conversion Tasks
  • For each conversion task you should create a custom profile so that each profile has a custom script (if you want different post processing scripts for each conversion task)
  • Now for each Conversion Task you can assign the Filename filters in the Advanced Settings section, e.g. one conversion task will only processes files with names CSI* in it and other does only House* etc.
  • Finally for each of these conversion tasks designate them to only be run when the file is passed via the CLI in the Expert Settings -> Select monitor locations option (see below)

IMG_0694

I was hoping to avoid that approach as it’s prone to me forgetting to update the filter when I add a new show or movie.

Like I say, the current approach I have, which doesn’t use the post-processing script in Plex, assigns the conversion task based on where the file is saved. Since I know this when I set up the recording, it’s all automatic. Unfortunately, I lose the meta-data since Plex is back to recording in .TS.

If this is the only way to do it, I’ll make it work - I was hoping for an alternative. Thanks as always!

1 Like

If you have a suggestion or want to add a variable that can be passed to the scripts let us know and we look into adding it.

I think there are two aspects to a possible solution:

  1. The post-processing script doesn’t want there to be monitored locations, but those are required to restrict a given encoding task. If it’s possible to set up the locations, but never have MCEBuddy check them for new locations, that would work
  2. In conversion tasks expert settings, it looks like the manual/CLI task is separate from the folder folder restriction. Would it be possible to add an option for a file location mask (i.e., only perform this task in CLI if the file is in …/tv-commercials/) as part of the CLI selection? If that was available, there’s no need for an additional variable

Thanks! Will.

Let me try to address the points above

  1. Having the location but not checking could cause a lot of confusion. It’s a fairly fundamental aspect. The option we could look at is disabling the Monitor location but how will that help? I don’t see how Monitor location disabling would solve your issue?

  2. From a GUI perspective I am unable to visualize how this would look. Open to ideas. However having said implement a variable would be much simpler and keeping in line with the overall architecture.

Totally agree regarding point 1 - if you could enter a path mask for the CLI selection, you wouldn’t need it, as I think about it a bit more. Point 1 was more about being able to select the location in Conversion Tasks > Expert.

In terms of how to expose point 2, I think I’d accomplish it like this:
When a user selects Manual / CLI in the expert settings, a text field appears below it allowing the user to enter a path. File Path Mask probably isn’t the friendliest name, but maybe something like “restrict to only these locations.” There should be a plus after the text field to allow you to add an additional location.

If the variable approach is easier, I guess it’s a matter of setting up what variable corresponds to a given conversion task. I the case of Plex, and how I’d use it, it would probably be “%~p1” - the path of the file.

Really appreciate the attention to this!

For point 2, are you referring to conversion task or Monitor location. Because the CLI selection option already exists for conversion tasks and it also has a file filter so I’m not getting what exactly is missing here.

Coming to the variable, there already is a variable for custom scripts which passes the file path.

I’m referring to Conversion Tasks - Then I’m not sure how to do point two.

Are you saying that I could have Conversion Task > Expert Settings> Select Monitor Locations set to only “Manual / CLI” and include something like “\DISK8\Plex\TV-Commercials” in the File Name Match and it would only execute on those manual tasks where the file lives in \DISK8\Plex\TV-Commercials?

Thanks!! Will.

One other bit of information that may be important - Plex DVR allows only one post processing script, hence trying to move the logic of choosing which conversion task should be executed into MCEBuddy. If the only way is putting the logic into the script itself, then I’ll have to figure out how to do that there.

Is there an ability to specify which Conversion task should be executed via CLI?

Thanks!! Will.

No, the CLI is basically an API extension of manual addition. The fundamental architecture doesn’t allow manual selection of conversions tasks. Those linking only happen through the conversion task itself using the Select Monitor locations feature.

Ok - so I’m back to “I don’t know how to do this.”

If I want to invoke MCEBuddy via CLI, and have the conversion task chosen based off the path of the file passed to it, how do I do that?

You’ll have to enter the file name filter in the conversion task.

You are back to your earlier point. Thinking out of the box how can you handle this with a post script?

Yah. I don’t think I can handle it in the script without the ability to specify which conversion task should be used as a command line option. If that was there, I could parse the path in the script, pass the filename, and choose the appropriate conversion task. Any chance of getting something like:

MCEBuddy.UserCLI.exe --command=addfile task=“commercial removal” --action=%1

Thanks! Will.

1 Like

I’ll discuss with the team on this and come back

Will_Tschumy any chance you would share your post processing script for Plex? I would like to look at it as I have used plex for years and just got a homerun and now learning mcebuddy to convert the .ts files to something more manageable for playing in plex.

Thanks in advance if you can…

Hi Jeff,

Happy to share what I’ve got, though I should caveat that I’m not using it currently. What I’m currently doing is having MCEBuddy watch the different locations where PMS records the files, and run conversion tasks based on the location. That way, I can determine if the file should be screened for commercials or not.

That said, the postprocessing script I’ve tested is:

@echo off
C:\Progra~1\MCEBuddy2x\MCEBuddy.UserCLI.exe --command=engine --action=start 
timeout /t 2 /nobreak > NUL
C:\Progra~1\MCEBuddy2x\MCEBuddy.UserCLI.exe --command=addfile --action=%1
timeout /t 10 /nobreak > NUL
:loop
for /f "delims=" %%o in ('C:\Progra~1\MCEBuddy2x\MCEBuddy.UserCLI.exe --command=jobstatus --action=%1 --quiet') do set status=%%o
if %status% == "not present" (
	Exit
) else (
	timeout /t 2 /nobreak > NUL
	goto loop
)

Once I finds out if they can allow for the manual specification of a conversion task from the command line, I’ll modify the script to choose the encoding task based off of the path in the %1 variable.

I didn’t write the script - I found it on one of the different Reddit threads (beware of the megafilz link - it’s an adware / spyware distribution vector).

Hope it helps! Will.

1 Like