Best practice when splitting a addon
#1
Question 
I've made a usenet streaming addon and are wondering how (or if) I should split it in order for others to utilize my functions without incorporating my code.
Basically the plugin consist of 3 parts.
1. Nzb site content listing (already one external plugin)
2. SABnzbd communication.
3. Partial rar-set player

Lets say others would like to utilize my partial rar-set player function, where should I place the code plugin.programs or should that be a script module?
(i.e. xbmc.executebuiltin("Container.Update("plugin://plugin.somewhere.rarplay?mode=play&path=somepath")")

The SABnzbd communication part needs settings, should that be placed in programs or where?

As an example I have made a radbox addon identifying vimeo and youtube links in a rss fed and are just using those addons API to start the videos without having to bother about the internals of how they work or maintain any code (except api changes)

I really like the thought about independent functions for all to utilize..
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#2
anything that's not usable on its own should be a script.module.

while the partial rar player stuff could in theory be used stand-alone, i doubt anyone will use it as is. that being said, if you want urls on that form to work, it has to be a plugin.
Reply
#3
I don't know much about how script.modules work or how you offer them for download...going to google it. The api example was just the tiny bit about cross plugin communication I know about..

How should I manage a plugin where the user only could enter settings, should that be a program or do I have any other option if I dont want to clutter the videos addon view with a "unusable" plugin ?
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#4
Popeye Wrote:I don't know much about how script.modules work or how you offer them for download...going to google it. The api example was just the tiny bit about cross plugin communication I know about..

How should I manage a plugin where the user only could enter settings, should that be a program or do I have any other option if I dont want to clutter the videos addon view with a "unusable" plugin ?

a script.module.file is set as a Requirement for the script and XBMC will automatically download the script.module.file from the repo.

If the modules are not excepted as script.modules you can still add them to your script and have the script still handle it like it was separately like using a script.module.

If your addon is set up like many others, you might be following a path similar to this

addon.name
---->resources
--------->lib
-------------->module1
------------------>__init__.py <- important to make the module a 'package'
------------------>code.py <- file(s) containing the parts you want to split out
-------------->scriptcode.py <- file(s) containing the parts you don't want to split out, but want out of your main script file
----->addon.xml
----->addon.py
----->LICENCE.txt

if you already use this path setup, to use you module, you probably already have the 'lib' directory added to your syspath. If not, you need to use the following lines:

Code:
__addon__         = xbmcaddon.Addon( "addon.name" )
__addon_path__    = __addon__.getAddonInfo( 'path' )
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __addon_path__, 'resources' ) )
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )

Now you just need to use the standard 'import module1' command in your addon.

Oh and the contents of the __init__.py just need to be the following

Code:
# dummy file to make this a package
Reply

Logout Mark Read Team Forum Stats Members Help
Best practice when splitting a addon0