Project

General

Profile

Feature #3818

Failed recordings (Files missing) because of file-renaming (refresh dvr)

Added by Thomas Smith over 5 years ago. Updated over 5 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
General
Target version:
-
Start date:
2016-05-20
Due date:
% Done:

100%

Estimated time:

Description

Dear TVH-Team,

iam using filebot to rename recordings via post-script for kodi (to find correct metadata infos)
after filebot was renaming the recorded file, my script (movies.sh) is searching all logs in .hts/tvheadend/dvr/log for the old full path and replace the string with the new one

tvh sometimes does not recognise the new path and tells: Failed Recordings - File missing
sometimes it is working
(example.zip)

one workaround for me is to restart tvheadend - after that, the failed recording moved to finished recordings

what can i do to tell tvh the new path without service-restart?
is there a "refresh dvr-logs" possibility?

thx


Files

example.zip (72.4 KB) example.zip Thomas Smith, 2016-05-20 11:29
example-nok.txt (1.74 KB) example-nok.txt Thomas Smith, 2016-05-30 08:51

Associated revisions

Revision ea572983 (diff)
Added by Jaroslav Kysela over 5 years ago

api: add /api/dvr/entry/filemoved, fixes #3818

Revision 31b99e26 (diff)
Added by Jaroslav Kysela over 5 years ago

DVR: fix files moved function, fixes #3818

History

#1

Updated by Mark Clarkstone over 5 years ago

  • Tracker changed from Bug to Feature

Thomas Smith wrote:

Dear TVH-Team,

iam using filebot to rename recordings via post-script for kodi (to find correct metadata infos)
after filebot was renaming the recorded file, my script (movies.sh) is searching all logs in .hts/tvheadend/dvr/log for the old full path and replace the string with the new one

tvh sometimes does not recognise the new path and tells: Failed Recordings - File missing
sometimes it is working
(example.zip)

one workaround for me is to restart tvheadend - after that, the failed recording moved to finished recordings

what can i do to tell tvh the new path without service-restart?

is there a "refresh dvr-logs" possibility?

No, but it might be a useful feature, this is not a bug IMO, Tvheadend is behaving as it should..

Even better option would be some api call allowing you to rename the files via tvheadend..

thx

#2

Updated by Mark Clarkstone over 5 years ago

  • Subject changed from Failed recordings (Files missing) because of file-renamings to Failed recordings (Files missing) because of file-renaming (refresh dvr)
#3

Updated by Rob vh over 5 years ago

In Linux, when you move a recording file externally from tvheadend, the new name is stored in dvr/log. tvheadend watches the inode change (inotify).

#4

Updated by Thomas Smith over 5 years ago

i have changed the script - no more changing dvr-log-files after renaming
what i can see is, that inotify is not working every time with tvh - tested with 9 successfull recordings:
7 recordings: ok
2 recordings: nok (status: file missing)

on "file missing recordings", i found in dvr-log no more informations in section "files" (see example-nok.txt)

#5

Updated by Steve Black over 5 years ago

I have also had this same problem. My feature request to refresh the log file after post_processing completes has been targeted to version 4.4. In the meantime, I have noticed that the new names do sometimes get recognized, which I believe is new in 4.1.x. I never noticed it in 4.0.

#6

Updated by Jaroslav Kysela over 5 years ago

If you remove the file, TVH will catch this (inotify) and removes the file info completely from the database. The file rename must met these conditions: Destination file must be in the same directory and 'mv' command (rename syscall) must be used.

From the original report, it's not allowed to change the internal database at the time.

#7

Updated by Jaroslav Kysela over 5 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100
#8

Updated by Jaroslav Kysela over 5 years ago

  • Status changed from Fixed to New
  • % Done changed from 100 to 0

I implemented /api/dvr/entry/filemoved API - the URL should be like:

http://localhost:9981/api/dvr/entry/filemoved?src=%2Fhome%2Fsrcfile&dst=%2Fhome%2Fdstfile

The request must be issued with admin rights.

v4.1-2105-gea57298

#9

Updated by Jaroslav Kysela over 5 years ago

Also, note that you can remove the old file after this notification, otherwise TVH will remove the "files" section from internal db before using inotify.

#10

Updated by Thomas Smith over 5 years ago

