[HOWTO] Develop a new grabber and don't die trying

Discussion in 'Submit: Movie Info Grabbers' started by morfius, September 7, 2014.

  1. morfius

    morfius Portal Pro

    November 10, 2011
    Likes Received:
    Technician Engineer
    +42 / 0
    Home Country:
    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

    Code (Text):
    1.         void button1_Click(object sender, EventArgs e)
    2.         {
    3.             Grabber g = new Grabber();
    4.             try
    5.             {
    6.                 //add your test titles to this ArrayList
    7.                 ArrayList movieTitles = new ArrayList() { "Memorias de África" };
    8.                 ArrayList elements = new ArrayList();
    9.                 foreach (string movieTitle in movieTitles)
    10.                 {
    11.                     g.FindFilm(movieTitle, 35, elements);
    12.                     IMDBMovie movieDetails = new IMDBMovie();
    13.                     if (elements.Count > 0)
    14.                     {
    15.                         if (g.GetDetails((IMDB.IMDBUrl)elements[0], ref movieDetails))
    16.                         {//only first element
    17.                             textBox1.Text = movieDetails.Title + Environment.NewLine + movieDetails.Year + Environment.NewLine + movieDetails.Genre;
    18.                             //chek your results
    19.                             Debugger.Break();
    20.                         }
    21.                     }
    22.                 }
    23.             }
    24.             catch (Exception ex)
    25.             {
    26.                 Debugger.Break();
    27.             }
    29.         }
    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")
    Code (Text):
    1. [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
    2. [2014-09-07 11:56:10,532] [Log    ] [10       ] [INFO ] - GrabberMP1 Found(s) 1 element(s) searching Memorias de África with iLimit=35
    3. [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
    4. [2014-09-07 13:18:36,283] [Log    ] [10       ] [INFO ] - GrabberMP1 Found(s) 1 element(s) searching Memorias de África with iLimit=35
    5. [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!)
    Code (Text):
    1. [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
    2. [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
    Code (Text):
    1. ::UpdateGrabberMP1.cmd
    2. ::change path ACCORDING YOUR LANGUAGE AND S.O. (%MediaPortalConfig%)
    3. ::Delete previous LOG
    4. del "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\log\Configuration.log"
    5. del "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\log\Configuration-Error.log"
    6. copy /y "GrabberMP1.cs" "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\scripts\MovieInfo\GrabberMP1.csscript"
    7. ::uncomment next line if you use third party libraries
    8. ::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
    Code (Text):
    1.             string[] arrDir = new string[] { @"Folder's Film" };
    2.             foreach (string sDir in arrDir)
    3.                 foreach (FileInfo file in new DirectoryInfo(sDir).GetFiles())
    4.                     if ((file.Extension.ToLower().Contains("avi")) | (file.Extension.ToLower().Contains("mkv")))
    5.                         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!

    Attached Files:

    Last edited: September 8, 2014
    • Like Like x 3

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.


  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!