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..."