Add-on Help / Advice / Input
#1
I have been looking into building an Add-on for Kodi and after reading over the links from the Wiki I managed to fumble my way though and get something that is most working. I am trying to polish it up now and get a better understand for some of the options. I am hoping that a wise someone here can either explain or point me towards some reading material to help me on my way.

What role does setting the content type play? I tried running though a couple of the different types and it didn't seem like the display changed any.
Code:
xbmcplugin.setContent(PLUGIN_HANDLE, "episodes")

What does setting the category do?
Code:
xbmcplugin.setPluginCategory(PLUGIN_HANDLE, "Foo Category")

Is there a way to keep session state in the add-on with out persisting to disk or some other form of persistent storage? When I was working on my Roku add-on while the app was active you could hold state for the session in a global. When you exited the add-on that state would be lost and recreated when it was next launched.

Is there a way to set the second sub title of the page as shown below?
watch gallery


Is there a way on error to abort further execution of the plugin? Take the following example (pseudo code) below:
Code:
def display_menu():
    api_data = api.fetch(...)

    if api_data["error"]:
        show dialog(...)
        stop further execution leaving current UI as it

    ...


Is there a guide / documentation that states how the different artwork is used when displaying (thumb vs poster vs icon vs ect.)?

Can you set a default fanart that is always present unless override by a MenuItem so the add-on has a constant background? I noticed that when I used a mouse and mouseout or selected the ".." option the background would revert to the theme's default.

Is there a way to hide the right side icon if it doesn't make sense to have something there?


If one wanted to implement a Rendezvous style registration:
Code:
The register example demonstrates how to do rendezvous style
registration.  Rendezvous registration presents the user with
a code (like Netflix, Amazon, etc.) and the user goes to the
providers web site to establish a link between the user account
and the box by using a short link code.

Is there some existing flow to support this or would one need to write some form of looping code to display the code, loop until the user registers, and then continue. I trying doing something along these lines using the ProgressDialog but didn't have much success.

Thanks again in advance for any and all help.
Kodi 19.0 | Ubuntu 20.04.2 | Kernel 5.4.0-67-generic | Intel i7-8700K | ASRock Z370 Gaming-ITX/ac | Ballistix Sport LT 2x16384MB (DDR4-2666) | Samsung 970 PRO 1TB |LG WH16NS60 | Cooler Master Elite 130 | Yamaha RX-A780Samsung Q70R
Reply
#2
Quote:What role does setting the content type play? I tried running though a couple of the different types and it didn't seem like the display changed any.
xbmcplugin.setContent(PLUGIN_HANDLE, "episodes")
The skin uses this info to pick what of the infolabels to display. This is very skin dependent.

Quote:What does setting the category do?
xbmcplugin.setPluginCategory(PLUGIN_HANDLE, "Foo Category")
when your plugin starts, it would display something like "Videos youraddonname" at the top. (like the screenshot in your original message)
any folder deeper than the first page of your plugin will have "youraddonname" changed to this value.

Quote:Is there a way to keep session state in the add-on with out persisting to disk or some other form of persistent storage?
there are add-ons that let you do this but i never tried them. I think they save/retrieve it on disk.
Another way is to put them in a super global variable window(10000) via setProperty()/getProperty()

Quote:Is there a guide / documentation that states how the different artwork is used when displaying (thumb vs poster vs icon vs ect.)?
none. you have to experiment which image gets shown where. this is dependent on the people who designed the skin. i do think that they have a general convention on which art is used where.

Quote:If one wanted to implement a Rendezvous style registration:
...
Is there some existing flow to support this or would one need to write some f...
none that I know of. no need to make a complicated thing to wait for user input. a yes/no dialog will do.
Reply
#3
@mossman1120

Quote:What role does setting the content type play?

It defines available views for your listing and what information is displayed in those views. However, views themselves depend on a skin used.

Quote:Is there a way to keep session state in the add-on with out persisting to disk or some other form of persistent storage?

Anything available in Python, from plain text files to databases. The recommended place for persistent files is an addon data folder that can be obtained as:
Code:
data_dir = addon.getAddonInfo('profile').decode('utf-8')
Also gedisony mentioned about storing string values in Kodi window properties.

Quote:Is there a way on error to abort further execution of the plugin?

Kodi addon is a normal Python script that finishes its work as soon as the last instruction has executed. You can use sys.exit(0) to terminate it prematurely or raise an appropriate exception to signal about some abnormal condition.

Quote:Can you set a default fanart that is always present unless override by a MenuItem so the add-on has a constant background? I noticed that when I used a mouse and mouseout or selected the ".." option the background would revert to the theme's default.
Addon fanart is used by default, except for "to upper level" (..) items that are handled by Kodi core. If you don't like those, you can hide ".." items in Kodi settings (I don't remember where exactly) and implement all navigation by yourself.

Quote:If one wanted to implement a Rendezvous style registration:

Python has a choice of authentication libraries (OAuth, social authentication and such). As for user interaction, xbmcgui module includes the necessary components for creating a custom UI for your addon, for example a login dialog. And I don't understand why you need a loop here, because the libraries that are commonly used to exchange data via HTTP protocol, like urllib2 or requests, are synchronous, that is, they block the current thread until they receive response from the remote server (or timeout expires).
Reply
#4
(2017-06-01, 18:12)gedisony Wrote:
Quote:What role does setting the content type play? I tried running though a couple of the different types and it didn't seem like the display changed any.
xbmcplugin.setContent(PLUGIN_HANDLE, "episodes")
The skin uses this info to pick what of the infolabels to display. This is very skin dependent.

(2017-06-01, 18:12)gedisony Wrote:
Quote:Is there a guide / documentation that states how the different artwork is used when displaying (thumb vs poster vs icon vs ect.)?
none. you have to experiment which image gets shown where. this is dependent on the people who designed the skin. i do think that they have a general convention on which art is used where.

Okay so I guess I will experiment with a couple of different skins to see what changes and make a best attempt for a good user experience.

(2017-06-01, 18:12)gedisony Wrote:
Quote:What does setting the category do?
xbmcplugin.setPluginCategory(PLUGIN_HANDLE, "Foo Category")
when your plugin starts, it would display something like "Videos youraddonname" at the top. (like the screenshot in your original message)
any folder deeper than the first page of your plugin will have "youraddonname" changed to this value.

I got the behavior on add-on entry but as I descended from the root folder that value didn't update. All of my menus use the same block:

Code:
xbmcplugin.setContent(PLUGIN_HANDLE, "tvshows | episodes")
    xbmcplugin.setPluginCategory(PLUGIN_HANDLE, "category based on location")
    xbmcplugin.addDirectoryItems(PLUGIN_HANDLE, menu_items_xbmc, len(menu_items_xbmc))
    xbmcplugin.addSortMethod(PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(PLUGIN_HANDLE)

Am I missing a step to get the behavior as you described?

(2017-06-01, 18:12)gedisony Wrote:
Quote:Is there a way to keep session state in the add-on with out persisting to disk or some other form of persistent storage?
there are add-ons that let you do this but i never tried them. I think they save/retrieve it on disk.
Another way is to put them in a super global variable window(10000) via setProperty()/getProperty()

I am using a disk cache for some API requests. As for more session type thing I was wondering about a place a value could be set so one doesn't have to pass it via the URL and it would be reset on exit from the app. Using the setProperty / getProperty is that value reset when the add-on exits?

(2017-06-01, 18:12)gedisony Wrote:
Quote:If one wanted to implement a Rendezvous style registration:
...
Is there some existing flow to support this or would one need to write some f...
none that I know of. no need to make a complicated thing to wait for user input. a yes/no dialog will do.

I didn't think I was trying to make it complicated. I just wanted the add-on to poll the server behind the scenes and once the user had linked it would close the dialog and refresh the UI.

(2017-06-01, 22:29)Roman_V_M Wrote: @mossman1120

Quote:What role does setting the content type play?

It defines available views for your listing and what information is displayed in those views. However, views themselves depend on a skin used.

Sounds good so I will set the more accurate one and test with some different skins to see how it looks.

(2017-06-01, 22:29)Roman_V_M Wrote:
Quote:Is there a way to keep session state in the add-on with out persisting to disk or some other form of persistent storage?

Anything available in Python, from plain text files to databases. The recommended place for persistent files is an addon data folder that can be obtained as:

Code:
data_dir = addon.getAddonInfo('profile').decode('utf-8')

Also gedisony mentioned about storing string values in Kodi window properties.

I am currently saving my cached API request to that location. I was looking for something more along the lines of a session storage that would be cleaned out upon add-on exit.

(2017-06-01, 22:29)Roman_V_M Wrote:
Quote:Is there a way on error to abort further execution of the plugin?

Kodi addon is a normal Python script that finishes its work as soon as the last instruction has executed. You can use sys.exit(0) to terminate it prematurely or raise an appropriate exception to signal about some abnormal condition.

Sounds like sys.exit(0 | n > 0) might be the way to go in the event of error. Just wanted to confirm Kodi would be okay with that.

[quote='Roman_V_M' pid='2595775' dateline='1496348980']
Quote:Can you set a default fanart that is always present unless override by a MenuItem so the add-on has a constant background? I noticed that when I used a mouse and mouseout or selected the ".." option the background would revert to the theme's default.
Addon fanart is used by default, except for "to upper level" (..) items that are handled by Kodi core. If you don't like those, you can hide ".." items in Kodi settings (I don't remember where exactly) and implement all navigation by yourself.

Oh interesting so in my addon.xml I would say remove ".." and then as I am generating my menu items I would add my version of the ".." to it where I can control the fan art?

(2017-06-01, 22:29)Roman_V_M Wrote:
Quote:If one wanted to implement a Rendezvous style registration:

Python has a choice of authentication libraries (OAuth, social authentication and such). As for user interaction, xbmcgui module includes the necessary components for creating a custom UI for your addon, for example a login dialog. And I don't understand why you need a loop here, because the libraries that are commonly used to exchange data via HTTP protocol, like urllib2 or requests, are synchronous, that is, they block the current thread until they receive response from the remote server (or timeout expires).

