Kodi MythTV addon fails to load

Starting around the 23rd of October 2020 I found that my MythTV add-on was not working in Kodi running on Windows 10. It would hang either on importing guide or it would show nothing but not work either. I had been changing the subtitle and title of some recordings in the DB but I had done this many times before without issue.

I spent a heck of a lot of time over the week and following weekend investigating but could not resolve it. Then magically today it is working fine. So I am little totally frustrated and happy all at once.

So this post mostly serves as a record of what I learned should it come up again.

Myth back end seems to be ok

Far as I could tell the back end has been working fine. It does recordings, keeps to the schedule, all fine. I also ran up the front end on the server and it worked fine, no issues. I also ran up Kodi on my phone and Kodi worked fine.

Kodi local SQLite

Kodi has a set of SQLite databases it uses for various things. There is a copy of these in each profile in Kodi. So if you only have the default “Master” profile then this is:

C:\Users\Tony\AppData\Roaming\Kodi\userdata\Database

In the above the “Tony” folder is the Windows user that I am logged in as when I run Kodi, it is not a Kodi profile – this is still the Kodi master profile. If you had a Kodi profile call “Fred” then the folder would be:

C:\Users\Tony\AppData\Roaming\Kodi\userdata\profiles\Fred\Database

The databases are:

Addons27.db
CDDB
Epg12.db
MyMusic72.db
MyVideos116.db
Textures13.db
TV32.db
ViewModes6.db

Note each DB has a version number in the name so the base DB names will be the same for you but the versions might be different.

The one that is interesting to us is Epg12.db. This contains the EPG details. It works perfectly fine to shutdown Kodi and delete this DB and it will recreate it.

I found when I was trying things with the EPG it was a good idea to shutdown Kodi and delete this EPG database, otherwise it go really confusing as to whether thing were working or not because it had already loaded some/all of the EPG details into the running app.

MythTV program table

In the main MythTV database, the MariaDB database on the MythTV back end, not the Kodi ones, there is a table called “program”.  This contains the EPG data. This can safely be truncated as it will be repopulated. To get the EPG data to populate record a program and once you do this it will start to collect EPG data and within a few minutes it will slowly start to populate.

This table was very important for this problem. For example if I did the following:

  1. Stop Kodi and ensure the process is killed
  2. Stop mythbackend and ensure it is completely down
  3. Truncate the “program” table
  4. Delete the Kodi Epg12.db database
  5. Start mythbackend
  6. Monitor MythWeb until recorded programs works to prove Myth is fully up
  7. Immediately start Kodi

This always worked. If I watched some live TV and allowed the program table to populate and then restarted Kodi it would hang loading the guide.

Possible causes

For this issues there was a suggestion it could be related to certain channels or it could be invalid characters in the title or subtitle.

Another possible theory is it is related to daylight savings times. I don’t know why this would be the case unless Kodi or the add-on, has problems dealing with daylight savings. The reason for thinking it might be related is mostly due to timing and the fact that the problem magically resolved.

EPG data is somehow likely to be related and this can give misleading time frames. Remembering MythTV will typically have 8 days worth of data. That means that if there is an EPG issue due to dates or text, like title/subtitle, then the problem could appear 8 days ahead of the actual recording