Plex Media Center for OS X Leopard

Changes to Framework v1 between beta 8 and 1.0.0

This article is aimed at developers who have been working with the last publicly available beta version of the framework (v1.0b8), and only outlines changes made since this version. Developers without prior experience with the framework should read the documentation.

Several improvements have been made to the framework since the last publicly available version. A number of bugs have been identified and repaired, and many features have been added or improved to help meet the needs of developers.

Bug fixes:

  • FIX: Functions use the correct prefix in plug-ins with multiple prefixes registered.
  • FIX: Prefix value in WebVideoItem was hard coded.
  • FIX: Redirects to URLs containing ‘%’ characters weren’t working.
  • FIX: Boolean preferences are properly converted to & from Python values (rather than "true" / "false" strings).
  • FIX: Preferences are now localized correctly.
  • FIX: XML.StringFromElement now works with HTML elements.

New and updated features:

  • NEW: All framework code can now be loaded with a single line in a source file: from PMS import *
  • NEW: Upgrades to the framework will automatically reset the dictionary, caches, preferences, database & data items if the newer version introduces incompatibilities with previously saved data. Please note that due to changes in this release, data stored by beta framework versions will be reset after upgrading.
  • NEW: Dateutil is now bundled with the framework to fix an incompatibility with Snow Leopard.
  • NEW: Several new logging functions are available (LogChildren, LogSelfAndChildren and LogSelfAndDescendants). Thanks to Ryan for these!
  • NEW: Imported modules are checked and a warning will be shown in the log file if a module hasn’t been marked as safe.
  • NEW: Certain functions will show a warning in the log file if the framework detects they are being used incorrectly (for example, adding a preference outside the CreatePrefs function).
  • NEW: Plug-ins can be flagged as being “broken”. If a broken plug-in is accessed, the framework will override its handler function & display an information message to the user instead. This feature will be made active after a future App Store update.
  • NEW: The @handler decorator allows a function to be assigned as a prefix handler without having to call Plugin.AddPrefixHandler in the Start function.
  • UPDATED: SearchDirectoryItem has been renamed to InputDirectoryItem since it’s being used for much more than just search (the old name will continue to work).
  • NEW: Resource files can now be loaded in binary mode, leaving the line endings intact.
  • NEW: The HTTP module now supports basic authentication. Use HTTP.SetPassword to provide credentials for sites requiring this method of user login.
  • NEW: Some new functions are available – Prefs.Reset (restores defaults for all preferences), Thread.Sleep (pauses the execution of the current thread), HTTP.GetCookiesForURL (retrieves cookies for a given URL from the plug-in’s cookie jar), Plugin.Restart (restarts the plug-in), String.StripTags (removes the HTML/XML tags from a given string), and Data.Remove (removes the named data item).
  • NEW: Some new modules are available – the Helper module provides functions for running external helper programs, the Network module provides information about the media server’s network settings, and the Client module provides information about the Plex client accessing the server.
  • NEW: Cookies can be passed back to Plex from a plug-in as the httpCookies argument in a MediaContainer’s constructor. This enables playback of videos that require cookie-based authentication (excluding videos that require WebKit). Thanks to Elan for making all the Plex & framework changes required.
  • NEW: The framework now automatically sets the system encoding to UTF-8. Developers should no longer need to manually convert strings between different encodings. The default system encoding can be overridden in the plug-in’s Info.plist file by setting the PlexPluginEncoding key. Many thanks to Ian for figuring this one out!
  • NEW: The default locale can now be set using Locale.SetDefaultLocale.
  • NEW: The Locale module now uses dynamic string localization. Strings returned using Locale.LocalString or the L() shortcut are new objects that localize their value at runtime (when performing an operation on the string, like returning it to the media server or writing it to a file). Local strings can be concatenated using the + operator, and formatted using the new Locale.LocalStringWithFormat function (or the new F() shortcut) while retaining their new capabilities. Due to these changes, localized strings will now automatically switch locale in response to information received from Plex instead of retaining the value assigned when they were created.
  • NEW: Function objects can now be used to populate media item attributes with image data. Attribute functions accept any number of optional arguments, and can be assigned to attributes directly, e.g. thumb = Function(my_function, arg)
  • NEW: New RTMPVideoItem and WindowsMediaVideoItem objects allow direct playback of Flash- or Silverlight-based video streams via custom players hosted on the Plex servers rather than the official player of the site hosting them. This enables full control of the video stream without needing to provide any site configuration details. Many thanks to Elan & Sander for putting in all the effort & getting the server side up & running!
  • UPDATED: The Thread module has been significantly improved. It now uses a higher level Python threading interface, and introduces a global thread locking system.
  • UPDATED: The Database module has been mostly rewritten to make it fully thread-safe and provide better exception handling.
  • NEW: A set of decorators are available to assist in plug-ins that use multithreading. @lock and @modify_dict simplify using thread locks and @thread and @spawn allow threaded code to be written inline within a function. Parallel task sets (@parallel, @parallelize and @task) take this concept further by providing a simple syntax for distributing tasks between multiple threads, with their execution being managed automatically by the framework.
  • UPDATED: Modules that write to the filesystem have been updated with new features. Each function that writes to a file takes advantage of the new thread locking features to ensure that the functions are thread-safe. Writes to the filesystem are delayed by a few seconds, allowing modifications caused by several function calls to be written in batches rather than after each call, and files are saved atomically to help prevent the possibility of data corruption.
  • NEW: Some constants are available to use when setting cache times: CACHE_1MINUTE, CACHE_1HOUR, CACHE_1DAY, CACHE_1WEEK and CACHE_1MONTH.
No comments

No comments yet. Be the first.

Leave a reply

You must be logged in to post a comment.