The loop here would be to poll the server to check for when the user has linked their account. This is so no user interaction to dismiss the dialog on Kodi would be needed. I would trigger a refresh and show logged in content specific to the user.
Kodi 19.0 | Ubuntu 20.04.2 | Kernel 5.4.0-67-generic | Intel i7-8700K | ASRock Z370 Gaming-ITX/ac | Ballistix Sport LT 2x16384MB (DDR4-2666) | Samsung 970 PRO 1TB |LG WH16NS60 | Cooler Master Elite 130 | Yamaha RX-A780Samsung Q70R
Reply
#5
Quote:xbmcplugin.setContent(PLUGIN_HANDLE, "tvshows | episodes")
xbmcplugin.setPluginCategory(PLUGIN_HANDLE, "category based on location")
xbmcplugin.addDirectoryItems(PLUGIN_HANDLE, menu_items_xbmc, len(menu_items_xbmc))
xbmcplugin.addSortMethod(PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(PLUGIN_HANDLE)

Am I missing a step to get the behavior as you described?
Sorry about that, the setPluginCategory() thing I mentioned depends on the skin.
it works in in estuary(default krypton skin) but didn't when i tried it in a different skin.

Also, "tvshows | episodes" in xbmcplugin.setContent() won't work.
it has to be just "tvshows" or "episodes"
earlier versions of kodi lets you put any string here.
in krypton, your list won't show up if it is not one of
files, songs, artists, albums, movies, tvshows, episodes, musicvideos

Quote: Using the setProperty / getProperty is that value reset when the add-on exits?
the window(10000) setProperty / getProperty does not reset when the add-on exits.

I'm not familiar with Rendezvous style registration but it sounds a lot like "pair" from a notorious site without the 'enter your code' part.
basically they want you to visit their site using the browser, hit "i'm not a robot" and they will allow your ip address access for x hours.
a very popular addon that use that site just pops a dialog that waits for about 1 minute.
Reply
#6
(2017-06-02, 19:43)gedisony Wrote:
Quote:xbmcplugin.setContent(PLUGIN_HANDLE, "tvshows | episodes")
xbmcplugin.setPluginCategory(PLUGIN_HANDLE, "category based on location")
xbmcplugin.addDirectoryItems(PLUGIN_HANDLE, menu_items_xbmc, len(menu_items_xbmc))
xbmcplugin.addSortMethod(PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(PLUGIN_HANDLE)

Am I missing a step to get the behavior as you described?
Sorry about that, the setPluginCategory() thing I mentioned depends on the skin.
it works in in estuary(default krypton skin) but didn't when i tried it in a different skin.

Also, "tvshows | episodes" in xbmcplugin.setContent() won't work.
it has to be just "tvshows" or "episodes"
earlier versions of kodi lets you put any string here.
in krypton, your list won't show up if it is not one of
files, songs, artists, albums, movies, tvshows, episodes, musicvideos

Quote: Using the setProperty / getProperty is that value reset when the add-on exits?
the window(10000) setProperty / getProperty does not reset when the add-on exits.

I'm not familiar with Rendezvous style registration but it sounds a lot like "pair" from a notorious site without the 'enter your code' part.
basically they want you to visit their site using the browser, hit "i'm not a robot" and they will allow your ip address access for x hours.
a very popular addon that use that site just pops a dialog that waits for about 1 minute.

I was taking a bit of a liberty there and using some pseudo code to represent one or the other. I don't actually use the "episodes | tvshows" but thank you for the clarification.

Ah okay so setContent is persist as well. I guess I will just pass my "session" values in via the URI.

As for the other add-on that you speak of...my intent isn't to do something sneaky / malicious. I got the idea from a Roku add-on that I built as it is their preferred way to link. The idea being you have an account on a site currently. You get a media player and want to link it to your exiting account. Rather than typing in your username and password which on the Roku doesn't have a keyboard just a controller it shows you a 8 character code. On your computer you sign in to the website and enter that code. The Roku is polling in the background and once it gets a linked command back from the website your Roku is linked to your account. To unlink you delete the association from your account. There no wait period or click bait or things of that nature. The method is used by Amazon / Netflix for linking a users device to their respective Amazon / Netflix account on their device. It doesn't support someone else's add-on getting access to Amazon / Netflix content.

I think based on the feedback I can implement I would just remove the automatic polling from the add-on in lieu of a button the user presses that will check to see if the account is linked.
Kodi 19.0 | Ubuntu 20.04.2 | Kernel 5.4.0-67-generic | Intel i7-8700K | ASRock Z370 Gaming-ITX/ac | Ballistix Sport LT 2x16384MB (DDR4-2666) | Samsung 970 PRO 1TB |LG WH16NS60 | Cooler Master Elite 130 | Yamaha RX-A780Samsung Q70R
Reply

Logout Mark Read Team Forum Stats Members Help
Add-on Help / Advice / Input0
This forum uses Lukasz Tkacz MyBB addons.