first i found, that inotify-tools are not available on my ubuntu-system (https://wiki.ubuntuusers.de/inotify)
maybe it is a good idea to add this tools to the tvheadend-dependency-list (apt-get build-dep)?

apt-get install inotify-tools (inotify-tools libinotifytools0)
upgraded tvh to version "Version: 4.1-2105~gea57298~trusty"

2nd i was not able to find directory-structure "api/dvr/entry/filemoved" in tvh-home-directory after update (maybe it doesnt matter?):
/home/hts/.hts# find . | grep api

can you give me more informations about the correct url or an example url?
original recorded full-path-name "/movies/Planet der Affen: Revolution/Planet der Affen: Revolution.ts"
new recorded full-path-name "/movies/Planet der Affen: Revolution/Planet der Affen - Revolution (2014).ts"

so in this case, is this the correct url, which i have to request:
http://localhost:9981/api/dvr/entry/filemoved?src=%2Fhome%2FPlanet der Affen: Revolution.ts&dst=%2Fhome%2FPlanet der Affen - Revolution (2014).ts

i will check the behavior after installing "inotify-tools" and will report again...

#11

Updated by C K over 5 years ago

Thomas Smith wrote:

first i found, that inotify-tools are not available on my ubuntu-system (https://wiki.ubuntuusers.de/inotify)
maybe it is a good idea to add this tools to the tvheadend-dependency-list (apt-get build-dep)?

apt-get install inotify-tools (inotify-tools libinotifytools0)
upgraded tvh to version "Version: 4.1-2105~gea57298~trusty"

2nd i was not able to find directory-structure "api/dvr/entry/filemoved" in tvh-home-directory after update (maybe it doesnt matter?):
/home/hts/.hts# find . | grep api

can you give me more informations about the correct url or an example url?
original recorded full-path-name "/movies/Planet der Affen: Revolution/Planet der Affen: Revolution.ts"
new recorded full-path-name "/movies/Planet der Affen: Revolution/Planet der Affen - Revolution (2014).ts"

so in this case, is this the correct url, which i have to request:
http://localhost:9981/api/dvr/entry/filemoved?src=%2Fhome%2FPlanet der Affen: Revolution.ts&dst=%2Fhome%2FPlanet der Affen - Revolution (2014).ts

i will check the behavior after installing "inotify-tools" and will report again...

It's not a directory, it's an url.

URL's should be URL-encoded: see http://meyerweb.com/eric/tools/dencoder/

http%3A%2F%2Flocalhost%3A9981%2Fapi%2Fdvr%2Fentry%2Ffilemoved%3Fsrc%3D%2Fpath%2Fmy%2Frecords%2FPlanet%20der%20Affen%3A%20Revolution.ts%26dst%3D%2Fmovies%2FPlanet%20der%20Affen%20-%20Revolution%20(2014).ts
#12

Updated by C K over 5 years ago

C K wrote:

Thomas Smith wrote:

first i found, that inotify-tools are not available on my ubuntu-system (https://wiki.ubuntuusers.de/inotify)
maybe it is a good idea to add this tools to the tvheadend-dependency-list (apt-get build-dep)?

apt-get install inotify-tools (inotify-tools libinotifytools0)
upgraded tvh to version "Version: 4.1-2105~gea57298~trusty"

2nd i was not able to find directory-structure "api/dvr/entry/filemoved" in tvh-home-directory after update (maybe it doesnt matter?):
/home/hts/.hts# find . | grep api

can you give me more informations about the correct url or an example url?
original recorded full-path-name "/movies/Planet der Affen: Revolution/Planet der Affen: Revolution.ts"
new recorded full-path-name "/movies/Planet der Affen: Revolution/Planet der Affen - Revolution (2014).ts"

so in this case, is this the correct url, which i have to request:
http://localhost:9981/api/dvr/entry/filemoved?src=%2Fhome%2FPlanet der Affen: Revolution.ts&dst=%2Fhome%2FPlanet der Affen - Revolution (2014).ts

i will check the behavior after installing "inotify-tools" and will report again...

It's not a directory, it's an url.

URL's should be URL-encoded: see http://meyerweb.com/eric/tools/dencoder/

[...]

Sry i wrote crap :-)

URL should be:

 http://localhost:9981/api/dvr/entry/filemoved?src=%2Fpath%2Fmy%2Frecords%2FPlanet%20der%20Affen%3A%20Revolution.ts&dst=%2Fmovies%2FPlanet%20der%20Affen%20-%20Revolution%20(2014).ts

file path should be encoded only not the whole link :-)

#13

Updated by Thomas Smith over 5 years ago

if the url is incorrect, tvh-web-server tells me a "400 Bad Request"

if the url is correct, tvh-crashes:
[Mon Jun 6 12:32:13 2016] tvh:tcp-start30005: segfault at 0 ip 0000555bf74848a7 sp 00007f03b77fd260 error 4 in tvheadend[555bf7254000+1a59000]
[Mon Jun 6 12:33:41 2016] tvh:tcp-start30256: segfault at 0 ip 000055ca7bd988a7 sp 00007f3976ffc260 error 4 in tvheadend[55ca7bb68000+1a59000]
[Mon Jun 6 12:35:42 2016] tvh:tcp-start30614: segfault at 0 ip 000055df9643e8a7 sp 00007f54fcff8260 error 4 in tvheadend[55df9620e000+1a59000]

my test:
copyeng recorded file to a new one with another name within the same directory:
nas:/data/movies/movies/Maggie# cp -a "Maggie (2015).ts" "Maggie (2010).ts"

requested url:
http://IP:9981/api/dvr/entry/filemoved?src=%2Fdata%2Fmovies%2Fmovies%2FMaggie%2FMaggie%20(2015).ts&dst=%2Fdata%2Fmovies%2Fmovies%2FMaggie%2FMaggie%20(2010).ts

tvh-crashes

should i start tvh via gdb?

#14

Updated by Thomas Smith over 5 years ago

aptitude install cmake
git clone https://github.com/tvheadend/tvheadend
./configure --trace-enabled=yes
make

ulimit -c unlimited
echo core.%h.%e.%t | sudo tee /proc/sys/kernel/core_pattern
echo 0 | sudo tee /proc/sys/kernel/core_uses_pid

gdb
set logging on
set pagination off
file /home/hts/case-3818/tvheadend/build.linux/tvheadend
run

Thread 60 "tvh:tcp-start" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff9b7fe700 (LWP 10163)]
0x0000555555744da7 in dvr_entry_file_moved ([email protected]=0x7fffe81d490c "/data/movies/movies/Maggie/Maggie (2015).ts", dst=0x7fffe81d74ec "/data/movies/movies/Maggie/Maggie (2010).ts") at src/dvr/dvr_db.c:3535
3535 HTSMSG_FOREACH(f, de->de_files)

