[release] script.module.requests-cache

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
gedisony Offline
Senior Member
Posts: 225
Joined: Mar 2015
Reputation: 13
Post: #1
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.

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 )
(This post was last modified: 2017-06-18 22:34 by gedisony.)
find quote