Project

General

Profile

Command after removal (Set previously recorded)

Added by M A Ben Amara about 6 years ago

Hi,

may someone has an idea howto add a command after removal for this user case.

my records gets moved after finished to another place (way is tvh record -> move to filebot -> move to Media folders for Plex)

now, when my records are done, they get moved ... tvheadend sets the state "file removed", so far correct, but now it would record the same show again.

my user case would be now to set something like "tvh_set_recorded %b" as command after removal.

is there any command line option therefore ?

thanks ahead.


Replies (14)

RE: Command after removal (Set previously recorded) - Added by Dave Pickles about 6 years ago

I don't think there is an API function which will do what you want.

Have you tried unticking "Clone scheduled entry on error" in Configuration->Recording ?

Alternatively you could replace the moved file with another of the same name but zero length.

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

thanks for the input.

as the record is not marked as failed i guess untick that will help.

i ll try the 0 byte file solution, good idea ;)

thanks again

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

well, seems that also doesnt work cause the trigger "after removal" is not triggered when i move the record away only ...

also a onliner /mv .... ; /touch ... doesnt work

well, have to check for other solution, needs probably a script to run instead direct commands.

thanks anyway

RE: Command after removal (Set previously recorded) - Added by Joe User about 6 years ago

With inotify, tvheadend will see the "moved" file as being deleted and consider it removed. You could try doing a copy and then truncate the original file to 0.

There could be other options also... Exactly how do you move the files and where (same machine???).

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

Hi,

yes, i move the files by command on the same mashine

see attachement.

the 2nd command is not triggered, i assume cause its NOT removed by TVH itself.

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

tried some more settings and its not working out, then tried a script but also with no luck, may someone an idea what could be wrong ?

script does nothing at all ...

i call it like this /config/scripts/move.sh "%f" "%b"
---
#!/bin/sh

pathname=$1 #Full path to recording
filename=$2 #Filename of recording

/mv "$pathname" "/Temp/$filename"
/touch "$pathname"

exit 0
fi
---

RE: Command after removal (Set previously recorded) - Added by Dave Pickles about 6 years ago

Remove forward slash before 'mv' and 'touch'

Delete 'fi' at end

Does directory '/Temp' exist; did you mean '/tmp/ ?

Is the file /config/scripts/move.sh executable?

RE: Command after removal (Set previously recorded) - Added by Joe User about 6 years ago

Did you try what I suggested???

Post-processor command:

/config/scripts/move.sh "%f" 

#!/bin/sh
/bin/cp "$1" /Temp
/usr/bin/truncate -s 0 "$1" 

(note you do not need to specify the target filename, the target directory is enough.)

You also did not explain what happens to the files after being put in /Temp.

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

ok, removed the slashes (was actually /bin/mv and /bin/touch)

and yes, should be exec and /Temp is there (when i use a move only command all is good)

post pro command is

/config/scripts/move.sh

script is now

---
#!/bin/sh

pathname=$1 #Full path to recording
filename=$2 #Basename of recording

mv "$pathname" "/Temp/$filename"
touch "$pathname"

exit 0
---

from shell to see move.sh mod 777 and /Temp is there ;)
---
root@AlsServer:/config/scripts$ ls l
total 4
-rwxrwxrwx 1 abc abc 175 Oct 4 12:35 move.sh
root@AlsServer:/config/scripts$ cd /Temp/
root@AlsServer:/Temp$
--

when i only use this command in postprcessing line that works.

/bin/mv "%f" "/Temp/%b"

but i need the 2nd command to create a 0 byte file.

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

Joe User wrote:

Did you try what I suggested???

Post-processor command:
[...]
[...]
(note you do not need to specify the target filename, the target directory is enough.)

You also did not explain what happens to the files after being put in /Temp.

did try it, same result, nothing happens.

in /Temp the file is passed to filebot, there it gets moved away in proper structure for Plex, 1st post.

my usercase is
/recordings (TVH) -> /Temp (Filebot - rename, categorize and move) -> /media/TV /media/HD /Media/UHD ... (Plex)

i almost think those scripts dont work in my linuxserver tvheadend docker ... nothing happens in scripts ...

thanks for the advices but im really stuck here and have no clue actually why theres no forward ...

RE: Command after removal (Set previously recorded) - Added by Joe User about 6 years ago

try adding the line

set -x

at the top of your script, which should print the commands with the expanded filename. Then if you look at the tvheadend log, all output from the script should be shown as an [ERROR].
You should also see a preceding line with

[   INFO] spawn: Executing "/config/scripts/move.sh" 

What version of tvheadend are you using?

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

theres nothing in log ...

2018-10-04 14:41:59.427 [ INFO] subscription: 0058: "DVR: Two and a Half Men" unsubscribing from "ProSieben HD"
2018-10-04 14:41:59.427 [ INFO] spawn: Executing "/config/scripts/move.sh"
2018-10-04 14:41:59.429 [ INFO] dvr: "Two and a Half Men" on "ProSieben HD": End of program: Completed OK

with this script layout

set -x
#!/bin/sh
/bin/cp "$1" /Temp
/usr/bin/truncate -s 0 "$1"

RE: Command after removal (Set previously recorded) - Added by Joe User about 6 years ago

Sorry, should have been more clear:

#!/bin/sh
set -x
/bin/cp "$1" /Temp
/usr/bin/truncate -s 0 "$1" 

RE: Command after removal (Set previously recorded) - Added by M A Ben Amara about 6 years ago

i gave up for now ;) actually a bit frustrated ;)

thanks anyway

    (1-14/14)