home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Submit: Movie Info Grabbers
[HOWTO] Develop a new grabber and don't die trying
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="morfius" data-source="post: 1099004" data-attributes="member: 116650"><p><span style="color: green">Full Source Code is available as attachment</span></p><p></p><p>First of all, i don't know if this is the right place for this [HOWTO]. It is a supplement to the wiki-guide <a href="http://wiki.team-mediaportal.com/1_MEDIAPORTAL_1/18_Contribute/5_Localization/Movie_Info_Scripts%2F%2FGrabbers" target="_blank">Movie Info Scripts/Grabbers</a></p><p></p><p>I hope this <em>miniwiki-howto-practical guide</em> 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.</p><p><em><strong>The audience for this post is restless people with some knowledges in any programming language</strong></em>. You dont need to be Bill Gates, but perhaps .. become in a developer</p><p>Download and run the entire code of MediaPortal is crazy. For debug the script, you need only emulate the involved procedures.</p><p>So .. to work!</p><p></p><p><strong>Prerequisites:</strong></p><ul> <li data-xf-list-type="ul">Visual Studio Express or SharpDevelop (both free)</li> </ul> <ul> <li data-xf-list-type="ul">Media Portal 1 (latest version) installed and functional <em>(you don't need full source code)</em></li> </ul><p></p><p><strong>Steps:</strong></p><ul> <li data-xf-list-type="ul">Create a new solution, with two projects, one WindowsFormApp and one Class</li> </ul> <ul> <li data-xf-list-type="ul">WindowsFormApp is your test project, and Class are your future script</li> </ul><p><span style="color: red"><strong>Mandatory:</strong> <em>(re-reference in Sample Source)</em></span></p><ul> <li data-xf-list-type="ul">Add a reference in WindowsFormApp to your Class</li> </ul> <ul> <li data-xf-list-type="ul">Add a reference in both projects to three libraries (usually in "C:\Program Files\Team MediaPortal\MediaPortal")</li> </ul><p>core.dll</p><p>Databases.dll</p><p>Utils.dll</p><ul> <li data-xf-list-type="ul">Add also at start of Class, before the <span style="color: blue"><em>using clausule</em></span></li> </ul><p><span style="color: GREEN">//css_reference "core.dll";</span></p><p><span style="color: GREEN">//css_reference "Databases.dll";</span></p><p><span style="color: GREEN">//css_reference "utils.dll";</span></p><ul> <li data-xf-list-type="ul">You can add any additional third party reference, but don't remember add also <span style="color: green">//css_reference "MyLibrary.dll";</span> In this case you need copy the Library to the Media Portal Folder</li> </ul> <ul> <li data-xf-list-type="ul">Add one Button and one TextBox to Form, copy necessary code from attachment, and ... <em>Here We Go</em> ...Run</li> </ul> <ul> <li data-xf-list-type="ul">You can use directly code from attachment</li> </ul> <ul> <li data-xf-list-type="ul"><em>That's All</em></li> </ul><p></p><p><em>Additional observations</em></p><ul> <li data-xf-list-type="ul">You can use <em>LINQ</em> but add also <span style="color: green">//css_reference "System.Core.dll";</span></li> </ul> <ul> <li data-xf-list-type="ul">You need to learn about RegEx, or use <a href="https://htmlagilitypack.codeplex.com/" target="_blank">HAP</a> at begining</li> </ul> <ul> <li data-xf-list-type="ul">SharpDevelop provides a tool for evaluate RegEx</li> </ul> <ul> <li data-xf-list-type="ul">Don't worry about actors and actresses, MP1 use only theirs internal scripts, so better, don't add Cast.</li> </ul> <ul> <li data-xf-list-type="ul">At this time MP1 uses .NET Framework 4.0, so use the same CLR</li> </ul> <ul> <li data-xf-list-type="ul">You can use other existents grabbers. But only one at time, because <span style="font-size: 12px"><strong>you can't set NAMESPACE in class</strong></span></li> </ul><p>divide and conquer</p><p></p><p>emulation</p><p>[CODE] void button1_Click(object sender, EventArgs e)</p><p> {</p><p> Grabber g = new Grabber();</p><p> try</p><p> {</p><p> //add your test titles to this ArrayList </p><p> ArrayList movieTitles = new ArrayList() { "Memorias de África" };</p><p> ArrayList elements = new ArrayList();</p><p> foreach (string movieTitle in movieTitles)</p><p> {</p><p> g.FindFilm(movieTitle, 35, elements);</p><p> IMDBMovie movieDetails = new IMDBMovie();</p><p> if (elements.Count > 0)</p><p> {</p><p> if (g.GetDetails((IMDB.IMDBUrl)elements[0], ref movieDetails))</p><p> {//only first element</p><p> textBox1.Text = movieDetails.Title + Environment.NewLine + movieDetails.Year + Environment.NewLine + movieDetails.Genre;</p><p> //chek your results</p><p> Debugger.Break();</p><p> }</p><p> }</p><p> }</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> Debugger.Break();</p><p> }</p><p></p><p> }[/CODE]</p><p>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")</p><p>[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</p><p>[2014-09-07 11:56:10,532] [Log ] [10 ] [INFO ] - GrabberMP1 Found(s) 1 element(s) searching Memorias de África with iLimit=35</p><p>[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</p><p>[2014-09-07 13:18:36,283] [Log ] [10 ] [INFO ] - GrabberMP1 Found(s) 1 element(s) searching Memorias de África with iLimit=35</p><p>[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[/CODE]</p><p>Result in TextBox after press Start</p><p><a href="http://postimg.org/image/tse2o2057/" target="_blank"><img src="http://s25.postimg.org/tse2o2057/Test_Grabber_MP1.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></p><p></p><p><span style="font-size: 18px"><span style="color: blue">Welcome</span> to the <span style="color: red">Real World.</span></span> (choose <span style="color: red">red</span> or <span style="color: blue">blue</span>)</p><p></p><p>At this time, <strong>i strongly suggest to use Media Portal Configuration</strong></p><p>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. <strong>(Don't forget move it to their original folder!)</strong></p><p>[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</p><p>[2014-09-08 12:35:45,885] [Config ] [IMDBDetails] [ERROR] - IMDB GetIMDBMovieActorsList error: Object reference not set to an instance of an object.[/CODE]</p><p></p><p>Scripts selection</p><p><a href="http://postimg.org/image/h9svtqdrv/" target="_blank"><img src="http://s25.postimg.org/h9svtqdrv/Scripts_selection.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></p><p>This cmd can help you every time that you compile the script, before run in <em>real</em> Media Portal</p><p>[CODE]::UpdateGrabberMP1.cmd</p><p>::change path ACCORDING YOUR LANGUAGE AND S.O. (%MediaPortalConfig%)</p><p>::Delete previous LOG</p><p>del "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\log\Configuration.log"</p><p>del "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\log\Configuration-Error.log"</p><p>copy /y "GrabberMP1.cs" "C:\Documents and Settings\All Users\Datos de programa\Team MediaPortal\MediaPortal\scripts\MovieInfo\GrabberMP1.csscript"</p><p>::uncomment next line if you use third party libraries</p><p>::copy /y "MyLibrary.DLL." "C:\Program Files\Team MediaPortal\MediaPortal\MyLibrary.DLL"[/CODE]</p><p>You can use your favourite Folder's Film as movieTitles Array</p><p><a href="http://postimg.org/image/9v3k1crwb/" target="_blank"><img src="http://s25.postimg.org/9v3k1crwb/Video_Folders.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></p><p>This code emulates Video Folders</p><p>[CODE] string[] arrDir = new string[] { @"Folder's Film" };</p><p> foreach (string sDir in arrDir)</p><p> foreach (FileInfo file in new DirectoryInfo(sDir).GetFiles())</p><p> if ((file.Extension.ToLower().Contains("avi")) | (file.Extension.ToLower().Contains("mkv")))</p><p> movieTitles .Add(new string[] { file.Name.Replace(file.Extension, ""), string.Empty });[/CODE]</p><p>Or add a single title, press Lookup and get the result</p><p><a href="http://postimg.org/image/4tw5zzkfv/" target="_blank"><img src="http://s25.postimg.org/4tw5zzkfv/Result.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></p><p></p><p>Any comments are welcome.</p><p></p><p>Greetings from Spain!</p></blockquote><p></p>
[QUOTE="morfius, post: 1099004, member: 116650"] [COLOR=green]Full Source Code is available as attachment[/COLOR] First of all, i don't know if this is the right place for this [HOWTO]. It is a supplement to the wiki-guide [URL=http://wiki.team-mediaportal.com/1_MEDIAPORTAL_1/18_Contribute/5_Localization/Movie_Info_Scripts%2F%2FGrabbers]Movie Info Scripts/Grabbers[/URL] I hope this [i]miniwiki-howto-practical guide[/i] 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. [i][b]The audience for this post is restless people with some knowledges in any programming language[/b][/i]. 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! [b]Prerequisites:[/b] [LIST]Visual Studio Express or SharpDevelop (both free)[/LIST] [LIST]Media Portal 1 (latest version) installed and functional [i](you don't need full source code)[/i][/LIST] [b]Steps:[/b] [LIST]Create a new solution, with two projects, one WindowsFormApp and one Class[/LIST] [LIST]WindowsFormApp is your test project, and Class are your future script[/LIST] [COLOR=red][b]Mandatory:[/b] [i](re-reference in Sample Source)[/i][/COLOR] [LIST]Add a reference in WindowsFormApp to your Class[/LIST] [LIST]Add a reference in both projects to three libraries (usually in "C:\Program Files\Team MediaPortal\MediaPortal")[/LIST] core.dll Databases.dll Utils.dll [LIST]Add also at start of Class, before the [COLOR=blue][i]using clausule[/i][/COLOR][/LIST] [COLOR=GREEN]//css_reference "core.dll"; //css_reference "Databases.dll"; //css_reference "utils.dll";[/COLOR] [LIST]You can add any additional third party reference, but don't remember add also [COLOR=green]//css_reference "MyLibrary.dll";[/COLOR] In this case you need copy the Library to the Media Portal Folder[/LIST] [LIST]Add one Button and one TextBox to Form, copy necessary code from attachment, and ... [I]Here We Go[/I] ...Run[/LIST] [LIST]You can use directly code from attachment[/LIST] [LIST][I]That's All[/I][/LIST] [i]Additional observations[/i] [LIST]You can use [i]LINQ[/i] but add also [color=green]//css_reference "System.Core.dll";[/color][/LIST] [LIST]You need to learn about RegEx, or use [URL=https://htmlagilitypack.codeplex.com/]HAP[/URL] at begining[/LIST] [LIST]SharpDevelop provides a tool for evaluate RegEx[/LIST] [LIST]Don't worry about actors and actresses, MP1 use only theirs internal scripts, so better, don't add Cast.[/LIST] [LIST]At this time MP1 uses .NET Framework 4.0, so use the same CLR[/LIST] [LIST]You can use other existents grabbers. But only one at time, because [size=3][b]you can't set NAMESPACE in class[/b][/size][/LIST] 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(); } }[/CODE] 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[/CODE] Result in TextBox after press Start [url=http://postimg.org/image/tse2o2057/][img]http://s25.postimg.org/tse2o2057/Test_Grabber_MP1.jpg[/img][/url] [size=5][COlor=blue]Welcome[/COlor] to the [COlor=red]Real World.[/COlor][/size][COlor=red][/COlor] (choose [COlor=red]red[/COlor] or [COlor=blue]blue[/COlor]) At this time, [b]i strongly suggest to use Media Portal Configuration[/b] 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. [b](Don't forget move it to their original folder!)[/b] [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.[/CODE] Scripts selection [url=http://postimg.org/image/h9svtqdrv/][img]http://s25.postimg.org/h9svtqdrv/Scripts_selection.jpg[/img][/url] This cmd can help you every time that you compile the script, before run in [i]real[/i] 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"[/CODE] You can use your favourite Folder's Film as movieTitles Array [url=http://postimg.org/image/9v3k1crwb/][img]http://s25.postimg.org/9v3k1crwb/Video_Folders.jpg[/img][/url] 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 });[/CODE] Or add a single title, press Lookup and get the result [url=http://postimg.org/image/4tw5zzkfv/][img]http://s25.postimg.org/4tw5zzkfv/Result.jpg[/img][/url] Any comments are welcome. Greetings from Spain! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Submit: Movie Info Grabbers
[HOWTO] Develop a new grabber and don't die trying
Contact us
RSS
Top
Bottom