[RELEASE] xbmcswift2 - plugin framework
#1
Not really a release since it's been out for while Smile Just posting it here for the first time though.

xbmcswift2 is a mini framework to enable rapid development of XBMC plugins. It enables you to run your plugins on the command line (in a limited fashion) for testing and handles most of the url routing so you don't have to deal with query strings and parameters. I think it also had a tendency to force authors to write clean and well seperated code, which makes debugging and maintenance much easier in the long run.

It started as xbmcswift (no "2") awhile back and there were a few early adopters that found it in the repos Wink The project began as a way to abstract a lot of the boilerplate code that I found myself writing. Eventually, I wanted to make some changes that were backwards incompatible, so now the current version is "xbmcswift2". Check out the documentation for some example code. There is also a page in the docs which lists addons already using xbmcswift2, so you can take a look at their source.

Project page on github (issues, comments, etc): https://github.com/jbeluch/xbmcswift2
Documentation: http://www.xbmcswift.com/en/latest/index.html

(Or if you have xam installed, you can do xam depends script.module.xbmcswift2 to list addons which use xbmcswift2)

Also thanks to sphere, takoi and beenje for patches and suggestions.

Here's the My Zen TV addon from sphere which uses xbmcswift2:

Code:
from xbmcswift2 import Plugin
import resources.lib.scraper as scraper

__addon_id__ = 'plugin.video.myzen_tv'
__addon_name__ = 'Myzen.tv'

plugin = Plugin(__addon_name__, __addon_id__, __file__)


@plugin.route('/')
def show_free_videos():
    videos = scraper.get_free_videos()
    for video in videos:
        video['path'] = plugin.url_for('play_video', path=video['path'])
        video['is_playable'] = True
    return plugin.finish(videos)


@plugin.route('/play/<path>')
def play_video(path):
    rtmp_params = scraper.get_rtmp_params(path)

    def xbmc_output(rtmp_params):
        return (
            '%(rtmp_url)s '
            'app=%(app)s '
            'swfUrl=%(swf_url)s '
            'playpath=%(playpath)s '
        ) % rtmp_params

    playback_url = xbmc_output(rtmp_params)
    return plugin.set_resolved_url(playback_url)

if __name__ == '__main__':
    try:
        plugin.run()
    except scraper.NetworkError:
        log('NetworkError')
Reply


Messages In This Thread
[RELEASE] xbmcswift2 - plugin framework - by jbel - 2012-10-08, 20:22
Logout Mark Read Team Forum Stats Members Help
[RELEASE] xbmcswift2 - plugin framework2