[RELEASE] xbmcswift2 - plugin framework
#46
I'm having some problem with my url routing.

my initial menu is something like this:

Code:
def show_menu():
    ##########################################################
    # menu     = { 'headlines'  : plugin.get_string(30001),
    #              'news'       : plugin.get_string(30002),
    #              'videos'     : plugin.get_string(30003),
    #              'photos'     : plugin.get_string(30004),
    #              'stadium     : plugin.get_string(30005),
    #              'tickets'    : plugin.get_string(30006),
    #            }
    ##########################################################

    items = [
        {'label': plugin.get_string(30001), 'path': plugin.url_for('show_headlines')},
        {'label': plugin.get_string(30002), 'path': plugin.url_for('show_news')},
        {'label': plugin.get_string(30003), 'path': plugin.url_for('show_media_modalities', media_type = 'videos')},
        {'label': plugin.get_string(30004), 'path': plugin.url_for('show_media_modalities', media_type = 'photos')},
        {'label': plugin.get_string(30005), 'path': plugin.url_for('show_stadium')},
        {'label': plugin.get_string(30006), 'path': plugin.url_for('show_tickets')},
    ]

    return items

and my routing is like:
Code:
@plugin.route('/headlines/')
def show_headlines():

@plugin.route('/news/')
def show_news():

media_type = "videos" | "photos"
@plugin.route('/<media_type>/')
def show_media_modalities(media_type):

@plugin.route('/stadium/')
def show_stadium():

@plugin.route('/tickets/')    
def show_tickets():

it works weel with /news/ and /headlines/ but it fails with /stadium/ and /tickets/ because it's falling back to "show_media_modalities"

I suppose it has something to do with the order i have for last 2 routes?

Can I force just /<media_type>/ to trigger "show_media_modalities"?

Thanks
Image Image
Reply
#47
(2014-01-31, 18:02)redglory Wrote: it works weel with /news/ and /headlines/ but it fails with /stadium/ and /tickets/ because it's falling back to "show_media_modalities"

I suppose it has something to do with the order i have for last 2 routes?

Can I force just /<media_type>/ to trigger "show_media_modalities"?

Thanks

Hi,

correct, the order is important when you have such ambiguous URLs. You have two possibilities to solve your issue:
1. Re-order the routes so that "/<media_type>/" is the last one.
2. Use "/media_type/<media_type>/" as route-URL (this one should be preferred).

regards,
sphere
My GitHub. My Add-ons:
Image
Reply
#48
Hey, thanks for your answer.

I'm indeed following your advise regarding 2nd option.

Just keeping it simple!
Image Image
Reply
#49
Hey,

I'm having some string encoding problems when running xbmcswift2 from CLI (Windows 7):

