Same plugin for multiple catgories
#1
My plugin should be visible both under audio, video and picture categories.
In addon.xml I have these settings:
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video audio image</provides>
</extension>

The problem is that I don't know how to fire different scripts for different categories. There might be some code in addon.py to detect from what category it has been called and then run either audio, video or image scripts, but I don't know how to detect from what category it has been called.
Reply
#2
IIRC, you can use the infolabel Container.PluginCategory to see what category your addon was launched from
Reply
#3
You should find the 'content_type' parameter if the plugin is launched from one of the main add-on directories.
Reply
#4
Hmm... do you have code examples?
Reply
#5
Plugin parameters are in sys.argv[2] it's up to you how to parse them, if you add a print statement, e.g. 'print sys.argv[2]', you should see it in the log.
Reply
#6
Aren't they empty when script just fired up?
Reply
#7
(2014-01-14, 10:03)void0 Wrote: Aren't they empty when script just fired up?

This exactly is the point. If you have just one providing media it is empty. If you have multiple, XBMC injects e.g. "content_type=video" into urlencoded sys.argv[2].
And it only does it when the plugin is started from the video-add-on windo, audio add-on window or image add-on window - means only on the initial start. You need to add it in deeper levels yourself.
My GitHub. My Add-ons:
Image
Reply
#8
I was thinking something like this in addon.py:
Code:
if video:
    from video_addon import *
elif audio:
    from audio_addon import *
elif image:
    from image_addon import *
Reply
#9
(2014-01-14, 16:27)void0 Wrote: I was thinking something like this in addon.py:
Code:
if video:
    from video_addon import *
elif audio:
    from audio_addon import *
elif image:
    from image_addon import *

Even if that works (don't know) - its (python wise) not a good design (Avoid "from x import *").
Maybe, if you want it to route this way, try something like:
Code:
if content == 'video':
    import video_addon as current_addon
elif content == audio':
    from audio_addon as current_addon
elif content == image':
    from image_addon as current_addon
else:
    raise NotImplementedError('missing content type')
My GitHub. My Add-ons:
Image
Reply
#10
How to get content? Do you have an example? When I just start plugin sys.argv[2] is empty, how then I would know that plugin has been started from e.g. video and not audio?
Reply
#11
Again (and last time):
If you have multiple providing media entries in your addon.xml AND you are starting your plugin from either the music-plugins or the picture-plugins or the video-plugins window, you will have content_type in sys.argv[2].

You are asking us for code samples but you are the one with who should upload the code.
My GitHub. My Add-ons:
Image
Reply
#12
Also I think* this requires XBMC version >= 12.0.
Reply
#13
(2014-01-15, 12:53)divingmule Wrote: Also I think* this requires XBMC version >= 12.0.

Ah yes thanks, I can confirm this. You need to be on >=12.0.
My GitHub. My Add-ons:
Image
Reply
#14
I am on 11.0, that looks like a reason why it didn't work
Reply

Logout Mark Read Team Forum Stats Members Help
Same plugin for multiple catgories0