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

morfius

Portal Pro
November 10, 2011
40
48
55
Valladolid
Home Country
Spain Spain
Country flag
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!

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

Steps:
  • 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")
core.dll
Databases.dll
Utils.dll
  • 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

emulation
Code:
        void button1_Click(object sender, EventArgs e)
        {
            Grabber g = new Grabber();
            try
            {
                //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
                            Debugger.Break();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debugger.Break();
            }

        }
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:
[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!)
Code:
[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
Code:
::UpdateGrabberMP1.cmd
::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
Code:
            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!
 

Attachments

  • TestGrabberMP1.zip
    16.4 KB
Last edited:

Users who are viewing this thread

Similar threads

That's awesome news! I can't say how I'm happy to help fellow XP user :D
That's awesome news! I can't say how I'm happy to help fellow XP user :D
Ok, I’m back, MP1.14 has been working great for the last few years, up until last month when a recording overwrote the hard drive...
Replies
18
Views
2K
So, for anyone that would like EPG data for radio stations in the US, here's my finished grabber. You'll need to customize it much like what's required for the IMDb US TV grabber. Go to DAR.fm to figure out the "siteId" (a 4 digit number) for each station you'd like guide data for, and modify the www_dar_fm_com.xml file according to...
So, for anyone that would like EPG data for radio stations in the US, here's my finished grabber. You'll need to customize it much...
I'm attempting to create a WebEPG grabber for US radio stations using DAR.fm as a source. I don't appear to be getting any errors...
Replies
4
Views
2K
yo mismo lo pruebo, dime lo que tengo que hacer. Por cierto,usais con normalidad mp2?,yo lo instalé,pero tuve problemas con las sintonizadoras de televisión,ya no recuerdo,pero creo que no me funcionaba la skystar2
yo mismo lo pruebo, dime lo que tengo que hacer. Por cierto,usais con normalidad mp2?,yo lo instalé,pero tuve problemas con las...
Updated APIFilmAffinityIMDbMP1.v1.1 2014/12/30 Aprovechando las vacaciones, he desarrollado un nuevo script para la obtención de...
Replies
26
Views
15K
Tried with a custom LAV build from @Sebastiii (0.68.5 git) and got a bit further :) - Works with MPC-HC (no image corruption) as subtitle engine however no subtitle selection for that sample - With DirectVobSub I get the subtitle selection however also the image corruption back So while not perfect at least I can have MPC-HC for...
Tried with a custom LAV build from @Sebastiii (0.68.5 git) and got a bit further :) - Works with MPC-HC (no image corruption) as...
Hi, Been trying out some 2160P releases recently and came across an odd issue with HEVC playback, it will run at a reduced...
Replies
16
Views
4K
Sorry to hear that you have to go to hospital. I hope that all wil be fine. In fact you have already all the information needed. The database name and the table name are the same than in mySQL for ArgusTV. How can I provide you the Backup file ?
Sorry to hear that you have to go to hospital. I hope that all wil be fine. In fact you have already all the information needed...
Hi. I like to introduce our latest tool, called "EPG-Buddy". This program should make EPG grabbing as easy as possible. Up to now a...
Replies
445
Views
120K
Top Bottom