Kodi Community Forum
[release] script.module.requests-cache - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: [release] script.module.requests-cache (/showthread.php?tid=316817)



[release] script.module.requests-cache - gedisony - 2017-06-18

https://github.com/reclosedev/requests-cache
packaged for kodi

if you use the requests package to communicate with web sites, requests-cache offers a transparent way to cache the replies from those sites without much change in your code.
Just import the requests-cache package, set-up the cache file and all requests response will be cached.

usage:
Code:
import requests_cache

#define the cache file to reside in the ..\Kodi\userdata\addon_data\(your addon)
addonUserDataFolder = xbmc.translatePath(addon.getAddonInfo('profile'))
CACHE_FILE          = xbmc.translatePath(os.path.join(addonUserDataFolder, 'requests_cache'))

#cache expires after: 86400=1 day   604800=7 days
requests_cache.install_cache(CACHE_FILE, backend='sqlite', expire_after=604800 )