Bug: Notify kodi/plex/etc skipped on custom action

All your suggestions, requests and ideas for future development
Post Reply
LightningRider
Posts: 10
Joined: 08 Aug 2019, 09:40

Bug: Notify kodi/plex/etc skipped on custom action

Post by LightningRider »

Using the amc script with options as follows

Code: Select all

filebot.sh -script fn:amc --output "/path/to/output" --log-file amc.log --action /bin/mv -non-strict "/path/to/input/" --def seriesFormat="/path/to/output/{n}/{'Season '+s}/{s00e00} - {t}" movieFormat="/path/to/output/{n}.{y}.{vf}" kodi="1.2.3.4:5678"
does not result in filebot sending the update video library command to my media box.

However, the following does work as expected:

Code: Select all

filebot.sh -script fn:amc --output "/path/to/output" --log-file amc.log --action copy -non-strict "/path/to/input/" --def seriesFormat="/path/to/output/{n}/{'Season '+s}/{s00e00} - {t}" movieFormat="/path/to/output/{n}.{y}.{vf}" kodi="1.2.3.4:5678"
As the only differences in the commands are the type of action being performed, I can only assume that the built in actions (in this case copy) set a flag if any files are processed to stop the media center being told to erroneously update it's library if no files were processed. Would it be possible to use the Exit Code of the custom action/script to determine if files were processed? As both windows and unix use 0 to indicate success this shouldn't be too hard. I haven't used java since Uni but a quick internet search yields the following code to check exit code:

Code: Select all

Process p = Runtime.getRuntime().exec("test.cmd");
p.waitFor();
System.out.println(p.exitValue());
amc.log snippets for both cases:

Code: Select all

[/bin/mv] from [/path/to/input/Formula.1.Drive.to.Survive.S01.1080p.WEB.X264-AMRAP[rartv]/Formula.1.Drive.to.Survive.S01E10.1080p.WEB.X264-AMRAP.mkv] to [/path/to/output/Formula 1 Drive to Survive/Season 1/S01E10 - Crossing the Line.mkv]
Processed 20 files
Done ヾ(@⌒ー⌒@)ノ

Code: Select all

[COPY] from [/path/to/input/New.Amsterdam.2018.S02E17.1080p.WEB.H264-METCON[rarbg]/New.Amsterdam.2018.S02E17.1080p.WEB.H264-METCON.mkv] to [/path/to/output/New Amsterdam (2018)/Season 2/S02E17 - Liftoff.mkv]
Processed 1 files
Notify Kodi: [host:1.2.3.4, port:5678]
POST: http://1.2.3.4:5678/jsonrpc {"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"FileBot finished processing 1 files","message":"\u2022 New.Amsterdam.2018.S02E17.1080p.WEB.H264-METCON[rarbg]","image":"https://app.filebot.net/icon.png"},"id":1}
POST: http://1.2.3.4:5678/jsonrpc {"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Bug: Notify kodi/plex/etc skipped on custom action

Post by rednoah »

FileBot will fail if your --action /command fails with a non-zero exit code:

Code: Select all

$ filebot -rename Alias.1x01.mp4 -non-strict --action $PWD/fail.sh
...
[fail.sh] from [Alias.1x01.mp4] to [Alias - 1x01 - Truth Be Told.mp4]
[fail.sh] Failure: net.filebot.ExecuteException: [fail.sh, Alias.1x01.mp4, Alias - 1x01 - Truth Be Told.mp4] failed (1)
...

Code: Select all

$ cat fail.sh
#!/bin/sh
exit 1

:idea: The history feature is however disabled for non-standard rename actions as they can't usually be reverted, except in this specific case. This seems to have unfortunate implications on the amc script which relies on the history.


:idea: Since you're already using custom commands, you could just do --def exec=update-kodi.sh instead.
:idea: Please read the FAQ and How to Request Help.
LightningRider
Posts: 10
Joined: 08 Aug 2019, 09:40

Re: Bug: Notify kodi/plex/etc skipped on custom action

Post by LightningRider »

rednoah wrote: 22 Mar 2020, 14:21 :idea: Since you're already using custom commands, you could just do --def exec=update-kodi.sh instead.
I had already added the curl command to the end of both my scripts, as I had noticed that kodi wasn't being notified but hadn't had time to investigate fully. It was only after checking the logs that I realised it was only when using the custom move script kodi wasn't being notified; and subsequently started this topic.

I've moved the curl command into the exec parameter of the amc script and this seems to satisfy my use case; as it appears to only be called once and only if any files are processed.

Thanks for the prompt response.
Post Reply