Add-on dev. 3 Newbie Questions
#1
Hey everyone!

I started developing an add-on for personal use just a couple of days ago and I was plesantly surprise with how quick it was to get a working version up and running.
Basically, I'm using it to load JSON (dinamically generated on my server using PHP) to display a list of Movies and TV Episodes I can watch online (my own personal VUDU collection, Amazon, etc).
I realize the thread title is quite vague but I had three totally unrelated questions of issues I ran into:

1.
I want to open links in a browser (using a third party launcher) and thus, not use the built-in player at all.
I am able to launch the plugin sucessfully, but I always get the "Playback Failed" message. ("One of more items failed to play. Check the log for more information about this message.").
I'm wondering what exactly is the right to call a plugin without Kodi thinking that I'm trying to obtain a stream/playlist from it?

I've tried several ways of doing/hacking it and with all three I had the same results.

Code:
li = xbmcgui.ListItem()
li.setPath(plugin_link)
xbmcplugin.setResolvedUrl(addon_handle, True, li)
Code:
xbmc.executebuiltin('PlayMedia(' + plugin_link + ')')
Code:
xbmc.executebuiltin('RunPlugin(' + plugin_link + ')')

I understand how the first two might be calling the player, but I don't get why the third one is.

2.
When listing TV Show episodes, only the episode number is shown, instead of the usual "1x01, 1x02, ..." format.
I've set the episode and season values using both the "setProperty" and "setInfo", but still unsucessfully. They do show up on the left side as you can see on the screenshots.

When adding the sort method "SORT_METHOD_PRODUCTIONCODE", I am able to see the season number, but the episodes are out of order.
Is there even a way to set the production code? I couldn't seem to find a documentation on it.

This is how it looks like for me.
Using SORT_METHOD_PRODUCTIONCODE: https://drive.google.com/open?id=0B2Lx71...GxjN21pQ2M
Using SORT_METHOD_EPISODE: https://drive.google.com/open?id=0B2Lx71...WE2dlhUc0E


3.
The JSON file I'm currently generating has all the information I need to run the addon - all Movie, TV Show and Episode infos (and I understand how this is lazy programming and problematic, as it's quite a huge file).
That being said, I couldn't find a way to load it just once at the beginning (even if it takes while) and then be able to navigate the screens without delay.
As I understand it, each time I enter a folder, the plugin has to be called again (with different parameters), so as it is, I have to load the same JSON 3 times: Load TV Show Details, Load Episode Details, Load Available Sources.

Code:
if mode is None:
    url = build_url({'mode': 'movies', 'foldername': 'Movies'})
        li = xbmcgui.ListItem('Movies', iconImage='DefaultFolder.png')
        xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                    listitem=li, isFolder=True)

        url = build_url({'mode': 'shows', 'foldername': 'TV Shows'})
        li = xbmcgui.ListItem('TV Shows', iconImage='DefaultFolder.png')
        xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                    listitem=li, isFolder=True)
        xbmcplugin.endOfDirectory(addon_handle)

elif mode[0] == 'movies':
    xbmcplugin.setContent(addon_handle, 'movies')
    
    response = urllib2.urlopen(json_url_movies, timeout = 30)
    data = json.loads(response.read())

(...)

elif mode[0] == 'shows':
    xbmcplugin.setContent(addon_handle, 'tvshows')
    response = urllib2.urlopen(json_url_shows, timeout = 30)
(...)

elif mode[0] == 'show_episodes':
    xbmcplugin.setContent(addon_handle, 'episodes')
    response = urllib2.urlopen(json_url_shows, timeout = 30)

(...)

elif mode[0] == 'streaming_sources':
    type = args['type'][0]
    if type == "movies":
        response = urllib2.urlopen(json_url_movies, timeout = 30)
        data = json.loads(response.read())

    if type == "shows":    
        response = urllib2.urlopen(json_url_shows, timeout = 30)

Is there any way to achieve this?

Thanks!
Reply
#2
Episode sorting will not show seasons as far as I am aware. Why and where are you executing the builtin? The example you provided doesn't actually show where you are using it. In general though I'm pretty sure depending on the format of the link it still uses the resolver. Since you have not provided the actual details it is hard to give much more information.
Reply
#3
1. Read my old post on how to configure plugin calls: http://forum.kodi.tv/showthread.php?tid=...pid2227469
It seems that you need case #3.

2. I guess, you need to set "episodes" content type before adding any list items: http://mirrors.xbmc.org/docs/python-docs...setContent

