This works fine, however the DirectoryObjects are all out of order and not sort alphabetically, is there an easy way to sort these items? I have tried a few different thing I found on the forums here but none seem to work, I think they are for older versions of PMS
Also im building another plugin that I need to be able to save settings for (e.g. favourite sites ect ect) is there anyway to save a setting so that it can be stored and used again after the server has been restarted?
And one last thing, im looking to have this plugin display MetaData about a specific Movie or TVShow all it needs is title, summary and a banner. This page just needs a simple button or item that will allow the user to add this show/movie as a favourite (see above) what is the best object type to do this?
Im only starting out with channel developing for Plex so im pretty new to this, and I have been searching for a while now with no luck...
The trick is to sort the list before adding them to the object container. The Python docs are a brilliant place to start, take a look at http://wiki.python.org/moin/HowTo/Sorting/. I imagine something like the following is what you are after:
series = sorted(series, key=lambda item: item[1])
Take a look at the Plex Framework documentation, it's certainly worth a read and has all of the information you are after.
Setting and accessing preferences
Create a DefaultPrefs.json file in the Contents directory.
Add the default preferences as a a JSON array, see Page 85 of the docs.
In the main menu of your application create the following object to allow the user to access it, Plex will take care of updating the user preferences.
oc.add(PrefsObject(title = "Preferences"))
And you can access the preferences in the python code via
In particular you want to set the following arguments:
title
A string specifying the movie’s title.
summary
A string specifying the movie’s summary.
thumb
A string specifying an image resource to use as the movie’s thumbnail.
art
A string specifying an image resource to use as the movie’s background art.
Sorting before adding to the Object Container works well but, may not always be the best approach. It is possible to sort the contents of a Object Container by title (or pretty much any of the attributes). Like so,
oc.objects.sort(key = lambda obj: obj.title)
The last bit “obj.title” can be changed to sort based on other attributes such as obj.duration, obj.originally_available_at, obj, etc. You can also add the “reverse=True” argument if you want the list in the reverse order.
As far as the MetaData goes, you might have misunderstood the question...
I need to retrieve metadata, say from TheTVDB.com or IMDB.com and display it within the plugin, I can see there are already agents for this within Plex im just not sure how to access them from within my plugin
Sorting before adding to the Object Container works well but, may not always be the best approach. It is possible to sort the contents of a Object Container by title (or pretty much any of the attributes). Like so,
oc.objects.sort(key = lambda obj: obj.title)
The last bit "obj.title" can be changed to sort based on other attributes such as obj.duration, obj.originally_available_at, obj, etc. You can also add the "reverse=True" argument if you want the list in the reverse order.
The sort command seems like a good one to know and use. Just one question, where would you put the line above within your code? You say that with this approach, you would not be sorting before adding to the object container. So would you place this command outside of any loop you are using to pull data and place it between the oc.add() and the return oc commands?
need to retrieve metadata, say from TheTVDB.com or IMDB.com and display it within the plugin, I can see there are already agents for this within Plex im just not sure how to access them from within my plugin.
Metadata from agents is not exposed for use by channel plugins. It *might* be possible to hack some sort of workaround but it would definitely be unsupported and liable to break at any time.
So would you place this command outside of any loop you are using to pull data and place it between the oc.add() and the return oc commands?
Thanks everyone for you help! I managed to get the sorting and adding items to favourites working and im just using the TVDB and IMDB api's to pull the data i need for banners ect ect