THIS PAGE IS A WORK IN PROGRESS
What is ttvdb.py
This python script is intended to perform TV series data lookups based on the thetvdb.comwiki
Downloading ttvdb.py set of scripts
Currently ttvdb.py does not ship with MythTV and only works with v0.22 revision 20232 or higher with a data base Schema Version: 1232 or higher. You will also need to apply the following patch #6346 and optionally: #6158
Click on the follow link to find the ttvdb scripts archive: #6242 - ttvdb make sure to download the latest version (v0.8.9)
The MythVideo scripts are typically installed in /usr/share/mythtv/mythvideo/scripts/ or /usr/local/share/mythtv/mythvideo/scripts/. When using mythvideo to download the TV series data, ttvdb must be installed in your "...mythvideo/scripts/" directory.
With sudo privileges un-archive all ttvdb archive files into your mythvideo scripts directory as described above. You can then delete the ttvdb archive file as it is no longer required.
Configuring MythVideo 0.22 to use ttvdb.py
Setup the directories for the TV Series artwork. Utilities/Setup|Setup|Media Settings|Videos Settings|General Settings on page 1/8, enter the directories where the graphic files will be stored. It is recommended to use separate directories for each type of graphic file (Posters, Banners, Fanart and Screen shots).
Using the default menu theme, you can find the settings in Utilities/Setup|Setup|Media Settings|Videos Settings|General Settings on page 8/8. The settings should look like:
Command to search for TV Shows in Mythvideo: /usr/local/share/mythtv/mythvideo/scripts/ttvdb.py -M Command to search for TV Season posters: /usr/local/share/mythtv/mythvideo/scripts/ttvdb.py -mlP Command to search for TV Show fanart: /usr/local/share/mythtv/mythvideo/scripts/ttvdb.py -tlF Command to search for TV Season banners: /usr/local/share/mythtv/mythvideo/scripts/ttvdb.py -lB Command to extract data for TV Episodes: /usr/local/share/mythtv/mythvideo/scripts/ttvdb.py -mD
Now you can use the mythvideo download feature "Manage Video|Download Metadata" to get a TV series artwork (poster, fanart and banner) plus episode details.
!!!! New feature that will only be available in release v0.9.0 or higher
ttvdb data requests defaults to English unless the -l option is used. If you specify a language (e.g. -l es), ttvdb will first look for data in that language but if none is available ttvdb will return the English equivalent assuming any exists.
Currently thetvdb.com wiki supports the following languages: (da, fi, nl, de, it, es, fr, pl, hu, el, tr, ru, he, ja, pt, zh, cs, sl, hr, ko, en, sv, no)
Why am I not getting the promised episode data?
Here are the usual suspects:
1) The Schedules Direct episode is completely different then what was entered in thetvdb.com.
2) You have not set up the commands properly in the setting as described in Configuring MythVideo 0.22 to use ttvdb.py.
3) The episode data was updated but one or more of the graphics will not display. Thetvdb.com web site can get overloaded which results in graphic files that are actually html error messages. When this happens the typical mythfrontend log message looks like:
example error message goes here !!!
If this occurs all you need to do is use the mythvideo "Manage Video|Reset Metadata", then download again, "Manage Video|Download Metadata". If you get a lot of these issues perform your metadata downloads when thetvdb.com is not so busy.
4) The format of your video file may not contain a series name matching that of any on thetvdb.com wiki or have incorrect season and episode numbers. If that is not the case then the video file name format may not be supported by ttvdb. This is the one case where you may need to use a user configuration file for mythvideo "Manage Video|Download Metadata". See section User configuration file. You can add your own regex string for parsing your video file names. Regex is not for the faint of heart but the option is there if you need it,
5) If problems persist verify that ttvdb is properly installed by viewing your mythfrontend log or trying ttvdb from the command line. See the next section on how to display examples.
Command line examples
To view command line examples of all ttvdb features type:
User configuration file
A user configuration file is not required when grabbing TV data through mythvideo download metadata. This is because you interactively select the specific TV series. If you intend to use ttvdb in your own user scripts a user configuration file is highly recommended.
TV listing sources such as Schedules Directdo not always pass MythTV TV series and episode names that match those on thetvdb.com wiki. This can cause ttvdb to fail in retrieving data. Luckily this does not happen often. To compensate ttvdb provides a user configuration file which can deal with those rare cases.
The configuration file can tie a series name (%TITLE%) to a specific thetvdb.com series id (the equivalent of an IMDB number). Also a TV series episode name (%SUBTITLE%) can be modified to match the episode name on thetvdb.com.
The included configuration file "ttvdb-example.conf" already has examples of TV series names that need special attention. There is also an episode name that must be manipulated to match those on thetvdb.com wiki.
Copy and rename "ttvdb-example.conf" to a directory of your choosing (e.g. ~/.tvdb/ttvdb.conf). Then edit the new file making changes as required. The example configuration file contains documentation for all sections and fields. To have ttvdb use your configuration file use the -c option, For example:
ttvdb -c "/home/user/.tvdb/ttvdb.conf" ...
See the command line examples for details. For mythbackend user jobs always specify a full qualified path for the configuration file, do not use the "~" short cut.
An example of a mismatch is where Schedules Direct has the TV Series name "The Beast" but thetvdb.com has the series name as "The Beast (2009)". Schedules Direct has the series "24" episode name of "Day 7: 10:00PM-11:00PM" while thetvdb.com has "Day 7: 10:00 PM-11:00 PM". The configuration file can compensate for these discrepancies.
Here are several examples that are included but inactive in the "ttvdb-example.conf" file. Please add new ones to this section when you encounter them.
[series_name_override] # Specify recorded "Life On Mars" shows as the US version Life on Mars:82289 # Specify recorded "Eleventh Hour" shows as the US version Eleventh Hour:83066 # Specify recorded "Frontline" or "Frontline/World" shows as the "Frontline PBS" version Frontline/World:80646 Frontline:80646 # Specify recorded "The Beast" shows are the 2009 version The Beast:83805 # Specify recorded "Castle" shows are the 2009 version Castle:83462 # Specify recorded "Battlestar Galactica" shows are the 2003 version Battlestar Galactica:73545
[ep_name_massage] # Modify the TV series 24 episode name (%SUBTITLE%) 24: PM," PM", AM, " AM"
Finally the user configuration file has a section that allows you to add regex stings used in parsing video file names when extracting series name, season and episode numbers. Any entries in the [regex] section of the configuration file will add to the scripts internal set of regex strings.
Within a user job you can generate a video file name with just the %TITLE% and %SUBTITLE% parameters passed by mythbackend. Here is a simple bash script.
#!/bin/bash # TV Episode Video File Name generation # $1 = %TITLE% and $2 = %SUBTITLE% echo "$1 - `ttvdb -N \"$1\" \"$2\"` - $2"
> example_script.sh "Sanctuary" "Sanctuary for All (2)" Sanctuary - S01E02 - Sanctuary for All (2)
If the series and/or episode was not found the script would have return
"Sanctuary - - Sanctuary for All (2)"
You can change the format of the season and episode numbers. For example:
echo "$1 - `ttvdb -N \"$1\" \"$2\" 'Season%dx%02d'` - $2"
Generates the custom format:
Sanctuary - Season1x02 - Sanctuary for All (2)
Obviously these examples are an oversimplification but it gives you an idea of what can be done.
User jobs are not generally interactive so it is highly recommended to include a user configuration file (see: User configuration file) so that series and episode names are found without manual interaction. With a user configuration file the simple example could have looked like:
echo "$1 - `ttvdb -c \"/home/user/.tvdb/ttvdb.conf\" -N \"$1\" \"$2\"` - $2"
If you find any other valuable ways utilize ttvdb in a user job please add an example to this section.
The ttvdb script could not exist without the tvdb_api module written by Ben/Hur. Time and again Ben/Hur has added functionality to accommodate the needs of MythTV. Ben/Hur has another useful script called tvnamer which renames video files to a standard format, tvnamer and tvdb_api can be found at:
You can install tvnamer which will also install a version of tvdb_api without fear of being out of sync with the version of tvdb_api that ttvdb uses as they are packaged separately.
I would also like to thank Robert McNamara for his invaluable suggestions on how ttvdb could be better integrated with mythvideo, which has increases the scripts value to the MythTV community.