[RELEASE] xbmcswift2 - plugin framework
#31
(2013-02-08, 21:13)jbel Wrote: Can you pastebin your code?

Thanks.

http://pastebin.com/MbrTZS8L

Edit 1 Updated url, cleaned it a bit.
Edit 2 Feel free to give any feedback you think of. This is my first plugin. I'm super new to this.
Reply
#32
(2013-02-08, 21:21)SorryGoFish Wrote:
(2013-02-08, 21:13)jbel Wrote: Can you pastebin your code?

Thanks.

http://pastebin.com/MbrTZS8L

Edit 1 Updated url, cleaned it a bit.
Edit 2 Feel free to give any feedback you think of. This is my first plugin. I'm super new to this.

How about lib.scraper as well? I want to be able to run the addon.
Reply
#33
(2013-02-08, 21:38)jbel Wrote: How about lib.scraper as well? I want to be able to run the addon.

Sent PM with git url. Thanks.
Reply
#34
Not sure it's xbmcswift2 related. Something is funky with the call to executeJsonRPC. If you comment that out, the addon works fine...
Reply
#35
(2013-02-08, 22:41)jbel Wrote: Not sure it's xbmcswift2 related. Something is funky with the call to executeJsonRPC. If you comment that out, the addon works fine...

Yeah, interesting. It's as if the call to executeJSONRPC is somehow doing a callback with the current URL. I'm preventing this by checking if the value being set is a change or not. If it's not a change it stops. This isn't great, but at least it doesn't spin. Thanks again.
Reply
#36
This thing is great. I have a couple questions.

1. Is there a way I can use an xbmcgui.ListItem? I'd like to provide some of the extra stream info with addStreamInfo(..)

2. Is there a way to make a progress bar for some of the listing operations that take a long time? (Edit, found my own answer.)

Thanks again.


Reply
#37
(2013-02-10, 22:46)SorryGoFish Wrote: 1. Is there a way I can use an xbmcgui.ListItem? I'd like to provide some of the extra stream info with addStreamInfo(..)

At the moment, there is no easy way. Sphere created a PR which will be merged for the next released version that addresses this, https://github.com/jbeluch/xbmcswift2/pull/88.

For a temporary workaround, you can access the xbmcgui.Listitem but accessing the ._listitem attribute of an xbmcswift2 listitem. So instead of returning a list of dicts from a view, you do this:

Code:
listitems = plugin.add_items(items)
# listitems is now a list of xbmcwift2.Listitems
xbmcgui_listitem = listitems[0]._listitem
xbmcgui_listitem.addStreamInfo(...)

It's a hack that shouldn't be used long term, but should work until the next version is released.
Reply
#38
Thanks for sharing such a good framework!
Reply
#39
(2013-01-05, 07:01)akuiraz Wrote: I tried installing this on Windows 7, python 2.7 and all the required dependencies and it doesn't work for me. Is this compatible with windows? if not, any plans on implementing windows support? Or Windows with MinGW / Cygwin?

I just installed it on Windows 7 x64 with python 2.7. I was getting issues when I tried to run 'xbmcswift2 create' (about missing readline module)

Installing pyreadline solved that part.

Hope that helps!

Now on to hello world...
Reply
#40
Thanks for this. I easily converted one of my plugins to use this framework and now my code is cleaner and much more readable.
I also learned about using decorators in the process Smile
Reply
#41
Thanks a lot for this great framework.

It helped me to accomplish my first add-on Smile

Just 1 question, I'm having trouble running my plugin from command line on windows 7:
Code:
(xbmcswift2) C:\Users\peu141\Documents\Apps\xbmc\plugin.video.slbenfica.pt>xbmcs
wift2 run once
Traceback (most recent call last):
  File "C:\Python27\Scripts\xbmcswift2-script.py", line 9, in <module>
    load_entry_point('xbmcswift2==0.3.0', 'console_scripts', 'xbmcswift2')()
  File "build\bdist.win-amd64\egg\pkg_resources.py", line 353, in load_entry_point
  File "build\bdist.win-amd64\egg\pkg_resources.py", line 2302, in load_entry_point
  File "build\bdist.win-amd64\egg\pkg_resources.py", line 2029, in load
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\__init__.py", line 57, in <module>
    from mockxbmc import xbmc, xbmcgui, xbmcplugin, xbmcaddon, xbmcvfs
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\mockxbmc\xbmc.py", line 4, in <module>
    from xbmcswift2.cli.create import get_value
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\create.py", line 12, in <module>
    import readline
