2016-06-18 13:03:28 +10:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2016-07-24 18:59:48 +10:00
|
|
|
import logging
|
2016-01-16 14:07:36 +11:00
|
|
|
import threading
|
|
|
|
import requests
|
|
|
|
|
2016-04-07 02:23:51 +10:00
|
|
|
# Disable annoying requests warnings
|
|
|
|
import requests.packages.urllib3
|
|
|
|
requests.packages.urllib3.disable_warnings()
|
2016-07-24 18:59:48 +10:00
|
|
|
#################################################################################################
|
|
|
|
|
2016-08-30 23:55:13 +10:00
|
|
|
log = logging.getLogger("PLEX."+__name__)
|
2016-06-18 13:03:28 +10:00
|
|
|
|
|
|
|
#################################################################################################
|
2016-03-24 02:57:49 +11:00
|
|
|
|
2016-01-27 03:20:13 +11:00
|
|
|
|
2016-08-22 12:51:23 +10:00
|
|
|
class ImageCacheThread(threading.Thread):
|
|
|
|
|
|
|
|
url_to_process = None
|
|
|
|
is_finished = False
|
2016-01-16 14:07:36 +11:00
|
|
|
|
|
|
|
xbmc_host = ""
|
|
|
|
xbmc_port = ""
|
|
|
|
xbmc_username = ""
|
|
|
|
xbmc_password = ""
|
2016-08-22 12:51:23 +10:00
|
|
|
|
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-01-27 03:20:13 +11:00
|
|
|
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-08-22 12:51:23 +10:00
|
|
|
def set_url(self, url):
|
|
|
|
|
|
|
|
self.url_to_process = url
|
|
|
|
|
|
|
|
def set_host(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
|
2016-06-18 13:03:28 +10:00
|
|
|
|
2016-08-22 12:51:23 +10:00
|
|
|
def set_auth(self, username, password):
|
|
|
|
|
|
|
|
self.xbmc_username = username
|
|
|
|
self.xbmc_password = password
|
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
def run(self):
|
|
|
|
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
|
2016-08-22 12:57:43 +10:00
|
|
|
except Exception:
|
2016-08-22 12:51:23 +10:00
|
|
|
pass
|
|
|
|
self.is_finished = True
|