2016-06-18 03:03:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2016-07-24 08:59:48 +00:00
|
|
|
import logging
|
|
|
|
import threading
|
2016-08-22 02:51:23 +00:00
|
|
|
import requests
|
2016-01-16 03:07:36 +00:00
|
|
|
|
2016-07-24 08:59:48 +00:00
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
log = logging.getLogger("EMBY."+__name__)
|
2016-06-18 03:03:28 +00:00
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2016-08-22 02:51:23 +00:00
|
|
|
class ImageCacheThread(threading.Thread):
|
|
|
|
|
|
|
|
url_to_process = None
|
|
|
|
is_finished = False
|
2016-01-16 03:07:36 +00:00
|
|
|
|
|
|
|
xbmc_host = ""
|
|
|
|
xbmc_port = ""
|
|
|
|
xbmc_username = ""
|
|
|
|
xbmc_password = ""
|
2016-08-22 02:51:23 +00:00
|
|
|
|
2016-06-18 03:03:28 +00:00
|
|
|
|
2016-01-16 03:07:36 +00:00
|
|
|
def __init__(self):
|
2016-06-18 03:03:28 +00:00
|
|
|
|
2016-01-16 03:07:36 +00:00
|
|
|
threading.Thread.__init__(self)
|
2016-06-18 03:03:28 +00:00
|
|
|
|
|
|
|
|
2016-08-22 02:51:23 +00:00
|
|
|
def set_url(self, url):
|
|
|
|
|
|
|
|
self.url_to_process = url
|
|
|
|
|
|
|
|
def set_host(self, host, port):
|
2016-06-18 03:03:28 +00:00
|
|
|
|
2016-01-16 03:07:36 +00:00
|
|
|
self.xbmc_host = host
|
|
|
|
self.xbmc_port = port
|
2016-06-18 03:03:28 +00:00
|
|
|
|
2016-08-22 02:51:23 +00:00
|
|
|
def set_auth(self, username, password):
|
|
|
|
|
|
|
|
self.xbmc_username = username
|
|
|
|
self.xbmc_password = password
|
|
|
|
|
2016-01-16 03:07:36 +00:00
|
|
|
def run(self):
|
2016-08-22 02:51:23 +00:00
|
|
|
|
2016-08-22 02:57:43 +00:00
|
|
|
log.debug("Image Caching Thread Processing: %s", self.url_to_process)
|
2016-01-16 03:07:36 +00:00
|
|
|
|
|
|
|
try:
|
2016-08-22 02:51:23 +00:00
|
|
|
requests.head(
|
2016-08-22 02:57:43 +00:00
|
|
|
url=("http://%s:%s/image/image://%s"
|
|
|
|
% (self.xbmc_host, self.xbmc_port, self.url_to_process)),
|
|
|
|
auth=(self.xbmc_username, self.xbmc_password),
|
|
|
|
timeout=(35.1, 35.1))
|
2016-01-16 03:07:36 +00:00
|
|
|
# We don't need the result
|
2016-08-22 02:57:43 +00:00
|
|
|
except Exception:
|
2016-08-22 02:51:23 +00:00
|
|
|
pass
|
|
|
|
|
2016-07-24 08:59:48 +00:00
|
|
|
log.debug("Image Caching Thread Exited")
|
2016-08-22 02:51:23 +00:00
|
|
|
self.is_finished = True
|