2016-06-18 13:03:28 +10:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2016-07-25 13:39:40 +10:00
|
|
|
import logging
|
2016-01-16 14:07:36 +11:00
|
|
|
import requests
|
2016-07-25 13:39:40 +10:00
|
|
|
import threading
|
2016-01-16 14:07:36 +11:00
|
|
|
|
2016-07-25 13:39:40 +10:00
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
log = logging.getLogger("EMBY."+__name__)
|
2016-06-18 13:03:28 +10:00
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
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 = ""
|
|
|
|
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
def __init__(self):
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
threading.Thread.__init__(self)
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
|
|
|
|
def setUrl(self, url):
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
self.urlToProcess = url
|
|
|
|
|
|
|
|
def setHost(self, host, port):
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
self.xbmc_host = host
|
|
|
|
self.xbmc_port = port
|
|
|
|
|
|
|
|
def setAuth(self, user, pwd):
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
self.xbmc_username = user
|
|
|
|
self.xbmc_password = pwd
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
2016-07-25 13:39:40 +10:00
|
|
|
log.debug("Image Caching Thread Processing: %s" % self.urlToProcess)
|
2016-01-16 14:07:36 +11:00
|
|
|
|
|
|
|
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),
|
|
|
|
timeout=(35.1, 35.1))
|
|
|
|
# We don't need the result
|
|
|
|
except: pass
|
|
|
|
|
2016-07-25 13:39:40 +10:00
|
|
|
log.debug("Image Caching Thread Exited")
|
2016-06-18 13:03:28 +10:00
|
|
|
self.isFinished = True
|