Page 1 of 1

AMC change I'm looking to make

Posted: 04 Dec 2019, 14:50
by mikejandreau
I'm running the AMC postprocess when a torrent finishes in Transmission and it's working perfectly, but I want to make a change.

Here's my current working script:

Code: Select all

#!/bin/sh -xu

# Input Parameters
ARG_PATH="$TR_TORRENT_DIR/$TR_TORRENT_NAME"
ARG_NAME="$TR_TORRENT_NAME"
ARG_LABEL="N/A"

# Configuration
CONFIG_OUTPUT="/Volumes/Super Storage/Video/To Be Processed"

/usr/local/bin/filebot -script fn:amc --output "$CONFIG_OUTPUT" --action move --conflict skip -non-strict --log-file amc.log --def clean=y unsorted=y music=y artwork=y excludeList=".excludes" ut_dir="$ARG_PATH" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL"
And here's my fn:sysinfo

Code: Select all

FileBot 4.8.5 (r6224)
JNA Native: 5.2.2
MediaInfo: 18.12
7-Zip-JBinding: 9.20
Chromaprint: fpcalc version 1.4.2
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2019-05-15 (r565)
Groovy: 2.5.6
JRE: OpenJDK Runtime Environment 11.0.2
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 12 Core / 8 GB Max Memory / 41 MB Used Memory
OS: Mac OS X (x86_64)
HW: Darwin Pennyworth.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64
DATA: /Users/Alfred/.filebot
Package: APP
License: FileBot License PX5825873 (Valid-Until: 2068-10-04)
Done ヾ(@⌒ー⌒@)ノ
What I'm looking to do is modify the postprocess script so that some movies I download get moved somewhere other than /Volumes/Super Storage/Video/To Be Processed/Movies

Ideally I could flag a torrent in Transmission using the Group functionality and have Filebot move it to another directory (ie; 4k Movies) upon the download finishing.

This would allow my other automations to not process the 4k download with Handbrake's CLI (which monitors the To Be Processed Movies and TV Shows directories) and Hazel would move it into the spot where Plex looks for it.

Any help is appreciated!

Re: AMC change I'm looking to make

Posted: 04 Dec 2019, 15:08
by mikejandreau
I think I've got it.

I found a post on Reddit where someone was trying to do something similar, but without the Transmission tagging bit.

I changed my postprocess.sh script to:

Code: Select all

#!/bin/sh -xu

# Input Parameters
ARG_PATH="$TR_TORRENT_DIR/$TR_TORRENT_NAME"
ARG_NAME="$TR_TORRENT_NAME"
ARG_LABEL="N/A"

# Configuration
CONFIG_OUTPUT="/Volumes/Super Storage/Video/To Be Processed"

/usr/local/bin/filebot -script fn:amc --output "$CONFIG_OUTPUT" --action move --conflict skip -non-strict --log-file amc.log --def "movieFormat={fn =~ /2160p|4K|4k|UHD/ ? 'Movies 4K' : fn =~ /3D|3d|HSBS|3dhsbs|H-SBS|3dhou|H-OU/ ? 'Movies 3D' : 'Movies'}/{n} ({y}) - {allOf{match}{s3d}{hd}{vc}{vf}{n.findMatch(group) ? null : '- '+group} join ' '} {' CD'+pi}{'.'+lang}" clean=y unsorted=y music=y artwork=y excludeList=".excludes" ut_dir="$ARG_PATH" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL"
That seems to be doing the trick. Happy to hear if someone's got a better solution, but this seems to work for me.

Re: AMC change I'm looking to make

Posted: 04 Dec 2019, 19:15
by mikejandreau
I'm not quite there. This script is working to sort the movies into either Movies or Movies 4k depending on their quality, but:

It's not putting them into their own folders like my original script did, which I need to make Plex happy.

I've been mucking with it today trying to get it to move the files to their own directory and I can't figure out why it isn't. This is the full postprocessing AMC script I'm using right now to test:

Code: Select all

#!/bin/sh -xu

# Input Parameters
ARG_PATH="$TR_TORRENT_DIR/$TR_TORRENT_NAME"
ARG_NAME="$TR_TORRENT_NAME"
ARG_LABEL="N/A"

# Configuration
CONFIG_OUTPUT="/Volumes/Super Storage/Video/To Be Processed"

