Bug #4020
API File moving not working: /api/dvr/entry/filemoved
100%
Description
I have been struggling to use the API for moving a file working and I am not sure if it is user or application error:
I get back either 400 Bad Request or nothing. Note for the following examples I have been escaping the special characters as per the instructions:
https://tvheadend.org/issues/3818
I have tried the following:
root@tvheadend:/home/hts/Test# ls -l * test1: total 92944 -rw-r--r-- 1 hts hts 95173684 Oct 12 12:26 test.ts test2: total 185888 -rw-r--r-- 1 hts hts 95173684 Oct 12 12:31 test1.ts -rw-r--r-- 1 hts hts 95173684 Oct 12 12:11 test.ts root@tvheadend:/home/hts/Test#
Allow Tvheadend to move the file:
http://tvheadend.internal:9981/api/dvr/entry/filemoved?src=/home/hts/Test/test2/test.ts&dst=/home/hts/Test/test1/test.ts
Copy the file manually and run the above URL - This gives no response from the server and Tvheadend still looks at the original file
Move the file manually and run the above URL - This gives a 400 error and Tvheadend moves the recording to failed (as the file no longer is there)
I have tried escaping the "/" (on all examples as I believe this is the correct way):
http://tvheadend.internal:9981/api/dvr/entry/filemoved?src=%2Fhome%2Fhts%2FTest%2Ftest2%2Ftest.ts&dst=%2Fhome%2Fhts%2FTest%2Ftest1%2Ftest.ts
I have tried just renaming the file (so not moving out of the directory) - This gives a 400 error
http://tvheadend.internal:9981/api/dvr/entry/filemoved?src=/home/hts/Test/test2/test.ts&dst=/home/hts/Test/test2/test1.ts
Tried putting relative paths (omitting /home/hts) - This gives a 400 error.
http://tvheadend.internal:9981/api/dvr/entry/filemoved?src=/Test/test2/test.ts&dst=/Test/test2/test1.ts
I have managed to crash the server using this as well (only once so far, so maybe not an issue):
2016-10-12 10:56:03.970 [ ALERT]:CRASH: Signal: 11 in PRG: /usr/bin/tvheadend (4.1-2270~g9e85ef2) [33cd24b5bbe785b6a94bb34e2335a9a1ca8323b7] CWD: / 2016-10-12 10:56:03.970 [ ALERT]:CRASH: Fault address (nil) (Address not mapped) 2016-10-12 10:56:03.970 [ ALERT]:CRASH: Loaded libraries: /usr/lib/x86_64-linux-gnu/libdvbcsa.so.1 /lib/x86_64-linux-gnu/libssl.so.1.0.0 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /lib/x86_64-linux-gnu/libz.so.1 /usr/lib/x86_64-linux-gnu/liburiparser.so.1 /usr/lib/x86_64-linux-gnu/libavahi-common.so.3 /usr/lib/x86_64-linux-gnu/libavahi-client.so.3 /lib/x86_64-linux-gnu/libdbus-1.so.3 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/librt.so.1 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libsystemd.so.0 /lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libselinux.so.1 /lib/x86_64-linux-gnu/liblzma.so.5 /lib/x86_64-linux-gnu/libgcrypt.so.20 /lib/x86_64-linux-gnu/libpcre.so.3 /lib/x86_64-linux-gnu/libgpg-error.so.0 /lib/x86_64-linux-gnu/libnss_compat.so.2 /lib/x86_64-linux-gnu/libnsl.so.1 /lib/x86_64-linux-gnu/libnss_nis.so.2 /lib/x86_64-linux-gnu/libnss_files.so.2 2016-10-12 10:56:03.970 [ ALERT]:CRASH: Register dump [23]: 000055b6f4587020000055b6f2920ee000007f1fc0051f100000000000000202000055b6f8745a4000007f1fc005888c00007f1fc0051f6c00000000ffffffff000000000000000000007f1fc005888c000055b6f8746110000055b6f87460f00000000000000000000000000000088c000000000000005400007f1fb97f11c800007f1ff06a0b5a000000000001028700000000000000330000000000000004000000000000000efffffffe7ffbba130000000000000000 2016-10-12 10:56:03.970 [ ALERT]:CRASH: STACKTRACE 2016-10-12 10:56:04.087 [ ALERT]:CRASH: ??:0 0x55b6f28f750d 2016-10-12 10:56:04.091 [ ALERT]:CRASH: ??:0 0x7f1ff126f3d0 2016-10-12 10:56:04.096 [ ALERT]:CRASH: ??:0 0x7f1ff06a0b5a 2016-10-12 10:56:04.100 [ ALERT]:CRASH: ??:0 0x55b6f2939bea 2016-10-12 10:56:04.105 [ ALERT]:CRASH: ??:0 0x55b6f2920f1f 2016-10-12 10:56:04.109 [ ALERT]:CRASH: ??:0 0x55b6f294baef 2016-10-12 10:56:04.113 [ ALERT]:CRASH: ??:0 0x55b6f28c9db2 2016-10-12 10:56:04.117 [ ALERT]:CRASH: ??:0 0x55b6f28cab2a 2016-10-12 10:56:04.121 [ ALERT]:CRASH: ??:0 0x55b6f28cad1d 2016-10-12 10:56:04.125 [ ALERT]:CRASH: ??:0 0x55b6f28ca362 2016-10-12 10:56:04.129 [ ALERT]:CRASH: ??:0 0x55b6f28cafd3 2016-10-12 10:56:04.133 [ ALERT]:CRASH: ??:0 0x55b6f28cb111 2016-10-12 10:56:04.137 [ ALERT]:CRASH: ??:0 0x55b6f28c37dd 2016-10-12 10:56:04.141 [ ALERT]:CRASH: ??:0 0x55b6f28bf135
My end goal is to move the recordings into a sub directories to split out the recordings between family groups:
RobsTV/<title>/<episode> KidsTV/<title>/<episode>
In Kodi this means that I am not presented with a list of titles that are for me or for the kids, we all have our own top level groups. This works if I do things manually, but would require a restart... I want to be able to kick this off after a recording.
History
Updated by Thomas Smith about 8 years ago
works here - procedure:
copy file (dont rename it)
use webbrowser and authenticate with admin-account (http://IP:9981)
use correct url to rename file via api (it is working only one time - on 2nd, you get an error)
in my opinion, you should also change the corresponding log-file in dvr/log-directory (for tvheadend-restart reasons)
Updated by Rob M about 8 years ago
Hello Thomas,
Excellent, I was expecting it to update the log file as well!
I've checked it and I can confirm that it is working (completely user error). The URL updates the internal information, and then I just have to update the log entry and it is good to go.
The other issue was that I was using Kodi to check the paths. The directory structure doesn't get updated unless you either restart kodi or tvheadend.
Next step to work out how to fire off an update to kodi via the API as Kodi gets updates sent by TVH as far as I can see after the initial scan. I feel I am getting closer
The ideal world would be to enter two directories (KidsTV/<title> in the autorec directory which would solve this problem straight away
Many thanks for such a quick response, much appreciated!
Updated by Rob M about 8 years ago
Just as a finishing note... I should have started my learning with Tvheadend with the unstable branch (4.1.x)! I have just discovered the new functions:
- For Recording profile you can now specify the format string to include multiple directories
- In the Autorec Directory, you can supply a path "KidsTV/Title" which is now created (4.0.x changed the "/" for a "-").
I am very happy now
Updated by Thomas Smith about 8 years ago
iam using "xbmc library auto update" - addon in kodi to do this:
system -> addons -> install from repository -> program add-ons -> xbmc library auto update
iam using multiple dvr-profiles in tvheadend with post-scripts to make links on recorded files with "filebot" and kodi update´s automatically the medialibrary
if you are interessting about this, just send me a contact-adress...
Updated by Rob M about 8 years ago
Many thanks for the information.
I did think about moving the recorded TV to the "TV Shows" section of Kodi, but most of the TV we watch is watched and then deleted, so it's nice to keep this to the "PVR" section of Kodi.
As the wife and kids have a load of stuff on record that may/may not be watched (in MythTV I just kept the last 5 latest episodes of a series (record new, delete old)) so I don't want that clogging up my TV programmes.
When I tried out 4.0 I used the recording profiles to do that but the base directory wasn't passed through to Kodi. Now after downloading the unstable branch to test the API, I see the wonderful "Format String" that has solved all my problems! I can add a static string in each profile and the folder structure is recreated!
KidsTV/$t/$t%F%R$-e$n.$x
I did look at Filebot but in the UK the EIT doesn't seem to provide fields for the series/episodes so that wouldn't work as well, maybe the XML providers might do it, but I'm happy with the FreeSAT EIT data
Thanks once again
Updated by Jaroslav Kysela about 8 years ago
- Status changed from New to Fixed
- % Done changed from 0 to 100
Applied in changeset commit:tvheadend|de3944eb2e82884e72e5a2e401726df3d52bc37e.
Updated by Jaroslav Kysela about 8 years ago
This fix in v4.1-2273-g91c4fa1 ensures that info for moved files is saved to disk. So, the script should not modify the log/ contents.