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
The Movie Database... first script, first trouble
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="Fred777" data-source="post: 988737" data-attributes="member: 138955"><p>Hi @<a href="https://forum.team-mediaportal.com/members/lopez-tuparles.92530/" target="_blank">lopez.tuparles</a>,</p><p> </p><p>I had a look at your script as @<a href="https://forum.team-mediaportal.com/members/megahorst.22213/" target="_blank">megahorst</a> told me about it.</p><p>First point is that I didn't noticed the problem with "<span style="font-family: 'Arial'"> do not work. The </span><span style="font-family: 'Arial'">" that you reported @<a href="https://forum.team-mediaportal.com/members/megahorst.22213/" target="_blank">megahorst</a>. The movie Otto - Der film seems to work fine for me, everything (except empty fields of course) are well retrieved. But perhaps I missed something, could you provide a screenshot on configuration tool?</span></p><p> </p><p><span style="font-family: 'Arial'">Second point regarding code is that it could be clearly optimized:</span></p><p><span style="font-family: 'Arial'">1. You should not retrieve movie details in FindFilm() (call to GetTMDBMovieDetails()) this can make search very long on some movies, try with "Cars" you will understand</span></p><p><span style="font-family: 'Arial'">2. You can really simplify your code using deserialization functionalities of JavaScriptSerializer object to parse JSON. This allow to create a dictionnary in which you can easily navigate to retrieve data. Here is a small code example:</span></p><p> </p><p><span style="font-family: 'Arial'"> JavaScriptSerializer deserializer = new JavaScriptSerializer();</span></p><p><span style="font-family: 'Arial'"> Dictionary<string, object> deserializedDictionary = deserializer.Deserialize<Dictionary<string, object>>(reader.ReadToEnd());</span></p><p><span style="font-family: 'Arial'"> Dictionary<string, object> movie = deserializedDictionary["movie"] as Dictionary<string, object>;</span></p><p> </p><p><span style="font-family: 'Arial'"> if (movie.ContainsKey("title") == true)</span></p><p><span style="font-family: 'Arial'"> movieDetails.Title = (string)movie["title"];</span></p><p><span style="font-family: 'Arial'"> else</span></p><p><span style="font-family: 'Arial'"> movieDetails.Title = (string)movie["originalTitle"];</span></p><p> </p><p>(where "movie" is the name of the root object, I don't know its name in TMDB as I have not tested. I used this script for Allocine API data retrieval before they improved their security on the API few days ago)</p><p><span style="font-family: 'Arial'">This will avoid you to use regular expression and thus avoid data extraction problems. (I hate regular expressions)</span></p><p><span style="font-family: 'Arial'">Let me know if you need help on this (you can PM me in French)</span></p><p><span style="font-family: 'Arial'">Fred</span></p></blockquote><p></p>
[QUOTE="Fred777, post: 988737, member: 138955"] Hi @[URL='https://forum.team-mediaportal.com/members/lopez-tuparles.92530/']lopez.tuparles[/URL], I had a look at your script as @[URL='https://forum.team-mediaportal.com/members/megahorst.22213/']megahorst[/URL] told me about it. First point is that I didn't noticed the problem with "[FONT=Arial] do not work. The [/FONT][FONT=Arial]" that you reported @[URL='https://forum.team-mediaportal.com/members/megahorst.22213/']megahorst[/URL]. The movie Otto - Der film seems to work fine for me, everything (except empty fields of course) are well retrieved. But perhaps I missed something, could you provide a screenshot on configuration tool?[/FONT] [FONT=Arial]Second point regarding code is that it could be clearly optimized:[/FONT] [FONT=Arial]1. You should not retrieve movie details in FindFilm() (call to GetTMDBMovieDetails()) this can make search very long on some movies, try with "Cars" you will understand[/FONT] [FONT=Arial]2. You can really simplify your code using deserialization functionalities of JavaScriptSerializer object to parse JSON. This allow to create a dictionnary in which you can easily navigate to retrieve data. Here is a small code example:[/FONT] [FONT=Arial] JavaScriptSerializer deserializer = new JavaScriptSerializer();[/FONT] [FONT=Arial] Dictionary<string, object> deserializedDictionary = deserializer.Deserialize<Dictionary<string, object>>(reader.ReadToEnd());[/FONT] [FONT=Arial] Dictionary<string, object> movie = deserializedDictionary["movie"] as Dictionary<string, object>;[/FONT] [FONT=Arial] if (movie.ContainsKey("title") == true)[/FONT] [FONT=Arial] movieDetails.Title = (string)movie["title"];[/FONT] [FONT=Arial] else[/FONT] [FONT=Arial] movieDetails.Title = (string)movie["originalTitle"];[/FONT] (where "movie" is the name of the root object, I don't know its name in TMDB as I have not tested. I used this script for Allocine API data retrieval before they improved their security on the API few days ago) [FONT=Arial]This will avoid you to use regular expression and thus avoid data extraction problems. (I hate regular expressions)[/FONT] [FONT=Arial]Let me know if you need help on this (you can PM me in French)[/FONT] [FONT=Arial]Fred[/FONT] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Submit: Movie Info Grabbers
The Movie Database... first script, first trouble
Contact us
RSS
Top
Bottom