MythTV and EPG Data

From Blue-IT.org Wiki

Revision as of 11:53, 24 June 2007 by WikiSysOp (talk | contribs)

MyhtTV

MythTV is the well known linux HPTC software.

One of the major advantages is the availability of an electronic program guide, that is fetched from grabbing tv-guide web pages with an external program: the 'grabber'.

On of the major problems setting up the mythtv program guide is, that the 'grabbers' are not part of myhttv and it is not trivial to install them.

None of these grabbers - for a list see xmltv - runs out of the box after installation.

Xmltv_prisma

After a having a lot of problems with the xmltv grabber, my favorite grabber is xmltv_prisma. It uses the webpage of the Prisma TV Guide.

Alter the mythtv channels table

The very first thing you have to do is to add an 'xmltvid' to each channel in the table 'channels' in the mythtv database. This database is named per default is 'mythconverg'.

What is the 'xmltvid' for a certain channel? Very easy. It is exact the string that you can read in your configuration file after you called

tv_grab_de_prisma --configure --gui

This file is located per default in '~/.xmltv/tv_grab_de_prisma.conf'. It looks like this

[...] 
channel 3.br-online.de #BR
channel 3sat.de #3SAT
channel ard.de #ARD
channel arte-tv.com #arte
channel dsf.com #DSF
channel einsplus.ard.de #Einsplus (ARD digital)
channel eurosport.de #Eurospor
[...]

The string after channel is the 'xmltvid'. The following command will give you these id's (uses mawk):

cat /home/whoever/.xmltv/tv_grab_de_prisma.conf  | mawk '{gsub(/^channel /,"");system("echo " $0 "")}'

You have to enter it manually into your database.

This could be done ether by editing the table with e.g. phpmyadmin or add them into the 'configuration' page of 'mythweb' (a plugin for myhttv).

Two scripts for running the grabber

Usual script

The following script grabs all program data for four weeks! this could last more than one day on a pc with slow cpu.

#!/bin/sh
ACTUAL_PATH='pwd'
XMLDIR="$HOME/.xmltv/xml"
DATE=`date +%F`
DAYS=7 
echo ---------------------------------------------------------------------
echo This is user $USER on $HOSTNAME running `pwd`/$0 script.
echo "`pwd`/$0 script running at ${DATE} grabbing data for next ${DAYS} days."
echo "`pwd`/$0 script running at ${DATE} grabbing data for next ${DAYS} days." >>  /var/log/mythtv/xmltv.log

cd ~/.xmltv
[ -d $XMLDIR ] || mkdir -p $XMLDIR

#for offset in 0;
for offset in 0 7 14 21;
do

XML=$XMLDIR/prisma_${DATE}-${offset}.xml

#tv_grab_de_prisma --days ${DAYS} --offset $offset --slow --output $XML
tv_grab_de_prisma --days ${DAYS} --offset $offset --slow --output $XML

if [ -f $XML ]; then
   mythfilldatabase --update --no-delete --file 1 0 $XML
   #mythfilldatabase --update --no-delete --file 1 -1 $XML
fi
done

Script with defined offset

The next script I use in conjunction with several crontab entries. It grabs only 3 days an runs every day. The script uses an offset parameter that controls the prisma grabber to grab date in future.

Prerequisites

The following scripts imply that you

  • have a fully configured tv_grab_de_prisma
  • use /home/mythtv/.xml/ directory to store the data and scripts
  • know how to edit your crontab as root
#!/bin/sh
ACTUAL_PATH='pwd'
XMLDIR="$HOME/.xmltv/xml"
DATE=`date +%F`
DAYS=3
OFFSET=$1

if [ ${OFFSET} -lt 1 ]
then
       echo Please specify an offset greater than 0.
       exit 1
fi

echo ---------------------------------------------------------------------
echo This is user $USER on $HOSTNAME.
echo "This is running `pwd`/$0 script at ${DATE} with offset of ${OFFSET} days."
echo "This is running `pwd`/$0 script at ${DATE} with offset of ${OFFSET} days." >> /var/log/mythtv/xmltv.log

cd ~/.xmltv
[ -d $XMLDIR ] || mkdir -p $XMLDIR

XML=$XMLDIR/prisma_${DATE}-${OFFSET}.xml

tv_grab_de_prisma --days ${DAYS} --offset ${OFFSET} --slow --output $XML || exit 1

if [ -f $XML ]; then
   mythfilldatabase --update --no-delete --file 1 0 $XML || exit 1
   #mythfilldatabase --update --no-delete --file 1 -1 $XML
