WIP HTTP caching proxy


New member
Apr 21, 2013
This is a WIP caching server for Kodi. It can currently only handle http live streams, but I do plan to add hls and seeking support as well. When the player requests a file, DownloadThread will download the stream continuously until a new file has been requested or the player has been disconnected for 15 minutes. Re-requesting the file before the 15 minute timeout will give Kodi all the data that had been downloaded since the player last disconnected.

Why might this be useful?
  • cache to reduce buffering
  • full control of headers
  • handle disconnects and changeovers
  • hide Kodi's connection patterns

Here's the code:

Here's an example of how to build a url:
    'User-Agent':'Lavf/57.40.101\r\nAccept: */*\r\nRange: bytes=0-\r\nConnection: close\r\nHost: '+urlparse.urlparse(url).netloc+'\r\nIcy-MetaData: 1',
link = base64.b64encode(json.dumps({"url": url, "headers": headers}))
url = '' + link + '.ts'
The header's being structured like that is an old sort-of-bug in requests that I reintroduced through monkeypatches. It allows you to take full control of the contents and order of the headers being sent.

I'm probably going to implement this into my addons by creating an interstitial that starts the download when loaded and gives the options to start the video or stop the download. Anyways, hope someone finds this useful.
Last edited: