Solved Make Addon Data persistant
#1
Hello Forum,
im currently working on a Video Addon, but since scraping over 1400 videos from the website all the time takes a few minutes and nobody wants to wait this long to get a simple video-list, i would like to store the data between addon sessions.

The python-code itself works just fine (created & tested in PyCharm), but i cant load the json-file with the same code when Kodi runns it.
I've read that the addon-folder is read-only, but i ant even read the file, and i'd like to know how to write files to the filesystem anyway.

I'm actually really confused that i found next to nothing addressing this, and i searched quite a bit.

The file is named 'library.json' and located in 'resources/data/'.
I'm testing on KODI v18 Leia.

thank you for your help
A20
Reply
#2
(2019-04-08, 16:12)a20gameco Wrote: Hello Forum,
im currently working on a Video Addon, but since scraping over 1400 videos from the website all the time takes a few minutes and nobody wants to wait this long to get a simple video-list, i would like to store the data between addon sessions.

The python-code itself works just fine (created & tested in PyCharm), but i cant load the json-file with the same code when Kodi runns it.
I've read that the addon-folder is read-only, but i ant even read the file, and i'd like to know how to write files to the filesystem anyway.

I'm actually really confused that i found next to nothing addressing this, and i searched quite a bit.

The file is named 'library.json' and located in 'resources/data/'.
I'm testing on KODI v18 Leia.

thank you for your help
A20

Are you aware that there is an area for an add-on to store data?
That area is typically userdata/addon_data/ your_addon_id/
You are able to read/write data to this location.
Here's some code that may work for you:
Python:

ADDON = xbmcaddon.Addon()
ADDONID = ADDON.getAddonInfo('id')
ADDON_USERDATA_FOLDER = xbmc.translatePath("special://profile/addon_data/"+ADDONID)
Now that you have a reference to the physical location of your data area, you can read/write data to that location all day long.
Here's a link to more information: Userdata Doc
Reply
#3
Aaaaah, thank you very much!

That was excactly what i was searching for.
Reply
#4
Thread marked solved.
Reply

Logout Mark Read Team Forum Stats Members Help
Make Addon Data persistant0