[bash] Filebot/ffmpeg/rclone script order of operations help

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
synthetiq
Donor
Posts: 5
Joined: 17 Sep 2017, 02:26

[bash] Filebot/ffmpeg/rclone script order of operations help

Post by synthetiq »

Hello all, I'm trying to follow the rules for how to request help, so pardon if I do not get it exact.

TL;DR: I'm 95% there in trying to get someone elses bash script working to have Filebot move & rename media, then use ffmpeg to remux the file and insert comment, and finally rclone move. The file is being moved before the ffmpeg part is able to kick off. Order of operations?

Output of filebot -script fn:sysinfo: https://pastebin.com/sQ2YVtK4

I'm using the scripts and advice from this archived reddit post: https://www.reddit.com/r/PleX/comments/ ... n/d87lsc6/

This is my slightly altered filebot_process.sh: https://pastebin.com/6hdb0G3a

Right now I am able to input argument: filebot_process.sh /home/me/dir1 /home/me/dir2

It will kicked-off the script, detect the media, move&rename accordingly to /home/me/dir2, but then when it gets to the remux_video part I can see the output call the remux_video.sh, but the actual console output fails.

This is the actual output I see on console:

Code: Select all

~$ filebot_process.sh /home/me/dir1 /home/me/dir2
Locking /home/me/log/Proc.log
Run script [fn:amc] at [Sun Sep 17 12:58:58 EDT 2017]
Parameter: exec = /usr/local/bin/remux_video.sh '{file}' 'TEST-COMMENT'
Parameter: movieFormat = Movies/{n} ({y}) {vf}/{n} ({y}) [{vf}]{' CD'+pi}{'.'+lang}
Parameter: seriesFormat = TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n} {episode.special ? 'S00E'+special.pad(2) : s00e00} {vf}{'.'+lang}
Parameter: excludeList = /home/me/dir1/Proc.txt
Argument[0]: /home/me/dir1
Use excludes: /home/me/dir1/Proc.txt
Input: /home/me/dir1/MY_Movie-example-1990-720p.mp4
Group: [mov:my movie 1990] => [MY_Movie-example-1990-720p.mp4]
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/home/me/dir1/MY_Movie-example-1990-720p.mp4]
[COPY] From [/home/me/dir1/MY_Movie-example-1990-720p.mp4] to [/home/me/dir2/Movies/My Movie (1990) 720p/My Movie (1990) [720p].mp4]
Processed 1 files
Execute: /usr/local/bin/remux_video.sh '/home/me/dir2/Movies/My Movie (1990) 720p/My Movie (1990) [720p].mp4' 'TEST-COMMENT'
sh: 1: /usr/local/bin/remux_video.sh: not found
Done ヾ(@⌒ー⌒@)ノ
Files processed
The problem I can't solve is the line sh: 1: /usr/local/bin/remux_video.sh: not found
I'm fairly certain that the script is moving the renamed file from /home/me/dir2/ into /home/me/dir3/ before the Execute remux_video.sh command, so it's not seeing the file.

I can manually run the remux pointing to dir3 and it works.

I hope I was able to clearly state the issue.

Thank you for any help!
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by rednoah »

What does this command say?

Code: Select all

file /usr/local/bin/remux_video.sh
Usually, one would create the remux_video.sh script somewhere and then symlink it to /usr/local/bin so that it can be called as a command without specifying the full path.
:idea: Please read the FAQ and How to Request Help.
synthetiq
Donor
Posts: 5
Joined: 17 Sep 2017, 02:26

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by synthetiq »

rednoah wrote: 18 Sep 2017, 03:06 What does this command say?

Code: Select all

file /usr/local/bin/remux_video.sh
Usually, one would create the remux_video.sh script somewhere and then symlink it to /usr/local/bin so that it can be called as a command without specifying the full path.
Output:

Code: Select all

~$ file /usr/local/bin/remux_video.sh
/usr/local/bin/remux_video.sh: Bourne-Again shell script, ASCII text executable
~$
~$ remux_video.sh
~$
I placed the script in the /usr/local/bin folder without symlink. Good to know it's not best practice, but I believe it's working as I am able to manually execute and it works fine. Concur?

