jellyfin-kodi/resources/lib/image_cache_thread.py

61 lines
1.4 KiB
Python
Raw Normal View History

2016-06-18 03:03:28 +00:00
# -*- coding: utf-8 -*-
#################################################################################################
import logging
import threading
2016-10-28 05:02:47 +00:00
import requests
#################################################################################################
log = logging.getLogger("EMBY."+__name__)
2016-06-18 03:03:28 +00:00
#################################################################################################
2016-10-28 05:02:47 +00:00
class ImageCacheThread(threading.Thread):
url_to_process = None
is_finished = False
xbmc_host = ""
xbmc_port = ""
xbmc_username = ""
xbmc_password = ""
2016-10-28 05:02:47 +00:00
2016-06-18 03:03:28 +00:00
def __init__(self):
2016-06-18 03:03:28 +00:00
threading.Thread.__init__(self)
2016-06-18 03:03:28 +00:00
2016-10-28 05:02:47 +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
self.xbmc_host = host
self.xbmc_port = port
2016-06-18 03:03:28 +00:00
2016-10-28 05:02:47 +00:00
def set_auth(self, username, password):
self.xbmc_username = username
self.xbmc_password = password
def run(self):
2016-10-28 05:02:47 +00:00
log.debug("Image Caching Thread Processing: %s", self.url_to_process)
try:
2016-10-28 05:02:47 +00:00
requests.head(
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))
# We don't need the result
2016-10-28 05:02:47 +00:00
except Exception:
pass
log.debug("Image Caching Thread Exited")
2016-10-28 05:02:47 +00:00
self.is_finished = True