hd binding not evaluating to SD, HD or UHD on some files

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
howdymilsap
Posts: 34
Joined: 14 Jul 2018, 17:22

hd binding not evaluating to SD, HD or UHD on some files

Post by howdymilsap » 25 Apr 2019, 00:50

I have a naming scheme based on the {plex} binding that uses {plex.tail}. I do some processing to determine if a file is 4K or not and then put those files into a folder structure like this:
4K\
..\movies
..\tv
movies\
tv\
this works well when using {plex.tail} as I am able to prefix the file path with '4K\tv' or '4K\movies' where necessary.

Sometimes, however, evaluating {hd} does not give me UHD or SD or HD, it returns NULL or maybe an empty string. I don't even know how to test for that it is returning or how to properly handle this possibility. My code that appends the file path then gets messed up and I wind up with access denied errors because the PATH I have built doesn't actually exist.

Here is a simplified version of my filebot script:

Code: Select all

filebot -script fn:amc --def ut_dir="$PWD" --output /mnt/unionfs --action move -non-strict --order Airdate --conflict override  --lang en --def ut_label=tv clean=y deleteAfterExtract=y "seriesFormat={hd =~ /UHD/ ? '4K/tv' : 'tv'}/{plex.tail} [{allOf{hd}{vf}{hdr}{bitdepth >= 10 ? {bitdepth}+'bit' : null}{vc}{af}{s3d}{source}{tags}{-group}  join ', '}" 
Here is an example of the issue:
Run script [fn:amc] at [Wed Apr 24 19:41:53 CDT 2019]
Parameter: ut_dir = /mnt/unionfs/TV Shows/Better Call Saul/Season 04
Parameter: ut_label = tv
Parameter: clean = y
Parameter: deleteAfterExtract = y
Parameter: seriesFormat = {hd =~ /UHD/ ? '4K/tv' : 'tv'}/{plex.tail} [{allOf{hd}{vf}{hdr}{bitdepth >= 10 ? {bitdepth}+'bit' : null}{vc}{af}{s3d}{source}{tags}{-group} join ', '}
Ignore hidden: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/.xattr
Ignore orphaned subtitles: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E01 - Smoke.eng.srt
Ignore orphaned subtitles: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E02 - Breathe.eng.srt
Ignore orphaned subtitles: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E03 - Something Beautiful.eng.srt
Ignore orphaned subtitles: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E04 - Talk.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E05 - Quite a Ride.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E05 - Quite a Ride.mkv
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E06 - Piñata.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E06 - Piñata.mkv
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E07 - Something Stupid.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E07 - Something Stupid.mkv
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E08 - Coushatta.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E08 - Coushatta.mkv
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E09 - Wiedersehen.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E09 - Wiedersehen.mkv
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E10 - Winner.eng.srt
Input: /mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E10 - Winner.mkv
Group: [Series:true] => [Better Call Saul - S04E05 - Quite a Ride.eng.srt, Better Call Saul - S04E05 - Quite a Ride.mkv, Better Call Saul - S04E06 - Piñata.eng.srt, Better Call Saul - S04E06 - Piñata.mkv, Better Call Saul - S04E07 - Something Stupid.eng.srt, Better Call Saul - S04E07 - Something Stupid.mkv, Better Call Saul - S04E08 - Coushatta.eng.srt, Better Call Saul - S04E08 - Coushatta.mkv, Better Call Saul - S04E09 - Wiedersehen.eng.srt, Better Call Saul - S04E09 - Wiedersehen.mkv, Better Call Saul - S04E10 - Winner.eng.srt, Better Call Saul - S04E10 - Winner.mkv]
Rename episodes using [TheTVDB]
Auto-detected query: [Better Call Saul]
Fetching episode data for [Better Call Saul]
Auto-detected query: [Better Call Saul]
Fetching episode data for [Better Call Saul]
[MOVE] from [/mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E05 - Quite a Ride.mkv] to [/Better Call Saul/Season 04/Better Call Saul - S04E05 - Quite a Ride [6ch.mkv]
[MOVE] Failure: java.nio.file.AccessDeniedException: /Better Call Saul
Processed 0 files
AccessDeniedException: /Better Call Saul

Finished without processing any files
Abort (×_×)
Here is the same code working on another file in that same folder
Fetching episode data for [Better Call Saul]
[MOVE] from [/mnt/unionfs/TV Shows/Better Call Saul/Season 04/Better Call Saul - S04E06 - Piñata.mkv] to [/mnt/unionfs/4K/tv/Better Call Saul/Season 04/Better Call Saul - S04E06 - Piñata [UHD, 2160p, x264, 6ch.mkv]
Finally, here is

Code: Select all

filebot -mediainfo *.*
output on the files in that folder showing that something is wrong with the UHD/HD/SD detection
Better Call Saul - S04E01 - Smoke.eng [3840x2160 x264 5.1 EAC3 0:47 29.4 Mbps]
Better Call Saul - S04E02 - Breathe.eng [3840x2160 x264 5.1 EAC3 0:47 29.4 Mbps]
Better Call Saul - S04E03 - Something Beautiful.eng [1920x1080 x264 5.1 EAC3 0:41 10.6 Mbps]
Better Call Saul - S04E04 - Talk.eng [3840x2160 x264 5.1 EAC3 0:47 29.4 Mbps]
Better Call Saul - S04E05 - Quite a Ride.eng [ 5.1 EAC3 3:01 0.6 Mbps]
Better Call Saul - S04E05 - Quite a Ride [ 5.1 EAC3 3:01 0.6 Mbps]

Better Call Saul - S04E06 - Piñata.eng [3840x2160 x264 5.1 EAC3 0:47 29.4 Mbps]
Better Call Saul - S04E06 - Piñata [3840x2160 x264 5.1 EAC3 0:47 29.4 Mbps]
Better Call Saul - S04E07 - Something Stupid.eng [1920x1080 x264 5.1 EAC3 0:41 10.6 Mbps]
Better Call Saul - S04E07 - Something Stupid [1920x1080 x264 5.1 EAC3 0:41 10.6 Mbps]
Better Call Saul - S04E08 - Coushatta.eng [1920x1080 x264 5.1 EAC3 ]
Better Call Saul - S04E08 - Coushatta [1920x1080 x264 5.1 EAC3 ]
Better Call Saul - S04E09 - Wiedersehen.eng [1920x1080 x264 5.1 EAC3 0:55 6.8 Mbps]
Better Call Saul - S04E09 - Wiedersehen [1920x1080 x264 5.1 EAC3 0:55 6.8 Mbps]
Better Call Saul - S04E10 - Winner.eng [1920x1080 x264 5.1 EAC3 1:00 6.4 Mbps]
Better Call Saul - S04E10 - Winner [1920x1080 x264 5.1 EAC3 1:00 6.4 Mbps]
Here is fn:sysinfo output
filebot -script fn:sysinfo

FileBot 4.8.5 (r6224)
JNA Native: 5.2.2
MediaInfo: 18.12
7-Zip-JBinding: 9.20
Chromaprint: java.io.IOException: Cannot run program "/usr/share/filebot/lib/fpcalc": error=13, Permission denied
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2019-04-09 (r559)
Groovy: 2.5.6
JRE: OpenJDK Runtime Environment 11
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 8 Core / 15 GB Max Memory / 40 MB Used Memory
OS: Linux (amd64)
HW: Linux xxxxxxxxxxxx 5.0.8-xanmod5 #1.190417 SMP PREEMPT Wed Apr 17 10:55:59 -03 2019 x86_64 x86_64 x86_64 GNU/Linux
DATA: /home/xxxxxxxxx/.filebot
Package: DEB
License: FileBot License T1015 (Valid-Until: 2019-08-04)
Done ヾ(@⌒ー⌒@)ノ

User avatar
rednoah
The Source
Posts: 16270
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: hd binding not evaluating to SD, HD or UHD on some files

Post by rednoah » 25 Apr 2019, 01:52

Can you check the MediaInfo specs (video stream) for that one and post it here?
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 777
Joined: 15 May 2014, 16:17

Re: hd binding not evaluating to SD, HD or UHD on some files

Post by kim » 25 Apr 2019, 03:42

Code: Select all

filebot -script fn:amc --def ut_dir="$PWD" --output /mnt/unionfs --action move -non-strict --order Airdate --conflict override  --lang en --def ut_label=tv clean=y deleteAfterExtract=y "seriesFormat={hd =~ /UHD/ ? '4K/tv' : 'tv'}/{plex.tail} [{allOf{hd}{vf}{hdr}{bitdepth >= 10 ? {bitdepth}+'bit' : null}{vc}{af}{s3d}{source}{tags}{-group}  join ', '}" 
Looks like a code problem

change

Code: Select all

"seriesFormat={hd =~ /UHD/ ? '4K/tv' : 'tv'}/{plex.tail}[{allOf{hd}{vf}{hdr}{bitdepth >= 10 ? {bitdepth}+'bit' : null}{vc}{af}{s3d}{source}{tags}{-group}  join ', '}"
to

Code: Select all

seriesFormat="{hd =~ /UHD/ ? '4K/tv' : 'tv'}{'/'+plex.tail}{' '+(allOf{hd}{vf}{hdr}{bitdepth >= 10 ? bitdepth+'bit' : null}{vc}{af}{s3d}{source}{tags}{'-'+group}).join(', ')}"
or

Code: Select all

seriesFormat="{hd =~ /UHD/ ? '4K/tv' : 'tv'}{'/'+plex.tail}{' ['+(allOf{hd}{vf}{hdr}{bitdepth >= 10 ? bitdepth+'bit' : null}{vc}{af}{s3d}{source}{tags.join(', ')}).join(', ')+']'}{'-'+group}"

howdymilsap
Posts: 34
Joined: 14 Jul 2018, 17:22

Re: hd binding not evaluating to SD, HD or UHD on some files

Post by howdymilsap » 25 Apr 2019, 04:48

@kim Thanks for the code refactoring. Those changes work better, but I still have the issue that I am encountering.

@rednoah, I checked the file that is having a problem and it does not have a recognizable video stream in ffprobe or mediainfo. So that is clearly the problem. So now I want to figure a way to incorporate a check ensuring a video stream is present before processing with filebot.

btw, the ffprobe command I used to check for a video stream is

Code: Select all

ffprobe -i INPUT -show_streams -select_streams v -loglevel error
Thanks to both of you for taking a look at this issue.

User avatar
rednoah
The Source
Posts: 16270
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: hd binding not evaluating to SD, HD or UHD on some files

Post by rednoah » 25 Apr 2019, 05:49

1.
You can use this command to find all files with a broken video stream:

Code: Select all

filebot -mediainfo -r . --filter '!allOf{width}{height}'
You can then use this command to move all broken files somewhere else:

Code: Select all

filebot -mediainfo -r . --filter '!allOf{width}{height}' -exec mv -v {f} ~/BrokenFiles

2.
You could possibly incorporate that logic directly into the amc script, but I'm actually not sure if the amc script respects the --file-filter option (--filter is used for something else in the amc script, so can't use that) because the amc script does it's own thing when it comes to collecting input files:

Code: Select all

--file-filter '!allOf{width}{height}'
:!: UNTESTED might not work
:idea: Please read the FAQ and How to Request Help.

Post Reply