Code:
2014-02-04 15:51:37,779 - INFO - [xbmcswift2] Request for "/media/videos/media_id/2805/category/12/page/1" matches rule for function "show_category_albums"
2014-02-04 15:52:04,071 - WARNING - [xbmcswift2] The addDirectoryItems method has not been implented on the CLI. Your code might not work properly when calling it.
2014-02-04 15:52:04,071 - WARNING - [xbmcswift2] The endOfDirectory method has not been implented on the CLI. Your code might not work properly when calling it.
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 183, in interactive
    items = [item for item in once(plugin, parent_stack=parent_stack)
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\app.py", line 161, in once
    display_listitems(items, plugin.request.url)
  File "C:\Python27\lib\site-packages\xbmcswift2-0.3.0-py2.7.egg\xbmcswift2\cli\console.py", line 49, in display_listitems
    print '\n'.join(header + output)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 11: ordinal not in range(128)

Any help?!

Thanks
Image Image
Reply
#50
Just solved my problem: was trying to encode/decode from unicode (which xbmcswift2 already does...)

removed this statement and voilá! Smile
Image Image
Reply
#51
I cannot figure out why the code which works perfectly in Gotham nightly builds throws an exception in Frodo. xbmcswift2 version is the same - 2.4.0.
Code example: http://xbmclogs.com/show.php?id=127275
Debug log: http://xbmclogs.com/show.php?id=127277
The is a raw WIP code which at this stage is supposed to create 3-level hierarchy of items, but I cannot reach the 3rd level in Frodo.
Any suggestions are welcomed.Smile
Reply
#52
(2014-02-08, 20:28)Roman_V_M Wrote: I cannot figure out why the code which works perfectly in Gotham nightly builds throws an exception in Frodo. xbmcswift2 version is the same - 2.4.0.
Code example: http://xbmclogs.com/show.php?id=127275
Debug log: http://xbmclogs.com/show.php?id=127277
The is a raw WIP code which at this stage is supposed to create 3-level hierarchy of items, but I cannot reach the 3rd level in Frodo.
Any suggestions are welcomed.Smile

This is just a guess, but most of the time I get this sort of error it is because one of my strings is None instead of a string. Try a "print repr(item)" at the end of your for loop and look for that in your log maybe.
Reply
#53
(2014-02-08, 20:46)ruuk Wrote: This is just a guess, but most of the time I get this sort of error it is because one of my strings is None instead of a string. Try a "print repr(item)" at the end of your for loop and look for that in your log maybe.

Thanks for the hint. Indeed, the problem was in incomplete WIP code. As it turned out, Gotham allows to add ListItems without path property, while Frodo does not - it requires at least an empty string dummy. Adding paths solved the problem.
Reply
#54
I'm just starting with xbmcswift2, and have one question.

What is the difference in an @plugin.route method between returning a list of items, and returning plugin.finish(items)

Am I correct that these are identical? And that plugin.finish is only actually required if you need to use any of its optional arguments?
Reply
#55
(2014-10-21, 17:40)IwasLegend Wrote: And that plugin.finish is only actually required if you need to use any of its optional arguments?

Exactly, you can pass extra arguments only when using the explicit finish-call.
My GitHub. My Add-ons:
Image
Reply
#56
You beat me to the answer. I was in mid sentence Smile
Reply
#57
I've recently started getting the following error and am not sure how to fix it:

D:\>xbmcswift2 create
Traceback (most recent call last):
File "D:\Python27\Scripts\xbmcswift2-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "D:\Python27\lib\site-packages\pkg_resources.py", line 35, in <module>
import email.parser
File "D:\Python27\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "D:\Python27\lib\email\feedparser.py", line 27, in <module>
from email import message
File "D:\Python27\lib\email\message.py", line 16, in <module>
import email.charset
File "D:\Python27\lib\email\charset.py", line 13, in <module>
import email.base64mime
File "D:\Python27\lib\email\base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "D:\Python27\lib\email\utils.py", line 28, in <module>
import socket
File "D:\Python27\lib\socket.py", line 47, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.


any ideas?

Running windows 8.1 (64 bit) with python 2.7.9
Reply
#58
is it possible to add extra args to listItem using default api? videoInfo,plot, etc?
Reply
#59
Is it possible to do something similar to setart using xbmcswift2?

Here's a snippet of my code:
Code:
current_item = []
current_item = {
'label' : current_name, 'thumbnail' : current_thumbnail,
'path' : current_page
'info' : {'genre': current_genre, 'credits': current_credits, 'date': current_date, 'plot': current_plot, 'trailer': current_trailer},
properties' : {'fanart_image' : current_fanart, 'banner' : current_banner, 'clearlogo': current_clearlogo, 'poster': current_thumbnail}
}
items.append(current_item)
The fanart image and thumbnail set correctly, but the banner, poster, clear logo, etc don't seem to be settable (if i go into the listitem in Kodi, and select info, then Choose Art, the banner, poster, etc are listed as None). Is there a way to be able to set the art for the keys listed for available info labels here: 16 Images Available in Kodi
[/align]
Thanks!
Reply
#60
2 zachmorris

Unfortunately, xbmcswift2 seems to be completely abandoned for some time now, and ListItem.setArt method is relatively new, so I guess it is not supported by xbmcswift2.
Reply

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