(gdb) bt
#0 0x0000555555744da7 in dvr_entry_file_moved ([email protected]=0x7fffe81d490c "/data/movies/movies/Maggie/Maggie (2015).ts", dst=0x7fffe81d74ec "/data/movies/movies/Maggie/Maggie (2010).ts") at src/dvr/dvr_db.c:3535
#1 0x000055555572c70f in api_dvr_entry_file_moved (perm=<optimized out>, opaque=<optimized out>, op=<optimized out>, args=0x7fffe81d4980, resp=<optimized out>;) at src/api/api_dvr.c:491
#2 0x0000555555756d9f in webui_api_handler (hc=0x7fff9b7fd840, remain=0x7fffe81d4699 "dvr/entry/filemoved", opaque=<optimized out>;) at src/webui/webui_api.c:43
#3 0x00005555556d5e32 in http_exec ([email protected]=0x7fff9b7fd840, [email protected]=0x555556c87350, remain=0x7fffe81d4699 "dvr/entry/filemoved") at src/http.c:916
#4 0x00005555556d6b36 in http_cmd_get ([email protected]=0x7fff9b7fd840) at src/http.c:989
#5 0x00005555556d6d1d in http_process_request (hc=0x7fff9b7fd840, spill=<optimized out>;) at src/http.c:1072
#6 0x00005555556d6382 in process_request ([email protected]=0x7fff9b7fd840, [email protected]=0x7fff9b7fd7c0) at src/http.c:1185
#7 0x00005555556d6fbb in http_serve_requests ([email protected]=0x7fff9b7fd840) at src/http.c:1475
#8 0x00005555556d7101 in http_serve (fd=48, opaque=0x7fffb4001c98, peer=0x7fffb4001cb0, self=0x7fffb4001d30) at src/http.c:1523
#9 0x00005555556cf89d in tcp_server_start (aux=0x7fffb4001c70) at src/tcp.c:645
#10 0x00005555556cb183 in thread_wrapper (p=0x7fffb4000d20) at src/wrappers.c:159
#11 0x00007ffff685b6fa in start_thread (arg=0x7fff9b7fe700) at pthread_create.c:333
#12 0x00007ffff5cfeb5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

#15

Updated by Jaroslav Kysela over 5 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100
#16

Updated by Jaroslav Kysela over 5 years ago

Fixed in v4.1-2110-g31b99e2 .

Also available in: Atom PDF