dave-p/TVHadmin

Database update for new recordings?

Closed this issue · 10 comments

Something missing from the docs, I think, is how to get Kodi to update the database of recordings. If I browse recordings made from the Kodi front end I see only those that were made using Kodi. Those made via TVHadmin show up in TVHeadend's UI but not Kodi. The file ownerships and permissions look fine so I presume Kodi needs to update its database. I haven't run into this before and haven't had time to search for info on it yet; may be worth adding a note to the docs.

I've not seen this issue but there are a couple of possibilities:

  • Do you have more than one recording profile set up in TVHeadend? TVHadmin lists all recordings but maybe the Kodi plugin is filtering them.
  • Is the TVHeadend user configured into TVHadmin the same as the one in the Kodi plugin?

I don't believe the Kodi plugin has a database, as far as I can tell it queries TVHeadend directly.

Ah, I hoped you'd say "You need to do X". No, only one recording profile. I have two TVheadend users, admin and me (non-admin account). The files appear no different from those recorded using the Kodi EPG. Kodi provides options for recreating the "Library" database, deleting everything and rebuilding it when things change/on startup, and I have tested the Watchdog plugin in the past. I tried getting it to rebuild library for videos as there isn't an option specifically for TV recordings. Didn't work.

Are you using only TVH for playback? Do your recordings made via TVadmin show up in the Kodi front end?

It's only a minor annoyance but would be nice to fix if possible.

I'm running Kodi (18.7 via OSMC) on a Raspberry Pi connected to the TV, with the TVHeadend HTSP plugin. TVHeadend itself is on a second Pi.
I use the dvr purely for timeshifting; recordings are deleted after they have been watched. Hence I have no need for a library. Recordings are visible in Kodi under TV -> Recordings whether they are scheduled by TVHadmin or Kodi and can be played from there.

Am also on Kodi 18.7-1 via LibreElec v9.2.3. Should have updated to 18.8 but hasn't yet. Running on an old HTPC under the TV (was a Vista-based Media Centre once but has had a new motherboard and a few peripheral and software updates since). TVHeadend is running on the same box. TVHadmin is running on a Raspberry Pi 3 whose main job is taking a photo every 5 mins for weather website. I have a separate Pi running LibreELec velcroed to the back of a TV in the bedroom and this runs the TVHeadend client.

I also use the main Kodi box purely as a PVR and delete stuff after I/we've watched it. I have a NAS folder available for archiving off anything I want to keep (rare).

My understanding is that Kodi uses a SQLite database "Library" to keep track of who has seen what recordings and at what point they were paused, if they were, so that they can be resumed. (We have been known to pause something in one place and resume in another.)

A profile difference would make sense but I can confirm I'm using the admin account for TVHeadend with TVHadmin. I'll make a post on the LibreElec forum and see if I can get some suggestions. If it's working for you on OSMC perhaps it could be a LibreElec difference?

Resolved: I was using the TVH admin account. Works as expected with non-admin account. This is better from a security POV too.

This (Installation instructions) needs to be amended

Browse to http://your.web.server/path/TVHadmin.php. Enter the username and password of a TVHeadend admin user.

to a "non-admin user."

Yes that statement is incorrect.

Since writing those instructions I've learned more about the TVHeadend permissions system. The 'Admin' isn't a superuser in the sense of a Unix root account, all that 'admin' controls is access to the 'Configuration' tab in the TVH user interface. (OK if you have access to that tab then you can give yourself any rights you wish, but you don't get everything automatically.)

It will be necessary to work out which privileges are needed to allow TVHadmin to function.

To complicate matters further there is an error in the online help text for the 'Change Parameters' box. I raised a PR to have the text corrected but it hasn't been applied yet - see tvheadend/tvheadend#1335.

Actually, I'm not sure it's entirely incorrect. I just discovered something interesting. It's not the admin/non-admin user, I think it's whether or not it's the same user as used by any Kodi client.

Previously I had a couple of series scheduled for recording (first episode already recorded in both cases) and I deleted them after I'd reverted to a non-admin user. This didn't delete them from TVH as they didn't exist for that user, but from TVH's POV they were, of course, still there. Attempting to reinstate them with the right (non-admin) user on TVHadmin caused an erroneous "record series" for the previous programme.

The lesson could be that changing user shouldn't be allowed if there are pending events until they've been deleted? Or perhaps that each user should have a separate subdirectory in the data folder? (probably not worth it given potential collisions?)

To be clear, here's what I did:

  1. Installed TVH with admin and non admin users
  2. Added Kodi client with non-admin user
  3. Added TVHadmin with admin user

If Kodi client was configured to use TVHadmin user there probably wouldn't have been a problem. I haven't verified.

I hadn't previously ever used anything other than a single non-admin account for recording so was oblivious of TVH potentially hiding recordings / keeping them separate across accounts. I think this is where the database is used.

Have now reinstated the scheduled series recordings with the right account and all's well.

The main thing I would still like is an ability to see "What's on this evening on favourite channels" (a "Tonight" button). I tried adjusting the EPG start time but it then gives a full 24 hours, which is too much. If you added an EPG end time alongside the start time it might work:

Tonight: begins at .... ends at... (say 7pm to midnight; 2am on Friday and Saturday :-) )

I've updated the README to clarify the requirements for a user and to specify using the same user for Kodi and TVHadmin.

Re your 'tonight' screen, you can easily create a custom version of the 'Favourites' screen:

  • Copy fav.php to a new name
  • Edit line 81 to reduce the interval that the EPG is gathered for. In my case the day is set to begin at 03:00 so to only show events between 19:00 and 23:00 I need to add 16 hours to the start time and subtract 4 hours from the end time. Hence my line 81 becomes:
    $progs = get_epg($c, $when+16*3600, $next-4*3600);
  • To make the navigation buttons stay on your custom screen instead of returning to the original, do a search-and-replace to substitute the name of your script for 'fav.php' - there are six lines to change.

Great! Do specify Kodi client and TVHadmin.

Aye, I looked at fav.php and guessed I could figure out doing that but thought you might like to make it an out of the box option ;-)