Selective listing of Audio or Video
#1
Hi all,

I'm brand new to XBMC development, and so this is probably something obvious - but I just can't figure out how to do it, so I'd appreciate your help.

I am writing a plugin that lists a set of Audio shows and a different set of Video shows. I want the plugin to only show the list of audio shows when it's started via Music Addon's and only list the video shows when started via the Video Addon's.

Seems to me I either need to tell XBMC what type it is, assuming it will then be selective it what it shows - or I need to be able to catch in my code what menu it was started from, so I can serve up different listings. Is this possible?

Thanks in advance for your thoughts.
Reply
#2
If your add-on does provide multiple content-types (like video and music) your add-on will be started automatically with an additional "content-type" parameter:
e.g.
Code:
plugin.video.foo?content_type=video

But only on the initial call.
My GitHub. My Add-ons:
Image
Reply
#3
Thanks for the quick reply. But I'm really showing my ignorance here I think - how to I get that parameter in my code? Thanks!
Reply
#4
Depends on your code Big Grin

Show me a snippet
My GitHub. My Add-ons:
Image
Reply
#5
Well I would... but I have no clue how to get the parameter you mention, so I really have no snippet to show! Any examples I can look at?

Actually using the TWiT plugin as an example, I think I'm halfway there now....

Got it, I used the TWiT plugins get params function...:

Code:
def get_params():
        param=[]
        paramstring=sys.argv[2]
        if len(paramstring)>=2:
            params=sys.argv[2]
            cleanedparams=params.replace('?','')
            if (params[len(params)-1]=='/'):
                params=params[0:len(params)-2]
            pairsofparams=cleanedparams.split('&')
            param={}
            for i in range(len(pairsofparams)):
                splitparams={}
                splitparams=pairsofparams[i].split('=')
                if (len(splitparams))==2:
                    param[splitparams[0]]=splitparams[1]
        return param

...to parse the params. Then I can easily get the content_type parameter you told me about using:

Code:
params=get_params()
content_type = params['content_type']

Thanks for steering me in the right direction!
Reply
#6
Ah. Just seen that if the addon is started from an addon shortcut on the home window, that parameter is not passed. Is there a better way I should be doing this?
Reply

Logout Mark Read Team Forum Stats Members Help
Selective listing of Audio or Video0