Saturday, March 9, 2013

Mythconverg - how to remove odd entries

I had some entries that kept appearing again and again in my mythbackend logs. An example is

2013-03-08 19:11:36.832276 E [979/979] CoreContext programinfo.cpp:2284 (GetPlaybackURL) - ProgramInfo(Superman_II_06.02.2012.mkv): GetPlaybackURL: 'Superman_II_06.02.2012.mkv' should be local, but it can not be found.

So, these would repeat themselves and fill my log files, but when I went to Mythfrontend and looked for them, they did not appear.

Related to this was a strange entry in Information Centre -> System Status -> Machine Status. Under the Total Disk Space I would have an entry that said I had years of time remaining, using my average rate of 1 kbps.

If I went to Mythfrontend -> Manage Recordings -> Delete Recordings, and with an entry in the Group Filter highlighted, open up the Group List Menu (the letter 'm' key), and selected 'Change Group Filter', I would see that I had some entries in either LiveTV or Default (or any other group I had saved a recording to), but if I selected that group the recordings would not appear.

For the LiveTV ones, the recording name was listed, but it was greyed out, with an 'x' at the start. Going and deleting this would remove it from the list, but it would always reappear if I did the process again.

For the Default ones, the list was just empty!

To solve this, I went straight to mysql and the mythconverg database itself. At a terminal type

$ mysql -u root -p

To see what databases you have, type

mysql> show databases;

To select the correct one, type

mysql> use mythconverg;

Mythconverg has lots of tables, and are stored like

| chanid | starttime | endtime | title | subtitle | description | season | episode | category | hostname | bookmark | editing | cutlist | autoexpire | commflagged | recgroup | recordid | seriesid | programid | inetref | lastmodified | filesize | stars | previouslyshown | originalairdate | preserve | findid | deletepending | transcoder | timestretch | recpriority | basename | progstart | progend | playgroup | profile | duplicate | transcoded | watched |

I started by seeing what was actually stored in the LiveTV recording group.

mysql> select * from recorded where recgroup = "LiveTV";

This listed some recordings, and these were indeed some of the ones repeating again and again in the logs. A commonly used SQL row selector is

WHERE chanid = "xxxx" and starttime = "xxxx-xx-xx xx:xx:xx"

I would look at the very first 2 outputs for any entry I wanted to delete to find the chanid and starttime. Firstly make sure this resulted in precisely what I wanted.

mysql> SELECT * FROM recorded WHERE chanid = "1009" and starttime = "2013-03-01 09:57:03";

Confirm that his would output only 1 entry, and was one that needed deleting. Then,


mysql> DELETE FROM recorded WHERE chanid = "1009" and starttime = "2013-03-01 09:57:03";

Gone! Continue for all entries you wanted deleted. Using the same approach I firstly listed everything in the Default recgroup.

mysql> select * from recorded where recgroup = "Default";

I had to take car of some unusual ones, which had chanid of "0" and some even had endtime of "0000-00-00 00:00:00". These seem to exist from recordings that were interrupted, whether through an unscheduled reboot or stopping a transcode from completing.

Not to worry. First check with the SELECT command, confirm it is correct, and the up-arrow and replace with DELETE. Done.

This also fixed my ridiculously low average kbps in the Machine Status page.