Kodi addons : how can I cache / load datas?

304 Views Asked by At

I’m writing a video addon that loads datas from a web API.

My problem is that, each time I access an (already) visited virtual folder, it loads the data again, while it could be cached - and it makes my addon slow.

Is there some core function to cache then get cached datas for Kodi addons ?

Thanks

2

There are 2 best solutions below

0
Alex B On

I guess you can just store your request results in the Kodi data folder

0
Roman Miroshnychenko On

There is no such "core" function, so you need to implement your own caching mechanism. An addon has its "profile" directory where it can store its own arbitrary files. A profile directory path can be obtained the following way:

  import xbmcaddon
  import xbmcvfs

  profile_dir = xbmcvfs.translatePath(xbmcaddon.Addon().getAddonInfo('profile'))