Installing an addon to Kodi (without going through its UI)
#1
OK, I have an addon I'm tweaking. Now I want to see if the tweak works.
  • I find my addon in ~/.kodi/addons/addonid
  • I tweak it (just change some text)
  • No change in Kodi
  • Reload the skin, no change in Kodi
  • Exit Kodi, and start it again, the change is reflected in Kodi

In a similar vein, I can:
 
  • copy ~/.kodi/addons/addonid to ~/.kodi/addons/addonid_new
  • edit addon.xml and make sure it refers to addonid_new
    xml:
    <addon id="addonid_new" ...>
  • tweak that, and it's not even seen by Kodi when I restart Kodi!

Can I ask Kodi to reload all addons somehow?

Can I register a new addon with Kodi somehow without making a zip and using the UI to install via zip?

A quick easy way to publish an addon I'm working on to the kodi server would be nice, and I can't seem to find one. This seems overlooked in everything I have read on the wiki and elsewhere to date.
Reply
#2
I should add, in the second case that the addon does appear in Kore. Odd.
Reply
#3
Add-on metadata is stored in /(appdata of your OS)/Kodi/userdata/Database/Addons##.db
It lists which add-ons are installed. Simply adding a folder to the /addons/ folder will not make it recognize that new add-on, as you've noticed.

The only way I know of debugging an add-on is to write as most as I can at first, make a ZIP out of it, install it on Kodi, then go and edit the installed source files inside /addons/plugin.video.myaddonname/ while Kodi is running, switching to Kodi and use the add-on to see where it fails etc., as it reloads the Python scripts in between different folders (17.6 works like this, I don't know about 18+). 
To distribute that add-on, I just pack the installed source files into a new ZIP (after removing the .PYO files).

This means I just use a text editor (Notepad++) and Kodi itself, no IDE or dev environment. 
I make plenty of use of text debug, the function is this: 
python:
import xbmc

(...)

def xbmcDebug(*args):
    xbmc.log('MY_ADDON > ' + ' '.join((val if isinstance(val, str) else repr(val)) for val in args), xbmc.LOGNOTICE)

# Calling it like: xbmcDebug('Test response', response.content, otherObject, etc)
It outputs to (appdata of your OS)/Kodi/kodi.log, I keep that file open on Notepad++ and set the Preferences -> MISC. -> Update Silently setting on so it always shows the latest log state. 

Debugging addon.xml is the toughest, you either restart Kodi or reinstall the add-on.
Reply
#4
(2019-08-31, 13:47)doko-desuka Wrote: Add-on metadata is stored in /(appdata of your OS)/Kodi/userdata/Database/Addons##.db
It lists which add-ons are installed. Simply adding a folder to the /addons/ folder will not make it recognize that new add-on, as you've noticed.

The only way I know of debugging an add-on is to write as most as I can at first, make a ZIP out of it, install it on Kodi, then go and edit the installed source files inside /addons/plugin.video.myaddonname/ while Kodi is running, switching to Kodi and use the add-on to see where it fails etc., as it reloads the Python scripts in between different folders (17.6 works like this, I don't know about 18+). 
To distribute that add-on, I just pack the installed source files into a new ZIP (after removing the .PYO files).

This means I just use a text editor (Notepad++) and Kodi itself, no IDE or dev environment. 
I make plenty of use of text debug, the function is this: 
python:
import xbmc

(...)

def xbmcDebug(*args):
    xbmc.log('MY_ADDON > ' + ' '.join((val if isinstance(val, str) else repr(val)) for val in args), xbmc.LOGNOTICE)

# Calling it like: xbmcDebug('Test response', response.content, otherObject, etc)
It outputs to (appdata of your OS)/Kodi/kodi.log, I keep that file open on Notepad++ and set the Preferences -> MISC. -> Update Silently setting on so it always shows the latest log state. 

Debugging addon.xml is the toughest, you either restart Kodi or reinstall the add-on.
Thank you very much for the clarifications!

It would be great to see some doc on exactly when Kodi loads addon.xml, the python script it refers to, and any resources etc, and what in Kodi can trigger a reload. Perhaps we could write an addoon script that  reloads all addons (addon.xml, resources and scripts)?

I also wonder if writing tuples to /(Kodi folder)/userdata/Database/Addons##.db would register with Kodi, though I suspect:
  1. That's risky as the schema may change, and looking at it it's got some interesting structure.
  2. Kodi may not read this database any more frequently or predictably than it does the addon.xml file or python scripts.
Still it'd be so nice to be able to write a simple bash script that publishes an addon to Kodi and sees it respected there, if there was some trigger in Kodi to say "reload this addon". Perhaps that's a Kodi feature request to stick here: https://github.com/xbmc/xbmc/issues ?

I can't find Preferences -> MISC. -> Update Silently mind you. Is that in the Kodi UI? I see Power > Settings but no MISC category, and I see Settings > ... but no MISC category. I'm using the Amber skin mind you, is that a skin specific setting?
Reply
#5
You can disable and re-enable your addon via a script.  That would allow you to test your tweaks.
eg something like this:
Quote:import xbmc
ADDON_ID = xxxxxxxxxxxxxxxxxxxxxxxxxxxx

xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","id":8,"params":{"addonid":"%s","enabled":false}}'% ADDON_ID)
xbmc.sleep(1000)
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","id":8,"params":{"addonid":"%s","enabled":true}}'% ADDON_ID)
You can pretty it up by adding checks and notifications, but the above should hopefully work.  Save it somewhere in userdata and run it from a favourite / shortcut / keyboard or remote key.
There may be a better way, if so I don't know it.
Reply
#6
(2019-08-31, 23:36)ThumbOne Wrote: I can't find Preferences -> MISC. -> Update Silently mind you. Is that in the Kodi UI?
I should've been clearer, that's a setting in Notepad++, my text editor, to listen to changes to files that are open in it.
This way when the kodi.log file is updated Notepad++ reloads it.

@trogggy if that trick reloads addon.xml without having to do those things I mentioned, then that's pretty cool!
Reply
#7
(2019-08-31, 23:36)ThumbOne Wrote: 2. Kodi may not read this database any more frequently or predictably than it does the addon.xml file or python scripts.
You should test if trogggy's suggestion causes a database reload. In case it doesn't, it's also worth testing if the LoadProfile() built-in command does that as well, I know for sure that it causes at least the reload of the favorites file, as I use it in this add-on.
Reply
#8
(2019-09-01, 01:49)doko-desuka Wrote: You should test if trogggy's suggestion causes a database reload.
It's just possible that I've used this method a squillion times already. Wink

edit: I use profile reload for favourites as well but it's a nuisance as it resets everything.  You may as well restart.
Reply

Logout Mark Read Team Forum Stats Members Help
Installing an addon to Kodi (without going through its UI)0