From MythTV Official Wiki
Revision as of 20:34, 7 March 2010 by Iamlindoro (talk | contribs) (Reverted edits by Ned14 (Talk) to last revision by Menny)

Jump to: navigation, search is perl script written by Menny Even Danan that goes over all the files under MythVideo folder and look them up in the Internet and fill the MythVideo database with the data.

This is done by parsing the filename, and determine whether it is a tv-show or a movie (not a tv-show), and retrieve information about the parsed item from or, locate subtitles for the video file, and generate a cover for the video file (either from within the video file, or from a web-site).

This script supports MythTV 0.22 features too (see #Main features).

The latest version can be downloaded from here


Movies files under MythVideo after running this script.

TV shows files under MythVideo after running this script.

Main features

  • Fill meta-data for movies and TV shows, by parsing the filenames:
    • Locating the most similar movie based on Levenshtein Distance algorithm and removal of redundant suffixes. Meta-data is retrieved from
    • Locating TV shows by parsing the filename for show name, season number and episode number. Meta-data is retrieved from
    • Allow overriding the automatic parsing by special nfo files:
      • Specify the movie ID (from for a specific video file.
      • Specify the series ID (from for all files in a specific folder.
      • Specify the tv show episode identification for a specific video file.
      • Setting an ignore marker for a file.
  • Setting the title of the video files to a configurable standard formatting, e.g., "01: My Jerks", or "Scrubs S08E01 My Jerks".
  • Creating a cover of each video file:
    • A snapshot from a random point within the video file.
    • Download an official cover art from the meta-data provider - if possible, will download hi-res poster.
    • Use an external script to retrieve poster.
  • Setting a cover for the folder, based on its content.
  • Support for ripped DVD folders (VIDEO_TS).
  • Works in a multi-clients-servers environment.
  • Automatically detects various required settings:
    • MySQL credentials.
    • Video folder.
    • Cover art folder.
    • Allowed file extensions.
  • Supports Parental Level detection.
  • Special MythTV tags:
    • Season and episode number parsing
    • season banner

Basic Usage

Usually, the best option to run is without any arguments. The script can automatically detect the sql password, and the machine's hostname, it can determine the video files folder, and which file extensions are valid, and where to store the artwork. If you would like to change the default behavior of the script, read about the command-line arguments below. It is suggested to use this script in a crontab job:

00 06 * * * /home/mythtv/
  • replace /home/mythtv/ with the path to the location of the script.

Perl prerequisites

There are not prerequisites for this script. It works with the default perl modules.

Help Output usage:

-N [1/0]
  Perform "full" (0)/"new files only" (1) scan (overriding the default specified)
  *default: 1
-D [path]
  Scan specific directory, recursive (overriding the automatic media folder detection).
  *default: taken from the database.
-F [full path to file]
  Work on a specific file.
-S [1/0]
  Perform subtitles download from
  *This will work for TV shows only.
  *default: 0 - do not download subtitles.
-DBP [whatever]
  Specify DB password
  *default: taken from mysql.txt file, which is under /home/mythtv/.mythtv/.
-MOVIE_SNAP [0/1/2]
  0 - take the official poster from
  1 - generate snapshot from file.
  2 - take from an external script.
  *default: 0 - take from
-TV_SNAP [0/1]
  For TV shows - generate snapshot from file (1), or take it from (0)
  *default: 1 - generate a snapshot from the video file.
  Change the default snapshot width (height is calculated by the aspect ratio of the video)
  *default: 320
-THUMB_OFFSET [seconds]
  Take the video snapshot image from the specified time.
  *default: -1 which means take a random point in the video file.
-TV_TITLE_TYPE [0/1/2]
  0-[File name]
  1(default)-[Episode number]: [Episode name]
  2-[Show] S[Season number]E[Episode number] [Episode name]
  3-[Show] [Season number]x[Episode number] [Episode name]
  0-[File name]
  1(default)-[Movie name from]
-ARTFOLDER [full path to folder]
  Override Art-Work folder.
  *default: taken from the database.
-HOST [hostname]
  Override the automatic hostname resolving.

NFO Files

Sometimes the script fails to detect the correct TV show or movie (Battlestar Galactica is a great example for this, since the script thinks it is BSG 1978...). For that reason, it is possible to "help" the script by giving it hints. The hints are given by adding file with ".nfo" extension. There are several types:

  • Overriding a movie - create an nfo file with the same filename as the movie, e.g., for "Wolverine.avi" create "Wolverine.nfo" in the video file folder. The file should include (wherever you want inside of it) the following:
<imdb id="tt0458525"/>
  • Overriding a show - create an nfo file with any filename you like, e.g., for "Battlestar Galactica" create "bsg.nfo" in the video files folder. The file should include (wherever you want inside of it) the following:
<thetvdb seriesid="73545"/>
  • Overriding an episode - create an nfo file with the same filename as the video file, e.g., for "Robot Chicken Star Wars Special Episode II.avi" create "Robot Chicken Star Wars Special Episode II.nfo" in the video file folder. The file should include (wherever you want inside of it) the following:
<thetvdb episodeid="406974"/>

or for "Family.Guy.Star.Wars.avi" create "Family.Guy.Star.Wars.nfo" which contains:

<thetvdb seriesid="75978" season="6" episode="1"/>
  • Ignoring a file - sometimes you'll like the script to skip a file, maybe you have really good meta-data for it, or maybe you do not want any meta-data for it. Create an nfo file with the same filename as the video file. The file should include the following:
  • Simple meta-data - sometimes you'll like the script to just get the snapshot for the file (family videos is a good examle). Create an nfo file with the same filename as the video file. The file should include the following:


  • IMDB ID can be located by searching the movie in, and taking it from the movie's page URL.
  • The-TV-DB ID can be locate by searching the show in, and copying it from the search result tables (it is in the Show ID column), or you can copy it from the series page URL.
  • Using, it is possible to retrieve the currently store metadata in the database into nfo files.

User Contributed Tips

Non-English metadata / Metadata for translated show names

Change every /en.xml (3 occurencies) in to /de.xml (it.xml,dk.xml etc.) to retrieve german (italian...) metadata.

Rename the new script to or something.

Keep the old one around, just in case there's no german info. :)