Code: Select all

/usr/local/bin/remux_video.sh '/home/me/dir2/Movies/My movie (1990) [720p].mp4' 'TEST-COMMENT'
and

Code: Select all

remux_video.sh '/home/me/dir2/Movies/My movie (1990) [720p].mp4' 'TEST-COMMENT'
work.

Thank you for your time
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by rednoah »

It should work, but it doesn't:

Code: Select all

sh: 1: /usr/local/bin/remux_video.sh: not found
:idea: At this point it's time for trial and error. Try things that can't not work, and then work your way up.

e.g.

Code: Select all

--def exec="echo Hello"

Code: Select all

--def exec="echo {quote file}"

Code: Select all

--def exec="file {quote file}"

Code: Select all

--def exec="myscript-that-just-calls-echo {quote file}"
...


:idea: Note that if you're running the script as a different user in a different environment then the one you're testing with, then permissions and environment variables may be different and make things not work or work differently.
:idea: Please read the FAQ and How to Request Help.
synthetiq
Donor
Posts: 5
Joined: 17 Sep 2017, 02:26

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by synthetiq »

rednoah wrote: 19 Sep 2017, 01:44 :idea: Note that if you're running the script as a different user in a different environment then the one you're testing with, then permissions and environment variables may be different and make things not work or work differently.
Thanks for this point. I just moved everything to /home/me/ and I believe I'm making progress:

Code: Select all

sh: 1: /home/me/remux_video.sh: Permission denied
Instead of "Not found". I then just wanted to make sure it's seeing the file, so I changed:

Code: Select all

EXEC_EACH="/home/me/remux_video.sh '{file}' '$METADATA_COMMENT'"
to
EXEC_EACH="echo TEST '{file}'"
And I'm at least getting the expected output:

Code: Select all

Execute: echo TEST '/home/me/dir2/Movies/My movie (1990) 720p/My movie (1990) [720p].mp4'
TEST /home/me/dir2/Movies/My movie (1990) 720p/My movie (1990) [720p].mp4
So based on your advice, I can infer that the script is definitely calling remux_video.sh for the Movie file in /home/me/dir2/ as expected, but the "Permission denied" issue must be due to the $LOCK_FILE part in the filebot_process.sh? This is where my scripting crumbles. Not sure how to handle the order of operations for the lock & hand-off to remux_video.sh

Thanks again for your time.
synthetiq
Donor
Posts: 5
Joined: 17 Sep 2017, 02:26

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by synthetiq »

Before I give up on this project: Are there any special rules concerning permissions and directories being that FileBot was installed via SNAP in Ubuntu? snap install filebot
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by rednoah »

Nothing specific to FileBot, but all SNAP application are confined which means then can't access your system. By default, FileBot will have permission to your $HOME folder an nothing else. You can give FileBot permission to access /media by connecting the appropriate SNAP plug.

If you want FileBot to run without confinement, then you can install with --devmode which disables all sandbox limitations.

If you want FileBot to call other tools, or custom bash scripts, then you'll probably run into a roadblock, because in the sandboxed environment, these custom tools probably won't be available.
:idea: Please read the FAQ and How to Request Help.
synthetiq
Donor
Posts: 5
Joined: 17 Sep 2017, 02:26

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by synthetiq »

That definitely sounds like my problem, then. Considering the bash script above is calling FileBot with --def exec="$EXEC_EACH"

And EXEC_EACH="/usr/local/bin/remux_video.sh '{file}' '$METADATA_COMMENT'"

And all remux_video.sh is doing is calling ffmpeg which is != FileBot.

I'll Google how to do --devmode -- but this should allow FileBot to call a non-SNAP plugin, like ffmpeg?
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [bash] Filebot/ffmpeg/rclone script order of operations help

Post by rednoah »

I have no idea. Image a SNAP kinda like a virtual machine. It's gonna run fine by itself, but if you want to call the host from inside the virtual machine then you're gonna hit a wall.

Not sure if SNAP has option that allow you to run applications the traditional way without any kind of virtualization or containerization.
:idea: Please read the FAQ and How to Request Help.
Post Reply