Automatically Updating MythVideo Metadata

You can automatically update your MythVideo Metadata using the Perl script mythvideo-scanner.pl, which can be scheduled to run automatically, at regular intervals, by cron. This script makes a good faith effort to figure out all of the relevant Web sites that may have information associated with each of the video files in the MythVideo storage tree, and download it. The information is blended into a consistent metadata record which is written to the database. Information about actors is also added.

This script may be run on any machine that has a network connection to the master backend. It does not have to be run on the master backend itself. We prefer to run it on the video server instead of the master backend, since this allows us to mount the posters, artwork and/or banners directory (along with the MythVideo storage tree) as read-only on all of the Mythbuntu boxes that access the video server, thereby minimizing the chance of accidents.

Meanwhile, the metadata updating is done directly on the video server, where the posters, artwork and/or banners directories can be accessed directly, thereby allowing new posters, artwork, etc. to be downloaded and stored. This also offloads the MythVideo work to the video server, thus freeing the master backend to do other, recording-related work unimpeded.

Begin by downloading the mythvideo-scanner install file from:

     http://code.google.com/p/mythvideo-scanner/

Uncompress the install file:

     cd /rpm/mythvideo-scanner
     tar xzf mythvideo-scanner.3.1.tar.gz

To install the mythvideo-scanner, you can try the installing it via the makefile, like this:

     cd mythvideo-scanner
     make upgrade
     su
     make PREFIX=/usr install

We prefer putting it in our own directory, by hand, like this:

     su
     mkdir /usr/local/mythvideo
     mkdir /usr/local/mythvideo/modules
     mkdir /usr/local/mythvideo/grabbers
     cp modules/ /usr/local/mythvideo/modules/
     chmod u=rw,go=r /usr/local/mythvideo/modules/
     cp grabbers/ /usr/local/mythvideo/grabbers/
     chmod u=rw,go=r /usr/local/mythvideo/grabbers/
     cp .pl /usr/local/mythvideo
     chmod u=rwx,go=rx /usr/local/mythvideo/.pl

This allows code in the Perl scripts to set the current directory into the include directory list and always find the modules and grabbers, regardless of which version of Mythbuntu (or not) that you are using.

Make sure that you have all of the prerequisite Perl modules installed from CPAN. We have found (on CentOS) that all of the necessary modules were already installed except HTML::TreeBuilder and Text::Levenshtein. On Mythbuntu, many people have reported that Text::Levenshtein is the only module that needs to be installed. The full list of required modules is:

     File::Spec;
     Getopt::Long;
     HTML::Parser;
     HTML::TreeBuilder;
     HTML::Entities;
     LWP::Simple;
     LWP::UserAgent;
     Text::Levenshtein qw(distance);

You can install them like this, for example:

     su
     perl -MCPAN -e shell
     install HTML::TreeBuilder
     install Text::Levenshtein
     quit

If you won't be running mythvideo-scanner on the master backend or one of your Mythbuntu frontends, get a copy of the MythTV MySQL configuration text file from one of your Mythbuntu boxes. It is preferrable to use mysql.txt from a frontend, since it is a little closer to what we want to use for a system that will access the MythTV database remotely. We like to put it in the /etc/mythtv directory but you can do a find to see if it is already installed elsewhere. Here is a sample of a typical mysql.txt file:

/etc/mythtv/mysql.txt:

     # Database server host name (master backend).
     DBHostName=192.168.1.99
     # By default, Myth tries to ping the DB host to see if it exists.
     # If your DB host or network doesn't accept pings, set this to "no".
     #DBHostPing=no
     # Database connection information.
     DBUserName=mythtv
     DBName=mythconverg
     DBType=QMYSQL3
     DBPassword=123abc987

You might want to set the ownership and permissions of this file to root, read/write, so that it is free from prying eyes (it does contain your database password, after all), like this:

     su
     chown root:root /etc/mythtv/mysql.txt
     chmod u=rw,go= /etc/mythtv/mysql.txt

>>>>>>
add the host's info to the mythconverg prefs table. <<<<<<

You can now try running the mythvideo-scanner like this:

     /usr/local/mythvideo/mythvideo-scanner.pl --dryrun --status --verbose

If run gets an error like this:

     -bash: /usr/local/mythvideo/mythvideo-scanner.pl: /usr/bin/perl^M: bad
       interpreter: No such file or directory

You need to remove all of the carriage returns off the ends of the lines. This is easily accomplished with these commands:

     su
     cd /usr/local/mythvideo
     find . -type f -exec dos2unix -o \{\} \;

>>>>>>
You need to be superuser to run, if you removed permissions from the mysql.txt file

     /usr/local/mythvideo/mythvideo-scanner.pl --dryrun --verbose

<<<<<<