Adding IMDb ratings to MythTV

I have a MythTV box which I am very happy with. I like the fact that I can get a quick overview of all the movies for the coming week.
I guess, that if you get the TV listing in the US and possibly also in other contries, then you get star ratings in MythTV. At least there is an option in the GUI to only show movies with a certain rating. But in Denmark where I live the TV listings, which come from TV2, do not contain star ratings. But the script tv_imdb which is part of XMLTV will add Internet Movie Database ratings to an XMLTV file.
So I created a simple script to do just that.

Before you can use the script, you need to setup tv_imdb. That can be done by calling:
tv_imdb --imdbdir <dir> --prepStage all --download
Be aware that this takes quite some time and uses a lot of memory, bandwidth and disk space.

Unfortunately the tv_imdb script messes with the categories, which means that MythTV will no longer recognise movies. To avoid this I have modified the tv_imdb script slightly.
Look for “my $imdb=new XMLTV::IMDB” and you should find something similar to what you see below.

my $imdb=new XMLTV::IMDB('imdbDir' => $opt_imdbDir,
'verbose' => !$opt_quiet,
'cacheLookups' => 1,
'cacheLookupSize' => 1000);

Now change it into this:

my $imdb=new XMLTV::IMDB('imdbDir' => $opt_imdbDir,
'verbose' => !$opt_quiet,
'cacheLookups' => 1,
'replaceCategories' => 0,
'updateCategories' => 0,
'cacheLookupSize' => 1000);

This will preserve the categories as they are.

And finally, here is my script:

#!/bin/bash
LOG_PATH=/var/log/mythtv/mythupdateepg.log

#################

log () {
stamp=$(date +"[%m-%d-%Y %H:%M:%S]“)
echo “$stamp $1″ >> $LOG_PATH
}

log "mythupdateepg starting..."

tv_grab_dk --output epg.xml
cat epg.xml | sed -e "s/<title>/<title lang=\"en\">/" > epg_en.xml
tv_imdb --imdbdir ~/imdb/ --stats --quiet --output epg_imdb.xml epg_en.xml
mythfilldatabase --file 2 -1 epg_imdb.xml
log "mythupdateepg ending..."

3 Responses to “Adding IMDb ratings to MythTV”

  1. Per Jørgensen Says:

    Hey there.

    having some problems with running the IMDB script.
    I’m getting 104error in stage 7 and afterwards no effect In Mythweb.
    I’ve tried several times to make this run, carse its is really a pain, that the programview cannot list the different categories?
    Do you have an idea - and having you done anything else - carse here on ArchLinux and Myth0.22 I cannot make it work!

    per

  2. Jacob Says:

    Hi Per.

    It is so long ago that I don’t remember the details. I think I ran out of memory on one of the last stages, but my machine also had only 256MB RAM, so…
    But you can run each stage alone. Try doing that and see if that makes any difference.

    Jacob

  3. Per Jørgensen Says:

    Hey Jacob.
    Thanks for the answer.
    have tried it .- and having 3GB RAM In my machine - and still fails.

Leave a Reply