3. Yes, plugin calls are stateless so you need to implement some form of caching. There is commoncache plugin (http://forum.kodi.tv/showthread.php?tid=116496) but I've never used it myself so I cannot tell you more about it.
Reply
#4
(2016-11-02, 13:34)Roman_V_M Wrote: 1. Read my old post on how to configure plugin calls: http://forum.kodi.tv/showthread.php?tid=...pid2227469
It seems that you need case #3.

#3 was definitely what I needed! I had a bad mix of "isPlayable"/"isFolder"...
After I changed it, the "Loading stream" dialog box was gone and it no longer attempted to play 'something'. Since I actually like having a Loading window, I just implemented a "DialogProgress" until the external plugin isn't actually launched.

(2016-11-02, 13:34)Roman_V_M Wrote: 2. I guess, you need to set "episodes" content type before adding any list items: http://mirrors.xbmc.org/docs/python-docs...setContent
(2016-11-02, 03:12)Protocol-X Wrote: Episode sorting will not show seasons as far as I am aware.

It was already set to episodes - xbmcplugin.setContent(addon_handle, 'episodes') - so it seems like that's indeed the case, episode sorting doesn't show seasons...?
I ended up just adding the season and episode number to the beginning of each episode title and forcing it to sort alphabetically. Seems to work as desired!

(2016-11-02, 13:34)Roman_V_M Wrote: 3. Yes, plugin calls are stateless so you need to implement some form of caching. There is commoncache plugin (http://forum.kodi.tv/showthread.php?tid=116496) but I've never used it myself so I cannot tell you more about it.

That did the trick, I even disabled my PHP/JSON server to be sure it was cached! So easy to set it up too Big Grin Huge difference now on loading times.

Thank you both for your help, by the way, I'm a happy camper now Big Grin
------------------------

If I can add another question to this thread, how do I set a specific Listitem to be highlighted as default? For example, so that I can go to the first unwatched episode on a list, instead of having to scroll all the way down.

All the highlight/focus information I found seem to be skin related, so apologizes if I missed it in the Kodi python-docs.
Reply
#5
(2016-11-02, 16:48)samukas Wrote:
(2016-11-02, 13:34)Roman_V_M Wrote: 1. Read my old post on how to configure plugin calls: http://forum.kodi.tv/showthread.php?tid=...pid2227469
It seems that you need case #3.

#3 was definitely what I needed! I had a bad mix of "isPlayable"/"isFolder"...
After I changed it, the "Loading stream" dialog box was gone and it no longer attempted to play 'something'. Since I actually like having a Loading window, I just implemented a "DialogProgress" until the external plugin isn't actually launched.

(2016-11-02, 13:34)Roman_V_M Wrote: 2. I guess, you need to set "episodes" content type before adding any list items: http://mirrors.xbmc.org/docs/python-docs...setContent
(2016-11-02, 03:12)Protocol-X Wrote: Episode sorting will not show seasons as far as I am aware.

It was already set to episodes - xbmcplugin.setContent(addon_handle, 'episodes') - so it seems like that's indeed the case, episode sorting doesn't show seasons...?
I ended up just adding the season and episode number to the beginning of each episode title and forcing it to sort alphabetically. Seems to work as desired!

(2016-11-02, 13:34)Roman_V_M Wrote: 3. Yes, plugin calls are stateless so you need to implement some form of caching. There is commoncache plugin (http://forum.kodi.tv/showthread.php?tid=116496) but I've never used it myself so I cannot tell you more about it.

That did the trick, I even disabled my PHP/JSON server to be sure it was cached! So easy to set it up too Big Grin Huge difference now on loading times.

Thank you both for your help, by the way, I'm a happy camper now Big Grin
------------------------

If I can add another question to this thread, how do I set a specific Listitem to be highlighted as default? For example, so that I can go to the first unwatched episode on a list, instead of having to scroll all the way down.

All the highlight/focus information I found seem to be skin related, so apologizes if I missed it in the Kodi python-docs.

Depending

These are the 3 options i know of.
xbmc.executebuiltin('Control.Move(controlid, index)');
xbmc.executebuiltin('Control.SetFocus(controlid, index)')
self.getControl(controlid).selectItem(index);

They all require you do do some kind of manipulation on your end to determine what is watched. Else set the watched flag and hide watched items, using one of the above options.

This is what I do to remove an item from a multi list queue. I would use the same principal but checking for the watched flag.

PHP Code:
tCtrl self.getControl(20502);
                                    
tSize tCtrl.size();

                                    for 
tix in range(0tSize):

                                        try:

                                            
tItem tCtrl.getListItem(tix);

                                            if 
tItem:

                                                
tParam tItem.getProperty('myQueueParams');

                                                if 
tParam == qParams:
                                                    
tCtrl.removeItem(tix);

                                                    break;

                                        
except Exception as inst:
                                            
#self.logger.error(inst);
                                            
                                            
pass
Reply

Logout Mark Read Team Forum Stats Members Help
Add-on dev. 3 Newbie Questions0