fi

exit 0

Change to user root and edit your crontab entry with

crontab -e

Than add the following data

## Mythtv EPG Daten grabben
0       5       *       *       1       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 0"
0       5       *       *       2       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 2"
0       5       *       *       3       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 4"
0       5       *       *       4       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 6"
0       5       *       *       5       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 8"
0       5       *       *       6       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 10"
0       5       *       *       7       su mythtv -c "sh /home/mythtv/.xmltv/xmltv_prisma_offset.sh 12"


I use the following scheme to grab the data.

|> = day where the grabber runs with a defined offset
|  = offset days
o  = days that will be really grabbed
Mo  Di  Mi  Do  Fr  Sa  So  Mo  Di  Mi  Do  Fr  Sa  So  Mo  Di  Mi  Do  Fr  Sa  So

|>offset 0
o---o---o

    |>offset 2
    |---|---o---o---o

        |>offset 4
        |---|---|---|---o---o---o

            |>offset 6
            |---|---|---|---|---|---o---o---o

                |>offset 8
                |---|---|---|---|---|---|---|---o---o---o      

                    |>offset 10
                    |---|---|---|---|---|---|---|---|---|---o---o---o

                        |>offset 12
                        |---|---|---|---|---|---|---|---|---|---|---|---o---o---o


Secure Mythweb (german)

I got the next informations from a german wiki:[1] After you installed mythweb, the following points should be considered.

[...] Damit Digest überhaupt funktioniert, muss der Apache entsprechend konfiguriert sein.

Unter Debian Sarge mit Apache 1.3.x genügt hierzu ein

echo "LoadModule digest_auth_module /usr/lib/apache/1.3/mod_auth_digest.so" \

>> /etc/apache/modules.conf

Für apache2 geht es folgendermaßen:

a2enmod auth_digest
a2enmod authn_file
a2enmod authz_user
/etc/init.d/apache2 force-reload               

Die .htaccess mit dem Editor öffnen:

vi /usr/share/mythtv/mythweb/.htaccess

Folgender Auszug muss auskommentieren werden:

AuthType           Digest
AuthName           "MythTv"
AuthDigestFile     /var/www/htdigest <- UNBEDINGT IN /var/htdigest ÄNDERN! 
Require            valid-user

Dies bedeutet, dass wir mit dem Tool htdigest eine Datei mit dem Namen /var/htdigest anlegen müssen. Im Gegensatz zur alten Methode spielt hier allerdings auch die AuthName-Zeile eine Rolle, die bei htdigest unter der Bezeichnung Realm (zu deutsch: Bereich) angegeben werden muss.

htdigest akzeptiert laut man-page folgende Parameter:

htdigest [ -c ] passwdfile realm username

was uns also im konkreten Beispiel zu folgender Befehlszeile führt (mit verändertem Pfad):

htdigest -c /var/htdigest MythTV mythtv

Achtung! Die Option -c überschreibt die angegebene Datei, also Vorsicht! Danach ruft man die mythweb.php erneut auf und loggt sich mit seinem Usernamen(hier: mythtv) und dem angegebenen Passwort ein [...]

Error editing videos- No Seeltable

Myhttv stores the information about video length and seeks in an external databse, called seek table (see [2] for a detailed explanation).

If you get the error no seektable, when you like to edit your videos, this is because mythtv has no data about the length of your video. There are several ways to fix this.

Check, if you mysql seektable database is o.k.

mysqlcheck -u mythtv -p -r  mythconverg  recordedseek

If you get the output

mythconverg.recordedseek        OK

Then everything is fine. If not, you should run

mysqlcheck -u mythtv -p --auto-repair  mythconverg  recordedseek && \
mysqlcheck -u mythtv -p -r  mythconverg  recordedseek

Now you should start the commercial detection (as user mythtv) with

mythcommflag --rebuild -f  1501_20070601004300.mpg

1501_20070601004300.mpg is a sample filename for a recording.

Now you should be able to edit you video as usual ;)

A Trick for advanced linuxers: If you have a gigabit connection to your mythtv box and a fast machine, you can mount your myhttv box via nfs and then chroot into it. You can start mythcommflag in that chroot environment and it will use the processor power of your faster machine for

Mytharchive

On june/2007 I tried to use mythtarchive on my frontend machine for burning a dvd. The system crashed with the following error:

[...]
AttributeError: 'NoneType' object has no attribute 'endswith'

I googled arround and found bug #118700.

Sorry, but until now there seens no way to change this behaviour.