/usr/local/bin/filebot -script fn:amc --output "$CONFIG_OUTPUT" --action move --conflict skip -non-strict --log-file amc.log --def "movieFormat={fn =~ /2160p|4K|4k|UHD/ ? 'Movies 4K' : fn =~ /3D|3d|HSBS|3dhsbs|H-SBS|3dhou|H-OU/ ? 'Movies 3D' : 'Movies'}/{n} ({y}) - {allOf{match}{s3d}{hd}{vc}{vf}{n.findMatch(group) ? null : '- '+group} join ' '} {' CD'+pi}{'.'+lang}" clean=y unsorted=y music=y artwork=y excludeList=".excludes" ut_dir="$ARG_PATH" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL"

Re: AMC change I'm looking to make

Posted: 04 Dec 2019, 21:19
by rednoah
The destination path is entirely defined by your custom format, or {plex} by default.

You can use bits and pieces:

Code: Select all

{plex.tail}
:arrow: viewtopic.php?t=4116

e.g.

Code: Select all

Movies {if (hd =~ /UHD/) ' 4K'}{if (s3d) ' 3D'}/{plex.tail}

Re: AMC change I'm looking to make

Posted: 04 Dec 2019, 23:49
by mikejandreau
I must be some kind of moron, because that's not working for me, either.

I tried:

Code: Select all

/usr/local/bin/filebot -rename Avengers\ Endgame\ \(2019\) --output "/Volumes/Super Storage/Video/To Be Processed" --action move --conflict skip -non-strict --log-file amc.log --def "movieFormat={fn =~ /2160p|4K|4k|UHD/ ? 'Movies 4K' : fn =~ /3D|3d|HSBS|3dhsbs|H-SBS|3dhou|H-OU/ ? 'Movies 3D' : 'Movies'}/{plex}" clean=y unsorted=y music=y artwork=y excludeList=".excludes"
and:

Code: Select all

/usr/local/bin/filebot -rename Avengers\ Endgame\ \(2019\) --output "/Volumes/Super Storage/Video/To Be Processed" --action move --conflict skip -non-strict --log-file amc.log --def "movieFormat={fn =~ /2160p|4K|4k|UHD/ ? 'Movies 4K' : fn =~ /3D|3d|HSBS|3dhsbs|H-SBS|3dhou|H-OU/ ? 'Movies 3D' : 'Movies'}/{plex.name}/{plex.name}" clean=y unsorted=y music=y artwork=y excludeList=".excludes"
Both ended up moving the file from /Volumes/Super Storage/Video (where they download to) to /Volumes/Super Storage/Video/To Be Processed.

I thought, based on how I'm reading the {plex} variable, my test file should have gotten moved to /Volumes/Super Storage/Video/To Be Processed/Movies 4k (given that it's a 4k movie).

And just for good measure, I tried simplifying the IF bit, based on your comment, with:

Code: Select all

/usr/local/bin/filebot -rename Avengers\ Endgame\ \(2019\) --output "/Volumes/Super Storage/Video/To Be Processed" --action move --conflict skip -non-strict --log-file amc.log --def "movieFormat=Movies {if (hd =~ /3D|3d|HSBS|3dhsbs|H-SBS|3dhou|H-OU/) ' 4K'}{if (s3d) ' 3D'}/{plex.tail}" clean=y unsorted=y music=y artwork=y excludeList=".excludes"
Same result. Movie ended up in /Volumes/Super Storage/Video/To Be Processed/

What obvious thing am I missing?

Re: AMC change I'm looking to make

Posted: 05 Dec 2019, 05:53
by rednoah
What does the console output say? (without console output, we can't see what's going on, and so we can't reason about it)


:!: You have switched from -script fn:amc calls to -rename calls. --def options such as --def movieFormat are exclusive to the amc script therefore have no effect if you switch to simple -rename calls.


:!: :!: :!: You need a systematic approach to problem solving. Make one single atomic change. Test. See what changed. Continue until you understand what's going on. If you make many changes, you will not be able to isolate what each change actually does, and end up randomly trying things getting nowhere, which is entirely unnecessary self-inflicted pain. ;)

Re: AMC change I'm looking to make

Posted: 05 Dec 2019, 12:32
by mikejandreau
Console shows success, it moved the file, just not to the right location:

Code: Select all

Alfred@Pennyworth Video % /usr/local/bin/filebot -rename Avengers\ Endgame\ \(2019\) --output "/Volumes/Super Storage/Video/To Be Processed" --action move --conflict skip -non-strict --log-file amc.log --def "movieFormat=Movies {if (hd =~ /3D|3d|HSBS|3dhsbs|H-SBS|3dhou|H-OU/) ' 4K'}{if (s3d) ' 3D'}/{plex.tail}" clean=y unsorted=y music=y artwork=y excludeList=".excludes" ut_dir="" ut_kind="multi" ut_title="" ut_label=""
Locking /Users/Alfred/.filebot/logs/amc.log
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/Volumes/Super Storage/Video/Avengers Endgame (2019)/Avengers Endgame (2019) - UHD.mkv]
[MOVE] from [/Volumes/Super Storage/Video/Avengers Endgame (2019)/Avengers Endgame (2019) - UHD.mkv] to [/Volumes/Super Storage/Video/To Be Processed/Avengers Endgame (2019).mkv]
Processed 1 files
Rename movies using [TheMovieDB]
I moved to --rename because I'm running it from command line to test. I was under the impression I couldn't run -script fn:amc from the command line, but I'll try that and see where I get from there.
:!: :!: :!: You need a systematic approach to problem solving. Make one single atomic change. Test. See what changed. Continue until you understand what's going on. If you make many changes, you will not be able to isolate what each change actually does, and end up randomly trying things getting nowhere, which is entirely unnecessary self-inflicted pain. ;)
This is what I've been doing all along, but the result is always the same, no matter how I change the CLI command. The file ends up in the wrong place.

