Just got my first addon working, and I am looking for advice/critiques.

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
yzupnick Offline
Junior Member
Posts: 5
Joined: Jul 2013
Reputation: 0
Post: #1
I just built my first addon (Link to github at bottom.) The purpose of the addon is scan the user's movie database, and suggest movies that might be missing from their collection. (This is based off Themoviedatabase.com's collection API)
Right now the addon is working, but I know there are a few problems with it.

1) I am making way too many API calls to TMDB. Right now I am making at least 1 request per movie in the database, and 1 request per collection, plus another request if they want to see the trailer of a missing movie. I feel like I should be making only two calls per collection. 1 for the first movie in the collection the script encounters, and 1 to get the rest of the collection details.
I'm not sure if I am being clear. Please ask if I'm not.

2) Correct me if I'm wrong, but it appears that the entire script gets re-evaluated every time you drill down into a folder. Right now that means I am re-scanning the database/rebuilding the collections data (and making even more requests to TMDB) constantly. What is the best way to store the data, so that I am not rebuilding it every click, but at the same time I can keep it up to date with new movies/collections that are added.

3)General code critiques. I'm not exactly sure how a plugin works, and I couldn't really find any in depth documentation on the wiki. I ended up working off of the sickbeard plugin. So any general criticisms and improvements would be greatly appreciated.

Thanks for all your help.

Link to github page
find quote
divingmule Offline
Skilled Python Coder
Posts: 1,297
Joined: Oct 2008
Reputation: 61
Post: #2
For 2) you can use common plugin cache add-on http://wiki.xbmc.org/index.php?title=Add...ugin_cache

The cacheFunction is really nice method for updating every x hours.
find quote
tom66 Offline
Posts: 77
Joined: Feb 2013
Reputation: 2
Post: #3
I would use except IndexError instead of plain except, because you want exceptions like NameError or RuntimeError (for example) to fall through otherwise weird bugs could creep in that you didn't otherwise intend.
find quote
yzupnick Offline
Junior Member
Posts: 5
Joined: Jul 2013
Reputation: 0
Post: #4
Thanks. Trying them out now.
find quote