Difference between revisions of "FillMythMetadata.pl"

From MythTV Official Wiki
Jump to: navigation, search
(hi-res)
m (moved Fill mythvideo metadata.pl to FillMythMetadata.pl: The script name has changed due to extreme refactor)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''fill_mythvideo_metadata.pl''' is perl script written by [[User:Menny | 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.
+
{{Todo box|Script needs to be updated to use [[Perl bindings]] for database credentials.}}
  
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 [http://www.thetvdb.com thetvdb.com] or [http://www.imdb.com imdb.com], 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).
+
'''FillMythMetadata.pl''' is perl script written by [[User:Menny | 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.
  
The latest version can be downloaded from [http://fill-mythvideo-metadata.googlecode.com/svn/trunk/fill_mythvideo_metadata.pl here]
+
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 [http://www.thetvdb.com thetvdb.com] or [http://www.themoviedb.org/ themoviedb.org], 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.23 only (see #Main features).
 +
 
 +
The latest version can be downloaded from [https://code.google.com/p/fill-mythvideo-metadata/downloads/list here]
 
==Screenshots==
 
==Screenshots==
 
Movies files under [[MythVideo]] after running this script.
 
Movies files under [[MythVideo]] after running this script.
 
<gallery>
 
<gallery>
Image:Mythvideo_covers.JPG|Movies under MythVideo. Posters were retrieved automatically from [http://imdb.com imdb.com].
+
Image:Mythvideo_covers.JPG|Movies under MythVideo. Posters were retrieved automatically from [http://www.themoviedb.org/ themoviedb.org].
Image:Mythvideo movie info.JPG|Movie information. Information was retrieved automatically from [http://imdb.com imdb.com].
+
Image:Mythvideo movie info.JPG|Movie information. Information was retrieved automatically from [http://www.themoviedb.org/ themoviedb.org].
 
</gallery>
 
</gallery>
 
TV shows files under [[MythVideo]] after running this script.
 
TV shows files under [[MythVideo]] after running this script.
Line 18: Line 22:
 
==Main features==
 
==Main features==
 
*Fill meta-data for movies and TV shows, by parsing the filenames:
 
*Fill meta-data for movies and TV shows, by parsing the filenames:
**Locating the most similar movie based on [http://en.wikipedia.org/wiki/Levenshtein_distance Levenshtein Distance algorithm] and removal of redundant suffixes. Meta-data is retrieved from [http://www.imdb.com imdb.com].
+
**Locating the most similar movie based on [http://en.wikipedia.org/wiki/Levenshtein_distance Levenshtein Distance algorithm] and removal of redundant suffixes. Meta-data is retrieved from [http://www.themoviedb.org/ themoviedb.org]
 
**Locating TV shows by parsing the filename for show name, season number and episode number. Meta-data is retrieved from [http://www.thetvdb.com thetvdb.com].
 
**Locating TV shows by parsing the filename for show name, season number and episode number. Meta-data is retrieved from [http://www.thetvdb.com thetvdb.com].
 
**Allow overriding the automatic parsing by special [[#NFO_Files|nfo files]]:
 
**Allow overriding the automatic parsing by special [[#NFO_Files|nfo files]]:
Line 38: Line 42:
 
**Cover art folder.
 
**Cover art folder.
 
**Allowed file extensions.
 
**Allowed file extensions.
 
+
*Supports Parental Level detection.
 +
*Special MythTV tags:
 +
**Season and episode number parsing
 +
**season banner
 
==Basic Usage==
 
==Basic Usage==
Usually, the best option to run '''fill_mythvideo_metadata.pl''' 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.
+
Usually, the best option to run '''FillMythMetadata.pl''' 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:
 
It is suggested to use this script in a crontab job:
  00 06 * * * /home/mythtv/fill_mythvideo_metadata.pl
+
  00 06 * * * /home/mythtv/FillMythMetadata.pl
 
*replace '''/home/mythtv/''' with the path to the location of the script.
 
*replace '''/home/mythtv/''' with the path to the location of the script.
  
Line 49: Line 56:
  
 
== Help Output ==
 
== Help Output ==
'''fill_mythvideo_metadata.pl''' usage:
+
'''FillMythMetadata.pll''' usage:
 
   
 
   
 
  -N [1/0]
 
  -N [1/0]
Line 72: Line 79:
  
 
  -MOVIE_SNAP [0/1/2]
 
  -MOVIE_SNAP [0/1/2]
   0 - take the official poster from imdb.com (0)
+
   0 - take the official poster from [http://www.themoviedb.org/ themoviedb.org].
 
   1 - generate snapshot from file.
 
   1 - generate snapshot from file.
 
   2 - take from an external script.
 
   2 - take from an external script.
   *default: 0 - take from imdb.com.
+
   *default: 0 - take from [http://www.themoviedb.org/ themoviedb.org].
  
 
  -TV_SNAP [0/1]
 
  -TV_SNAP [0/1]
Line 97: Line 104:
 
  -MOVIE_TITLE_TYPE [0/1/2]
 
  -MOVIE_TITLE_TYPE [0/1/2]
 
   0-[File name]
 
   0-[File name]
   1('''default''')-[Movie name from IMDB]
+
   1('''default''')-[Movie name from [http://www.themoviedb.org/ themoviedb.org]]
  
 
  -ARTFOLDER [full path to folder]
 
  -ARTFOLDER [full path to folder]
Line 126: Line 133:
 
*IMDB ID can be located by searching the movie in [http://www.imdb.com imdb.com], and taking it from the movie's page URL.
 
*IMDB ID can be located by searching the movie in [http://www.imdb.com imdb.com], and taking it from the movie's page URL.
 
*The-TV-DB ID can be locate by searching the show in [http://thetvdb.com thetvdb.com], 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.
 
*The-TV-DB ID can be locate by searching the show in [http://thetvdb.com thetvdb.com], 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 [[Createnfos.py]], it is possible to retrieve the currently store metadata in the database into nfo files.
  
 
==User Contributed Tips==
 
==User Contributed Tips==
  
 
[[Category:Scripts]]
 
[[Category:Scripts]]
 +
 +
'''Non-English metadata / Metadata for translated show names'''
 +
 +
 +
Change every /en.xml (3 occurencies) in FillMythMetadata.pl
 +
to /de.xml (it.xml,dk.xml etc.) to retrieve german (italian...) metadata.
 +
 +
 +
Rename the new script to f...metadata_de.pl or something.
 +
 +
Keep the old one around, just in case there's no german info. :)

Latest revision as of 09:42, 20 August 2010

List-add.png Todo: Script needs to be updated to use Perl bindings for database credentials.

FillMythMetadata.pl 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 thetvdb.com or themoviedb.org, 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.23 only (see #Main features).

The latest version can be downloaded from here

Screenshots

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 themoviedb.org
    • Locating TV shows by parsing the filename for show name, season number and episode number. Meta-data is retrieved from thetvdb.com.
    • Allow overriding the automatic parsing by special nfo files:
      • Specify the movie ID (from imdb.com) for a specific video file.
      • Specify the series ID (from thetvdb.com) 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 FillMythMetadata.pl 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/FillMythMetadata.pl
  • 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

FillMythMetadata.pll 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 tvsubtitles.com
  *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 themoviedb.org.
  1 - generate snapshot from file.
  2 - take from an external script.
  *default: 0 - take from themoviedb.org.
-TV_SNAP [0/1]
  For TV shows - generate snapshot from file (1), or take it from thetvdb.com (0)
  *default: 1 - generate a snapshot from the video file.
-SNAPSHOT_WIDTH [number]
  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]
-MOVIE_TITLE_TYPE [0/1/2]
  0-[File name]
  1(default)-[Movie name from themoviedb.org]
-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:
<no_update/>
  • 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:
<simple_update/>

Note:

  • IMDB ID can be located by searching the movie in imdb.com, and taking it from the movie's page URL.
  • The-TV-DB ID can be locate by searching the show in thetvdb.com, 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 Createnfos.py, 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 FillMythMetadata.pl to /de.xml (it.xml,dk.xml etc.) to retrieve german (italian...) metadata.


Rename the new script to f...metadata_de.pl or something.

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