2016-01-16 14:07:36 +11:00
|
|
|
import threading
|
|
|
|
import utils
|
|
|
|
import xbmc
|
|
|
|
import requests
|
|
|
|
|
2016-04-07 02:23:51 +10:00
|
|
|
# Disable annoying requests warnings
|
|
|
|
import requests.packages.urllib3
|
|
|
|
requests.packages.urllib3.disable_warnings()
|
2016-03-24 02:57:49 +11:00
|
|
|
|
2016-01-27 03:20:13 +11:00
|
|
|
|
|
|
|
@utils.logging
|
2016-01-16 14:07:36 +11:00
|
|
|
class image_cache_thread(threading.Thread):
|
|
|
|
|
|
|
|
urlToProcess = None
|
|
|
|
isFinished = False
|
|
|
|
|
|
|
|
xbmc_host = ""
|
|
|
|
xbmc_port = ""
|
|
|
|
xbmc_username = ""
|
|
|
|
xbmc_password = ""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.monitor = xbmc.Monitor()
|
|
|
|
threading.Thread.__init__(self)
|
2016-01-27 03:20:13 +11:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
def setUrl(self, url):
|
|
|
|
self.urlToProcess = url
|
|
|
|
|
|
|
|
def setHost(self, host, port):
|
|
|
|
self.xbmc_host = host
|
|
|
|
self.xbmc_port = port
|
|
|
|
|
|
|
|
def setAuth(self, user, pwd):
|
|
|
|
self.xbmc_username = user
|
|
|
|
self.xbmc_password = pwd
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
|
|
|
self.logMsg("Image Caching Thread Processing : " + self.urlToProcess, 2)
|
|
|
|
|
|
|
|
try:
|
|
|
|
response = requests.head(
|
|
|
|
url=(
|
|
|
|
"http://%s:%s/image/image://%s"
|
|
|
|
% (self.xbmc_host, self.xbmc_port, self.urlToProcess)),
|
|
|
|
auth=(self.xbmc_username, self.xbmc_password),
|
2016-03-14 02:12:25 +11:00
|
|
|
timeout=(5, 5))
|
2016-01-16 14:07:36 +11:00
|
|
|
# We don't need the result
|
|
|
|
except: pass
|
|
|
|
|
|
|
|
self.logMsg("Image Caching Thread Exited", 2)
|
|
|
|
|
|
|
|
self.isFinished = True
|
|
|
|
|