PlexKodiConnect/resources/lib/image_cache_thread.py

38 lines
1.2 KiB
Python
Raw Normal View History

2016-06-18 13:03:28 +10:00
# -*- coding: utf-8 -*-
###############################################################################
import logging
import threading
import requests
# Disable annoying requests warnings
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
###############################################################################
2016-08-30 23:55:13 +10:00
log = logging.getLogger("PLEX."+__name__)
2016-06-18 13:03:28 +10:00
###############################################################################
2016-01-27 03:20:13 +11:00
2016-08-22 12:51:23 +10:00
class ImageCacheThread(threading.Thread):
def __init__(self, xbmc_username, xbmc_password, url):
self.xbmc_username = xbmc_username
self.xbmc_password = xbmc_password
self.url = url
threading.Thread.__init__(self)
2016-01-27 03:20:13 +11:00
def run(self):
try:
requests.head(
url=self.url,
2016-09-12 02:31:25 +10:00
auth=(self.xbmc_username, self.xbmc_password),
timeout=(0.01, 0.01))
except requests.Timeout:
# We don't need the result, only trigger Kodi to start download
2016-08-22 12:51:23 +10:00
pass
except Exception as e:
log.error('Encountered exception: %s' % e)
import traceback
log.error("Traceback:\n%s" % traceback.format_exc())