Videos disappear from Tvheadend after editing
Added by Karl P almost 3 years ago
I'm not sure if anyone else has come across this (couldn't find anything from a quick search).
When I record programs on channels that have commercials, I always edit out the adverts before I watch the film/show. Tvheadend is on a server on my LAN. I use VideoReDo to do the editing and the edited file is saved to my local PC.
When I copy/move the edited file back to the server, it sometimes disappears from the Tvh GUI and shows in the 'Removed Recordings' section as 'File Missing'. The file is obviously still there and can be played outside of Tvh but can't be seen for some reason by Tvh. I have both SMB and NFS on my LAN and I've noticed that if I copy back to the SMB share it's pretty much guaranteed to disappear from Tvh, but it's 50:50 if I use NFS.
It's only a mild irritation but it would be really nice if:
- Tvh wasn't so aggressive in removing files or
- There was a way to force Tvh to recheck the files in the Recording folder and put back ones that do clearly exist
Replies (10)
RE: Videos disappear from Tvheadend after editing - Added by Dave Pickles almost 3 years ago
Likely an ownership or file permissions problem. The recording files need to be accessible (at least readable) by user hts.
Restarting TVH should restore the recordings.
RE: Videos disappear from Tvheadend after editing - Added by Karl P almost 3 years ago
Thanks, but there are no file permission problems. I have read/write access via both SMB and NFS. Forgot to mention that Tvheadend is running in a docker container on an Unraid server. I've never not been able to read or write to the recording share. It seems (to me) that maybe Tvh checks the files every x seconds and if I happen to do the copy operation at the wrong moment Tvh says 'file incomplete - remove'.
Screenshot from 2022-01-15 18-29-56.png (27.4 KB) Screenshot from 2022-01-15 18-29-56.png | Tvheadend file/folder permissions |
RE: Videos disappear from Tvheadend after editing - Added by Hiro Protagonist almost 3 years ago
You need to use the 'filemoved' api. Here's a small example script:
#!/bin/bash SRC=/path/to/original/file DST=/path/to/new/file TVH_USER=admin # Valid TVH username TVH_PASS=secret # Password for TVH_USER TVH_IP="127.0.0.1" # IP address of TVH server TVH_PORT="9981" API_ENDPOINT="/api/dvr/entry/filemoved" curl -s --user "${TVH_USER}:${TVH_PASS}" "http://${TVH_IP}:${TVH_PORT}${API_ENDPOINT}" --digest \ --data-urlencode "src=${SRC}" \ --data-urlencode "dst=${DST}"
Note the above uses digest authentication - if TVHUSER is using plain authentication, the curl line should be changed to:
curl -s "http://${TVH_USER}:${TVH_PASS}@${TVH_IP}:${TVH_PORT}${API_ENDPOINT}" \ --data-urlencode "src=${SRC}" \ --data-urlencode "dst=${DST}"
When you want to move or edit a file, create the destination file first [by copying or saving edited version], call the filemoved API, and only then delete the original file.
RE: Videos disappear from Tvheadend after editing - Added by Karl P almost 3 years ago
Thanks for the script, though it doesn't seem to work. I presume this is supposed to be run from the client and not the server? All I get is some HTML output in the terminal when I run it, and it seems more of a bodge workaround than correcting something that, to my mind, is is more of a bug.
This is the edited script for something that was recorded last night. Tvh is available for all users on the LAN (*) so I removed the user/pass sections:
#!/bin/bash
SRC="/media/infi/nfs/Recordings/The Good Doctor S02E10 - Quarantine Part One - 2022-01-16 21-00.ts"
DST="/home/infi/Videos/The Good Doctor S02E10 - Quarantine Part One - 2022-01-16 21-00.ts"
TVH_IP="192.168.0.20" # IP address of TVH server
TVH_PORT="9981"
API_ENDPOINT="/api/dvr/entry/filemoved"
curl -s "http://${TVH_IP}:${TVH_PORT}${API_ENDPOINT}" \
--data-urlencode "src=${SRC}" \
--data-urlencode "dst=${DST}"
This is the terminal output:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD><BODY>
<H1>404 Not Found</H1>
</BODY></HTML>
I tried both authentication types as Tvh is set to allow plain and digest.
As mentioned, I only get intermittent failures when using NFS. Today for instance I've edited two TV programs and copied them back to the server without issue; they still show in the completed recording section. It's only seemingly randomly that Tvh decides the file has gone missing when I'm copying it back. The script would also add an extra layer of effort every time I edit my files, which is most days, as I'd also have to edit the script every time instead of just cut/pasting.
RE: Videos disappear from Tvheadend after editing - Added by Hiro Protagonist almost 3 years ago
Karl P wrote:
I presume this is supposed to be run from the client and not the server?
Doesn't matter. It needs to be run somewhere that has access to the address TVH_IP
This is the edited script for something that was recorded last night. Tvh is available for all users on the LAN (*) so I removed the user/pass sections:
API access is restricted to users with admin access, which the default user doesn't have [unless you've changed that]. You need to give a user & password for a user with admin rights.
The script would also add an extra layer of effort every time I edit my files, which is most days, as I'd also have to edit the script every time instead of just cut/pasting.
A simple matter to modify the script to take the source & dest paths as parameters.
RE: Videos disappear from Tvheadend after editing - Added by Karl P almost 3 years ago
Thanks again.
Doesn't matter. It needs to be run somewhere that has access to the address TVH_IP
Must be some other issue with the script then as all PCs on my LAN have access to Tvh.
API access is restricted to users with admin access, which the default user doesn't have [unless you've changed that]. You need to give a user & password for a user with admin rights.
The default user does have admin access.
A simple matter to modify the script to take the source & dest paths as parameters.
I'm sure that's true for people who are better at bash scripting than me.
RE: Videos disappear from Tvheadend after editing - Added by Hiro Protagonist almost 3 years ago
Suggest you remove the '-s' parameter from the curl line, & try again. Post the output here.
RE: Videos disappear from Tvheadend after editing - Added by Karl P almost 3 years ago
Thanks, but even with the 'silent' switch removed all I'm getting is the HTML output from my previous post in the terminal.
RE: Videos disappear from Tvheadend after editing - Added by Hiro Protagonist almost 3 years ago
Curious that you're getting "404 Not Found".
API documentation can be found here: https://github.com/dave-p/TVH-API-docs/wiki/API-Description
Note the mention of '--http_root' are you running TVH with that parameter by any chance?
RE: Videos disappear from Tvheadend after editing - Added by Karl P almost 3 years ago
Looking at the Unraid server itself the only user is root* so, while I can't see that particular command in as part of the Tvheadend docker container startup, it would by default be running as root.
I have tried amending the script in two places to no avail:
API_ENDPOINT="/myHttpRoot/api/dvr/entry/filemoved"
curl "http://${TVH_IP}:${TVH_PORT}/myHttpRoot/${API_ENDPOINT}" \
Both options still result in the same HTML output.
*The system runs as root; there are however SMB & NFS users to enable access to the shares.