Re: AMC change I'm looking to make

Posted: 05 Dec 2019, 12:35
by mikejandreau
Okay, if I switch to -script fn:amc, I get the right Plex structure.

But my 4k movie is moving into the regular Movies folder, so I think I need to rename that test file so Filebot knows it's 4k. Or maybe my if else isn't working right. I'll keep poking at it.

Re: AMC change I'm looking to make

Posted: 05 Dec 2019, 12:47
by rednoah
Step 1: A -rename call without custom format, using default naming:

Code: Select all

$ filebot -rename *.mkv -non-strict --db TheMovieDB --action TEST
Rename movies using [TheMovieDB]
Auto-detect movie from context: [Avengers Endgame (2019) - UHD.mkv]
[TEST] from [Avengers Endgame (2019) - UHD.mkv] to [Avengers Endgame (2019).mkv]
Processed 1 files
:idea: We confirm that filebot -rename works for this file.

:!: The amc script does not use default naming, and defaults to {plex} if not specified otherwise.



Step 2: A -rename call with a simple fail-safe custom format, {plex} in this case:

Code: Select all

$ filebot -rename *.mkv -non-strict --db TheMovieDB --action TEST --format {plex}
Rename movies using [TheMovieDB]
Auto-detect movie from context: [Avengers Endgame (2019) - UHD.mkv]
[TEST] from [Avengers Endgame (2019) - UHD.mkv] to [Movies/Avengers - Endgame (2019)/Avengers - Endgame (2019).mkv]
Processed 1 files
:idea: We confirm that --format works.
:idea: We confirm that {plex} yields the desired Plex file and folder structure.



Step 3: A -rename call with our desired custom format:

Code: Select all

$ filebot -rename *.mkv -non-strict --db TheMovieDB --action TEST --format "Movies {if (hd =~ /UHD/) ' 4K'}{if (s3d) ' 3D'}/{plex.tail}"
Rename movies using [TheMovieDB]
Auto-detect movie from context: [Avengers Endgame (2019) - UHD.mkv]
[TEST] from [Avengers Endgame (2019) - UHD.mkv] to [Movies 4K/Avengers - Endgame (2019)/Avengers - Endgame (2019).mkv]
Processed 1 files
:idea: We confirm that our custom format works as expected.



:!: -rename uses the --format option, and does not support different custom formats for different types of media. The amc script has it's own set of --def *Format options for different types of media, and thus does not use the --format option at all.



:!: The {vf} binding is based on the video resolution only, and thus independent of file name:

Code: Select all

$ filebot -mediainfo *.mkv --format "{f}: {resolution} => {vf}"
a.mkv: 3840x2160 => 2160p
:idea: We rename the file to a.mkv and confirm that {vf} works as expected based on video resolution.

Re: AMC change I'm looking to make

Posted: 05 Dec 2019, 13:11
by mikejandreau
Thanks. I think I've got something that's working now.

Now to download my first 4k movie and see if this all works (or test from command line if it doesn't!)

Re: AMC change I'm looking to make

Posted: 05 Dec 2019, 13:44
by mikejandreau
All good now, thanks for the help.

My 4k movies are going to the right place with the right formatting and artwork. My other movies and TV shows are going to the right place for Handbrake to process them to change their container and reduce filesize.

Thanks again for the help!

Re: AMC change I'm looking to make

Posted: 13 Jul 2022, 22:40
by rednoah