Project

General

Profile

How to refresh recording DB (move files after recording)

Added by Mo Hahn over 6 years ago

TV series and movie detection doesn't seem to work good here in Germany. And enabling "Make subdirectories per title" creates a subdirectory for every movie, which is what I do not want. So I have a huge list of recordings in one folder.

Now, I thought about creating a post-processing script, which looks for existing .ts files with similar names, create a folder and move them into the folder. Sure, I have to iterate over log files and have to update the filename, which has to be done for every recording event separately. This is not ideal, as there is not placeholder to tell post-recording script which log file has been created for actual file. But the most annoying this is, that there is no way to refresh the recording database in TVH except restarting TVH, which is not an option for me.

Are there any recommendations?


Replies (4)

RE: How to refresh recording DB (move files after recording) - Added by Robert Cameron over 6 years ago

You can do this by sending an HTTP post to Tvheadend with the original location of the file, and its new path:

http[s]://[user[:pass]@]1.2.3.4:5678/api/dvr/entry/filemoved?src=sourcefile.ts&dst=newfile.ts

user and pass are optional, depending upon your user/access restrictions in Tvheadend, 1.2.3.4 is the IP address of your Tvheadend server, 5678 is the HTTP (not HTSP) port for your server (9981, by default), sourcefile.ts is the URL-encoded absolute path of the original location of the file, and newfile.ts is the URL-encoded absolute path to the new location of the file.

If you want to script it, you can use curl, which works out well. Just ensure that you properly URL-encode the parameters, as malformed POSTs to Tvheadend tend to crash the server. (I know, as I've forgotten to do so on several occasions.)

RE: How to refresh recording DB (move files after recording) - Added by Lloyd Adams about 3 years ago

I have a script that moves files and uses the move files api. The database files get updated, but I need to restart tvheadend for the client to see the changes (restarting the client does not work), presumably because an in memory copy of the database needs to be updated. Is there anyway to achieve a database reload with an api call? I don't really want to be restarting the service at random times.

RE: How to refresh recording DB (move files after recording) - Added by Hiro Protagonist about 3 years ago

I run a post-processing script that calls api/dvr/entry/filemoved on every recording.

I don't have to re-start TVH to play moved recordings.

What is your script doing?

To safely move a file you need to:

Copy file to new location.
Call api/dvr/entry/filemoved
Delete old file.

RE: How to refresh recording DB (move files after recording) - Added by Lloyd Adams about 3 years ago

OK. Thanks for that response. As a result, I've been experimenting some more, and apologies, but its not the move causing me issues.

For some recordings, I'm amending the config_name. It seems that unless that is set to the default profile, Kodi will not put recordings into sub-folders (eg I have a folder of childrens programs, which then has sub folders by program. So if the recording is here childrens/clangers/clangers_S01E01, Kodi displays this as clangers/clangers_S01E01, and does not display it in childrens folder.)

    (1-4/4)