ImportError: No module named readline

EDIT: just fixed previous problem. Had to install pyreadline, along with BeautifulSoup on xbmcswift2 virtualenv

However it is triggering this error:
Code:
(xbmcswift2) C:\Users\peu141\Documents\Apps\xbmc\plugin.video.slbenfica.pt>xbmcs
wift2 run once
2014-01-30 11:38:59,855 - INFO - [xbmcswift2] Using temp directory c:\users\peu1
41\appdata\local\temp\xbmcswift2_debug
2014-01-30 11:38:59,997 - WARNING - [xbmcswift2] The getLanguage method has not
been implented on the CLI. Your code might not work properly when calling it.
2014-01-30 11:39:00,006 - INFO - [xbmcswift2] Request for "/" matches rule for f
unction "show_menu"
Traceback (most recent call last):
  File "C:\Python27\Scripts\xbmcswift2-script.py", line 9, in <module>
    load_entry_point('xbmcswift2==0.3.0', 'console_scripts', 'xbmcswift2')()
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\cli.py", line 76, in main
    manager.run(opts, args[1:])
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\app.py", line 52, in run
    plugin_mgr.run()
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\app.py", line 129, in run
    return handler(self.plugin)
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\app.py", line 150, in once
    items = plugin.run()
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\plugin.py", line 332, in run
    items = self._dispatch(self.request.path)
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\plugin.py", line 306, in _dispatch
    listitems = view_func(**items)
  File "C:\Users\peu141\Documents\Apps\xbmc\plugin.video.slbenfica.pt\addon.py", line 158, in show_menu
    {'label': __language__(30001), 'path': plugin.url_for('show_video_highlights
')},
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\mockxbmc\xbmcaddon.py", line 32, in getLocalizedString
    assert key in self._strings, 'id not found in English/strings.xml.'
AssertionError: id not found in English/strings.xml.

And I have this English/strings.xml:
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>

  <!-- Menu labels -->
  <string id="30001">Highlights</string>
  <string id="30002">Videos</string>
  <string id="30003">Photos</string>
  <string id="30004">Stadium</string>
  <string id="30005">Tickets</string>

  <!-- Login Settings -->
  <string id="30100">Login for http://www.slbenfica.pt</string>
  <string id="30101">Username:</string>
  <string id="30102">Password:</string>

</strings>
Image Image
Reply
#42
(2014-01-30, 13:25)redglory Wrote: Just 1 question, I'm having trouble running my plugin from command line on windows 7:

Did you use install xbmcswift with pip? If yes did you do that in a virtualenv? If yes, did you activate the virtualenv before running the plugin?
My GitHub. My Add-ons:
Image
Reply
#43
Updated my post.

BTW:

__language__ is set like this:

Code:
__addon__       = xbmcaddon.Addon(id=__plugin_id__)
__language__    = __addon__.getLocalizedString

Thanks
Image Image
Reply
#44
(2014-01-30, 13:45)redglory Wrote: Updated my post.

BTW:

__language__ is set like this:

Code:
__addon__       = xbmcaddon.Addon(id=__plugin_id__)
__language__    = __addon__.getLocalizedString

Thanks

First, you don't need to initialize your own Addon instance with xbmcswift. If you really need it you can use "plugin._addon". And for translated strings just use "plugin.get_string(string_id)".

Regarding your error, the strings.xml needs to be places in "ADDON_DIR/resources/language/English/".
My GitHub. My Add-ons:
Image
Reply
#45
Yupp, that did the trick!

I already had one version with plugin.get_string() but didn't commit it... my bad...

Thanks!
Image Image
Reply

Logout Mark Read Team Forum Stats Members Help
[RELEASE] xbmcswift2 - plugin framework2