Friday, October 2, 2015

Building a Plex Plugin from scratch

First of all, some important url-s for learning:
 Seconds, the skeleton  (directories and files) of a plex plugin (all are case sensitive):
  • MyPlugin.bundle
    • Contents
      • Code
        • __init__.py
      • Info.plist
An absolute minimal content of the Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>CFBundleIdentifier</key>
 <string>com.plexapp.plugins.myplugin</string>
 <key>PlexFrameworkVersion</key>
 <string>2</string>
 <key>PlexClientPlatforms</key>
 <string>*</string>
</dict>
</plist>
An absolute minimal content of the __init__.py (for a responding plugin):
@handler('/video/myplugin', 'My Plugin')
def Main(): # this is the landing page of the plugin because of the prefix handler.
    return ObjectContainer()
That's it. Every plugin grows out from this root :)

Okay, one thought to developing a plex plugin: without a proper IDE, you're dooooomed! :D Okay, maybe not, but if you use other people's code than sorting out python syntax errors (like: there's a tab instead of space, and here's a comma missing, thet indentation is only 2 space not 4, etc) can be quite annoying since the Plex server does not help much with debugging (it either responds or not, but that's it).
Anyway, I managed to make my first plex plugin work... or at least some parts of it, and at least on my PC :) Here it is.


This post was originally published on my other blog, Alice@Ubuntu, but considering the content, I moved it here.

No comments:

Post a Comment