[HOWTO] Develop a new grabber and don't die trying (1 Viewer)


Portal Pro
November 10, 2011
Spain Spain
Full Source Code is available as attachment

First of all, i don't know if this is the right place for this [HOWTO]. It is a supplement to the wiki-guide Movie Info Scripts/Grabbers

I hope this miniwiki-howto-practical guide help you to build a new script in a few steps. At this time only a few of scripts (only four languages) are availables. My point of view, it is really necessary to read the information about every Film in your native language.
The audience for this post is restless people with some knowledges in any programming language. You dont need to be Bill Gates, but perhaps .. become in a developer
Download and run the entire code of MediaPortal is crazy. For debug the script, you need only emulate the involved procedures.
So .. to work!

  • Visual Studio Express or SharpDevelop (both free)
  • Media Portal 1 (latest version) installed and functional (you don't need full source code)

  • Create a new solution, with two projects, one WindowsFormApp and one Class
  • WindowsFormApp is your test project, and Class are your future script
Mandatory: (re-reference in Sample Source)
  • Add a reference in WindowsFormApp to your Class
  • Add a reference in both projects to three libraries (usually in "C:\Program Files\Team MediaPortal\MediaPortal")
  • Add also at start of Class, before the using clausule
//css_reference "core.dll";
//css_reference "Databases.dll";
//css_reference "utils.dll";

  • You can add any additional third party reference, but don't remember add also //css_reference "MyLibrary.dll"; In this case you need copy the Library to the Media Portal Folder
  • Add one Button and one TextBox to Form, copy necessary code from attachment, and ... Here We Go ...Run
  • You can use directly code from attachment
  • That's All

Additional observations
  • You can use LINQ but add also //css_reference "System.Core.dll";
  • You need to learn about RegEx, or use HAP at begining
  • SharpDevelop provides a tool for evaluate RegEx
  • Don't worry about actors and actresses, MP1 use only theirs internal scripts, so better, don't add Cast.
  • At this time MP1 uses .NET Framework 4.0, so use the same CLR
  • You can use other existents grabbers. But only one at time, because you can't set NAMESPACE in class
divide and conquer

        void button1_Click(object sender, EventArgs e)
            Grabber g = new Grabber();
                //add your test titles to this ArrayList 
                ArrayList movieTitles = new ArrayList() { "Memorias de África" };
                ArrayList elements = new ArrayList();
                foreach (string movieTitle in movieTitles)
                    g.FindFilm(movieTitle, 35, elements);
                    IMDBMovie movieDetails = new IMDBMovie();
                    if (elements.Count > 0)
                        if (g.GetDetails((IMDB.IMDBUrl)elements[0], ref movieDetails))
                        {//only first element
                            textBox1.Text = movieDetails.Title + Environment.NewLine + movieDetails.Year + Environment.NewLine + movieDetails.Genre;
                            //chek your results
            catch (Exception ex)

Media Porrtal uses log4net (you don't need learn about this). Check the Log ("C:\Users\All Users\Team MediaPortal\MediaPortal\Log\TestGrabberMP1.vshost.log")
[2014-09-07 11:43:47,307] [Log    ] [10       ] [INFO ] - GrabberMP1 Details added for Out of Africa; url=http://www.sensacine.com/peliculas/pelicula-1592
[2014-09-07 11:56:10,532] [Log    ] [10       ] [INFO ] - GrabberMP1 Found(s) 1 element(s) searching Memorias de África with iLimit=35
[2014-09-07 11:56:10,990] [Log    ] [10       ] [INFO ] - GrabberMP1 Details added for Out of Africa; url=http://www.sensacine.com/peliculas/pelicula-1592
[2014-09-07 13:18:36,283] [Log    ] [10       ] [INFO ] - GrabberMP1 Found(s) 1 element(s) searching Memorias de África with iLimit=35
[2014-09-07 13:18:36,739] [Log    ] [10       ] [INFO ] - GrabberMP1 Details added for Out of Africa; url=http://www.sensacine.com/peliculas/pelicula-1592
Result in TextBox after press Start

Welcome to the Real World. (choose red or blue)

At this time, i strongly suggest to use Media Portal Configuration
For debugging purposes, it is better don't use the internal scripts, so move it to a backup folder. log4net will report about this error like this. (Don't forget move it to their original folder!)
[2014-09-08 12:35:45,765] [Config ] [IMDBDetails] [ERROR] - InternalActorMoviesGrabber LoadScript() - grabber script not found: C:\Documents and Settings\All Users.WINDOWS\Datos de programa\Team MediaPortal\MediaPortal\scripts\InternalActorMoviesGrabber.csscript
[2014-09-08 12:35:45,885] [Config ] [IMDBDetails] [ERROR] - IMDB GetIMDBMovieActorsList error: Object reference not set to an instance of an object.
Scripts selection

This cmd can help you every time that you compile the script, before run in real Media Portal
::change path ACCORDING YOUR LANGUAGE AND S.O. (%MediaPortalConfig%)
::Delete previous LOG
del "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\log\Configuration.log"
del "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\log\Configuration-Error.log"
copy /y "GrabberMP1.cs" "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\scripts\MovieInfo\GrabberMP1.csscript"
::uncomment next line if you use third party libraries
::copy /y "MyLibrary.DLL."   "C:\Program Files\Team MediaPortal\MediaPortal\MyLibrary.DLL"
You can use your favourite Folder's Film as movieTitles Array

This code emulates Video Folders
            string[] arrDir = new string[] { @"Folder's Film" };
            foreach (string sDir in arrDir)
                foreach (FileInfo file in new DirectoryInfo(sDir).GetFiles())
                    if ((file.Extension.ToLower().Contains("avi")) | (file.Extension.ToLower().Contains("mkv")))
                        movieTitles .Add(new string[] { file.Name.Replace(file.Extension, ""), string.Empty });
Or add a single title, press Lookup and get the result

Any comments are welcome.

Greetings from Spain!


Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom