Giter Site home page Giter Site logo

jbeluch / xbmcswift2 Goto Github PK

View Code? Open in Web Editor NEW
80.0 13.0 30.0 898 KB

The latest and greatest version of xbmcswift. Different package name, slight different API, same great project.

License: GNU General Public License v3.0

Python 96.95% Shell 3.05%

xbmcswift2's Introduction

xbmcswift2

Build Status

A micro framework to enable rapid development of XBMC plugins.

Features

  • Run the addon from the command line or within XBMC without changing any code.
  • Helper libraries to make common XBMC api operations easy, like adding items, getting settings, creating temporary files, etc.
  • Handles all the url parsing involved in plugin routing. No need to deal with complicated URLs and query strings.

Installation

xbmcswift2 is available in pypi, so you can install via pip:

pip install xbmcswift2

You should probably also read http://www.xbmcswift.com/en/latest/installation.html#installation to ensure it is properly installed for XBMC as well.

Documentation

The current documentation can be found at http://www.xbmcswift.com. It covers installation, quickstart, a guide to writing an addon and documentation for the full xbmcswift2 API.

Upgrading from xbmcswift

This project is the next version of xbmcswift. While the APIs are similar, there are a few things that are not backwards compatible with the original version, hence the new name.

If you are upgrading an addon that used xbmcswift, see http://www.xbmcswift.com/en/latest/upgrading.html#upgrading.

Development

xbmcswift2 is now available in the official XBMC Eden repository. Every time a new release is created and uploaded to pypi, a new XBMC release will be created as well. Be aware that XBMC's "version" for xbmcswift2 will not match the official python package version.

New features and bug fixes are done on the develop branch of this repo. If you are interested in using the develop branch, you can install locally via pip:

pip install git+git://github.com/jbeluch/xbmcswift2.git@develop

The documentation for the develop branch can be found at http://www.xbmcswift.com/en/develop/api.html#api.

Contributing

Bugs, patches and suggestions are all welcome. I'm working on adding tests and getting better coverage. Please ensure that your patches include tests as well as updates to the documentation. Thanks!

Support

#xbmcswift on freenode

https://github.com/jbeluch/xbmcswift2

Subscribe to the mailing list to be notified of new releases or to get help. Send an email to [email protected] to subscribe.

[email protected]

xbmcswift2's People

Contributors

cancan101 avatar dersphere avatar jbeluch avatar ulion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xbmcswift2's Issues

Error when calling plugin.notify('My message')

01:04:28 T:140468851570432   ERROR: Traceback (most recent call last):
                                              File "/home/jon/.xbmc/addons/plugin.video.coursera/addon.py", line 26, in <module>
                                                coursera = get_api_conn()
                                              File "/home/jon/.xbmc/addons/plugin.video.coursera/addon.py", line 24, in get_api_conn
                                                plugin.notify('Login did not work. Check your email and password and try again.')
                                              File "/home/jon/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/xbmcmixin.py", line 160, in notify
                                                title = self.plugin.name
                                            AttributeError: 'Plugin' object has no attribute 'plugin'

context_menu + XBMC.RunPlugin + set_resolved_url does not work

I have added an action to the context menu to call back into the plugin using XBMC.RunPlugin.

This correctly works and I can see the correct route being called. However with the route I am then using set_resolved_url to play a URL. Making his call yields:

ERROR: SetResolvedUrl - called with an invalid handle.

and the video does NOT play.

cache_path doesn't exist by default, need to make the directory

01:25:43 T:140469224744704   ERROR: Traceback (most recent call last):
                                              File "/home/jon/.xbmc/addons/plugin.video.coursera/addon.py", line 34, in <module>
                                                coursera = get_api_conn()
                                              File "/home/jon/.xbmc/addons/plugin.video.coursera/addon.py", line 24, in get_api_conn
                                                cookie_jar.load()
                                              File "/usr/lib/python2.7/cookielib.py", line 1761, in load
                                                f = open(filename)
                                            IOError: [Errno 2] No such file or directory: '/home/jon/.xbmc/userdata/addon_data/plugin.video.coursera/.cache/.cookies'

Allow ENV vars for settings in CLI mode

When running on CLI mode, xbmcswift2 wll ask you for test values (e.g. username/password). Enable a temp file or env vars to be used so user doesn't have to enter these every they run.

IOError with Cache

23:34:10 T:2844765040   ERROR: Error Type: <type 'exceptions.IOError'>
23:34:10 T:2844765040   ERROR: Error Contents: (2, 'No such file or directory', '/home/xbmc/.xbmc/userdata/addon_data/plugin.video.coursera/.storage/.functions.tmp')
23:34:10 T:2844765040   ERROR: Traceback (most recent call last):
                                              File "/home/xbmc/.xbmc/addons/plugin.video.coursera/addon.py", line 493, in <module>
                                                plugin.run()
                                              File "/home/xbmc/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/plugin.py", line 318, in run
                                                return self._dispatch(self.request.path)
                                              File "/home/xbmc/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/plugin.py", line 302, in _dispatch
                                                listitems = self.finish(listitems)
                                              File "/home/xbmc/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/xbmcmixin.py", line 380, in finish
                                                storage.close()
                                              File "/home/xbmc/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/storage.py", line 69, in close
                                                self.sync()
                                              File "/home/xbmc/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/storage.py", line 63, in sync
                                                shutil.move(tempname, self.filename)    # atomic commit
                                              File "/usr/lib/python2.7/shutil.py", line 298, in move
                                                copy2(src, real_dst)
                                              File "/usr/lib/python2.7/shutil.py", line 127, in copy2
                                                copyfile(src, dst)
                                              File "/usr/lib/python2.7/shutil.py", line 81, in copyfile
                                                with open(src, 'rb') as fsrc:
                                            IOError: (2, 'No such file or directory', '/home/xbmc/.xbmc/userdata/addon_data/plugin.video.coursera/.storage/.functions.tmp')

user_data folder doesn't exist for addons that don't have a settings.xml


                                                listitems = view_func(**items)
                                              File "/home/jon/.xbmc/addons/xbmc-vimcasts/addon.py", line 71, in index
                                                } for epi in get_json_feed()['episodes']]
                                              File "/home/jon/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/xbmcmixin.py", line 56, in wrapper
                                                cache.sync()
                                              File "/home/jon/.xbmc/addons/script.module.xbmcswift2/lib/xbmcswift2/cache.py", line 52, in sync
                                                fileobj = open(tempname, 'wb' if self.file_format == 'pickle' else 'w')
                                            IOError: (2, 'No such file or directory', '/home/jon/.xbmc/userdata/addon_data/plugin.video.vimcasts/.cache/function_cache.tmp')
14:59:41 T:140579985602432   ERROR: GetDirectory - Error getting plugin://plugin.video.vimcasts
14:59:41 T:140579985602432   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.vimcasts) failed

ERROR: EndOfDirectory - called with an invalid handle.

Currently I have a route which calls "plugin.set_resolved_url(path)"

I then either return nothing (None) or an empty list. In either case I see:

ERROR: EndOfDirectory - called with an invalid handle.

in the log. The video DOES correctly start playing, so I am not sure what the effects of this error are.

logging bug

22:48:18 T:2960314368 NOTICE: [xbmcswift2] Request for "%s" matches rule for function "%s"

update caching

  • Get rid of regular Cache. Everything will be TimedCache, however you can specify ttl 0. Will make things less complicated.
  • s/cache/storage/g

error in docs

In http://www.xbmcswift.com/en/latest/patterns.html#reusing-views-with-multiple-routes

Wrong:

@plugin.route('/movies/', name='show_movie_genres')
@plugin.route('/silents/', name='show_silent_genres', {'path': 'index.php/silent-films-menu'})
@plugin.route('/serials/', name='show_serials', {'path': 'index.php/serials'})
def show_genres(path='movies'):
    pass

Correct:

@plugin.route('/movies/', name='show_movie_genres')
@plugin.route('/silents/', name='show_silent_genres', options={'path': 'index.php/silent-films-menu'})
@plugin.route('/serials/', name='show_serials', options={'path': 'index.php/serials'})
def show_genres(path='movies'):
    pass

options= missing before the dict, else it raises SyntaxError: ('non-keyword arg after keyword arg')

Request: Mock xbmcgui.Window

I need to add some statistics methods to my plugin, and will need the width and height of XBMC. This is provided through the xbmcgui.Window class (getWidth() / getHeight()).

It would be great if there was a way to use this with xbmcswift2. For now I've implemented the class in xbmcgui.py to just return static values, but I'm unsure if this is the right way to do it.

module issues

  • no _end_of_directory when calling module.finish()
  • cannot do module.get_storage() because no _storage_path attribute

get_storage() writes '{' to xbmc.log when file_format != pickle

This is because the line: https://github.com/jbeluch/xbmcswift2/blob/develop/xbmcswift2/storage.py#L94

for loader in (pickle.load, json.load, csv.reader):
    fileobj.seek(0)
    try:
        return self.initial_update(loader(fileobj))
    except Exception as e:
        print e
        pass

On first round Exception KeyError is raised because first char of json file is '{': KeyError('{',)
which results in a xbmc.log line:
19:49:49 T:5384 NOTICE: '{'
I would recommend either using:
print repr(e)
or better remove that print ;)

Document update_listing and cache_to_disc parameters

I struggled with the history being funky when I tried to implement pagination. Found the solution by looking at the rofl.to plugin source, but it took me a while.

Seeing a lot of goodies in the documentation that are only mentioned but not documented. Would contribute, but I don't feel confident enough with xbmcswift yet.

On an unrelated note; great project :-)

xbcmswfit2 create issues

  • the addon.py from imports xbmcswift instead of xbmcswift2.
  • the addon.xml imports python version 1.0 instead of 2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.