• Errors with MiroBridge

    by  • 2010/05/30 • How-to, Linux, Main Menu, MythTV, Ubuntu • 0 Comments

    For a while in MythTV 0.22 I was getting an error with MiroBridge saying Miro was not set up properly even though Miro worked just fine and I triple checked all my config files. I waited until upgrading to MythTV 0.23 to fix it because there was a much easier one button install option in Mythbuntu Control Centre. MiroBridge ran successfully once but I started getting files added to my recordings screen that didn’t exist. Once I manually cleared out the files MiroBridge automatically ran again but caused even more problems by having the two non-recordings show up 44 times.

    Once I got all of those recordings removed MiroBridge would never successfully run for me again. I could run MiroBridge manually but every time I would get an error

    AttributeError: ‘NoneType’ object has no attribute ‘lower’

    and MiroBridge would just hang. I would have to force quit the script and never got past that point. I figured out how to fix this issue with a lot of Googling. The problem happens because all of those files that didn’t exist from before were referenced in my database and MiroBridge was trying to remove them. Because they weren’t cleanly removed from the recordings screen (or Miro) MiroBridge couldn’t delete the listings. So what we have to do is clean up these erroneous database references manually. If you have phpMyAdmin installed on your machine you can easily delete these referenced recordings through there but I didn’t want to have something else installed on my MythTV box so I did it through the terminal. Before you go on this is a great chance to learn how to use screen because we are going to want to reference a lot of information from a bunch of different terminal windows. You can either do this with multiple terminals or you can be cool and do it with screen.

    Here are the steps you need to take to fix this error.

    Step 1. Troubleshoot and Backup
    Close out of MythTV and open a terminal. From the terminal run MiroBridge with the simulate option (-s) and redirect the output to a file (>). In MythBuntu 10.04 the command is
    /usr/share/doc/mythtv-backend/contrib/imports/mirobridge/mirobridge.py -s > mirobridge.log
    BTW this command needs to be run from the local machine and not through ssh because I believe the $DISPLAY variable isn’t set to :0 so MiroBridge gets confused when you are remote. We could change that variable but it is just as easy to work from the local machine.
    Now we need to make sure you are having the same error I was having. To do this we are going to read that file you just created and check for any lines that tell MiroBridge to delete old recordings from the database.
    cat mirobridge.log | grep oldrecorded
    If you don’t have any output from this then you probably have a different error than what I was getting. If you have a bunch of lines outputted that look like this

    Simulation: Remove orphaned oldrecorded record (None – ?????)

    Then you have the exact same error and should continue on to the next step. Make note of the ????? value cause we will need it later. It should be the name of the video file that was giving us errors.
    It is a good idea to always backup your mythconverg database so you may want to run this before continuing
    /usr/share/mythtv/mythconverg_backup.pl

    Step 2. Close Miro
    ps aux | grep miro
    Find each line that says something like /usr/bin/miro or mirobridge.py and then get the number at the front of that line and type kill *number* If you have more than 1 line just put each number and it will kill all of the running instances.
    Now that Miro and MiroBridge have been killed move on to manually removing the recordings information form the database.

    Step 3. Remove old data
    First thing you will need is your database username and password. The easiest way to get this is just to use
    cat /etc/mythtv/mysql.txt
    At the begining of the output you should have DBUserName and DBName. You will need both of those but it is probably mythtv and mythconverg so make sure you also get the DBPassword near the bottom of that output.
    Once you have that information connect to your mysql server. Replace ‘password’ with your actual password from the /etc/mythtv/mysql.txt file.
    mysql --user=mythtv --password='password'
    Then we just want to make sure we have the right mysql server (just because it is better to be safe than sorry).

    SHOW DATABASES;
    You should see your mythconverg table here so go ahead and use it.

    USE mythconverg;
    SHOW TABLES;

    You should then see a whole lot of tables but the one we want is the oldrecorded table. Just to make sure we have the right information you are going to view all the erroneous database entries before you delete them. For the ????? you need to use the recording name that you got from step 1. Make sure you use the correct case when searching for the information.
    SELECT * FROM oldrecorded WHERE subtitle = "?????";
    If there were more than one different entry names simply put OR subtitle = “?????” with your next value. In my case I had two different recordings that caused the problem so I used
    SELECT * FROM oldrecorded WHERE subtitle = "STALKER_REPORTER_ITUNES.mp4" OR "tekzilla--tzdaily--0464--2009-10-16gmaps--hd.h264.mp4";
    This should list all of the entries so now you just need to delete them from the database.

    DELETE FROM oldrecorded WHERE subtitle = "?????";
    Just like above you can use the OR command to delete multiple entries at once.
    Once the entries are deleted just type exit; to leave mysql and go back to the normal shell prompt.

    Step 4. Test
    Now that the the entries have been deleted repeat step 1 again and you shouldn’t have any lines returned that say
    Simulation: Remove orphaned oldrecorded record (None - ?????)
    You should then be able to run MiroBridge without the simulation option and get your Miro videos imported into your recordings. It is a good idea to still use the verbose (-V) option just to make sure everything goes smoothly.
    /usr/share/doc/mythtv-backend/contrib/imports/mirobridge/mirobridge.py -V

    That is all you need to do. Just make sure you set up your cron job to automatically run MiroBridge however often you want and you should be all set.

    I hop this helps and leave a comment below if you have any questions.

    About

    Avid learner with a passion for technology and people. He is always trying new things or taking something apart to make it better.

    http://1n73r.net