2. Bundles¶
Each plug-in’s code and support files are stored in a self-contained bundle. A bundle is a specially organized directory with a .bundle extension. Mac OS X treats bundles as if they were files, allowing you to manipulate them as such in Finder. To view the contents of a bundle, right-click on it & select “Show Package Contents”. Here’s an example of the contents of a bundle:
The files and directories that can be contained within a bundle are explained in more detail below.
Note
The project templates provided with the Plex SDK will automatically generate bundles during the build process.
The bundle directory itself contains only one item: the Contents directory. This directory contains all files and other directories belonging to the plug-in. The Contents directory should include the following items:
2.1. The Info.plist file¶
The Info.plist file contains information about the plug-in which is used by the framework when loading the plug-in.
TODO: More information, sample file, description of keys.
2.2. The Code directory¶
The Code directory contains all of the plug-in’s source code files. Third-party code should not be included here, only files created by the developer.
2.2.1. The __init__.py file¶
The __init__.py file is the main source code file of the plug-in. It is responsible for any initialization required, and loading any extra source code files.
This is where all of the required Plug-in functions will go and you can place other custom functions in here as well. Of course you may create your own custom python modules and put them in this folder as well but just note that the __init__.py file is the one that Plex Media Server loads first.
See also
- The Start() function
- The specific framework function which is used to initialize your plugin.
- The Framework functions section
- Section detailing the Plex Media Server reserved functions.
2.3. The Resources directory¶
The Resources directory contains any resource files used by the plug-in. These include any images displayed by the plug-in, and any other data files the plug-in needs to load or return to Plex.
2.4. The Strings directory¶
The Strings directory contains JSON-formatted text files for each language the plug-in supports. String files should have a .json extension and be named according to the ISO specification for language codes (e.g. en.json). The name may also include an optional country code (e.g. en-us.json). For more information, see the Locale module.
2.5. The Libraries directory¶
The Libraries directory contains any third-party source code files or libraries used by the plug-in.
Note
This folder is optional.
2.6. The Helpers directory¶
The Helpers directory contains any executable helper programs required by the plug-in. For more information, see the Helper module.
2.7. The DefaultPrefs.json file¶
The DefaultPrefs.json file can be used to define the plug-in’s user preferences. The file should contain a JSON-formatted array, composed of a dictionary for each preference. The following code demonstrates the available preference types:
[
{
"id": "pref1",
"label": "Text preference",
"type": "text",
"default": "Default Value",
},
{
"id": "pref2",
"label": "Hidden text preference (passwords, etc.)",
"type": "text",
"option": "hidden",
"default": "",
},
{
"id": "pref3",
"label": "Boolean preference",
"type": "boolean",
"default": "true",
},
{
"id": "pref4",
"label": "Enum preference",
"type": "enum",
"values": ["value1", "value2", "value3"],
"default": "value3",
},
]
The preference dictionaries should contain the same keys and values used by Prefs.Add(). For more information, see the Prefs module.
Note
This file is optional.
2.8. The DefaultDict.json file¶
The DefaultDict.json file contains a JSON-formatted dictionary, which is loaded into the plug-in’s dictionary during initialization. This file can be used as an alternative to the CreateDict() function.
Note
This file is optional.
2.9. The DefaultDatabase.sql file¶
The DefaultDatabase.sql file contains a series of SQL statements, which are executed when creating the plug-in’s database. This file can be used as an alternative to the CreateDatabase() function.
Note
This file is optional.