BigNoid/plugin.library.data.provider — pull request #3 by unfledged (2013-12-19 04:18:28+00:00)
Title: Convert to service

First, let me say I fully understand if you don't want to pull this, as it complicates a nice clean script and introduces some problems. With a few lists filled by your script on my scratchboard (an old Netbook) entering the home page took between 8 and 12 seconds every time, so I looked at ways to try and speed this up!

Basically, I've converted the script into a service (with a plugin entry point to fill the lists), and split the functionality into two parts.

Firstly, the service takes care of all JSON requests and saves them. It also keeps track of when JSON requests need re-sending (updating random items - set to every 10 minutes, playback finished, db update).

Second, the plugin loads the saved JSON requests, parses them and fills the lists.

Advantages - JSON is all done in the background. Allows lists to be updated without the home page being reloaded. JSON results are (essentially) cached, so don't need to be run every time the home page is accessed.

Disadvantages - Looses the ability for skinners to set a limit, as the max limit is dictated by how many items the service loads in the first place (and obviously, the more items it loads the longer it takes). All JSON requests for all media are made when the service first loads, whether or not they are actually used by the plugin. Nasty code for skinners to have lists auto-update.