Navigation

Mythtv & Mediatomb

This is a brain dump of the steps that I took to setup Mediatomb to (semi) dynamically publish a list of my mythtv recordings for playback on various media devices connected to my network.

Exporting information from Myth

The first step is do get the information out of the mythtv data base and into a format that can be easily parsed by media tomb. The format that I've chosen to use for the data transfer tab separated vales, other formats such as csv would work just as well, it just that tsv files are easier to parse and import later in this process. The actual export is performed using the following script.

export-db-to-tsv

#!/bin/bash

MythDir="/mnt/data/myth" # This is the directory where all the myth recordings are storedMediaTombRoot="MythTV" # This is the name of the mediatomb folder that will contain the list of recordingsMythDBUser="mythtv" # mythconverge db usernameMythDBPass="mythtv" # mythconverge db password

The first select produces a list of each different TV series that Myth has recorded eg Mythbusters, Time Team, Dr Who, etc. For each of these series the second select produces a list of episodes currently on disk and numbers them sequentially in ascending date recorded order. This numbering is important later on in the import step as it gives Mediatomb a field to order its listings by.

A cron entry is set up to run this script each hour and to dump the output into "/tmp/mythdump.tsv". Note that the extension .tsv is very important as it will tell Mediatomb how to process the file.

Telling Mediatomb about TSV files

Next we need to tell media tomb what a TSV file is and how it should be handled. First modify the config.xml file as follows.

In the extension-mimetype section add the following line.

<map from="tsv" to="text/tab-separated-values"/>

This tells Mediatomb to assign a mime type of "text/tab-separated-values" to all files that end with ".tsv". Next in the mime-contenttype section add the following line.

<treat mimetype="text/tab-separated-values" as="playlist"/>

This tells Mediatomp to treat all text/tab-separated-values files as playlists, not as regular files.

Finally modify getPlaylistType function in the comon.js file to return the connect value if a TSV file is being processed

Now all you need to do is to tell Mediatomb to watch the dump file (in this case /tmp/mythdump.tsv) for changes and it will automatically import the files into the structure for you. I've found that there is a bug in Mediatomb where immediately after you set up a watch the file is not imported. However if you regenerate the dump file after the watch is in place then everything works fine.