2015-12-25 06:51:47 +11:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-02-20 06:03:06 +11:00
|
|
|
###############################################################################
|
2017-12-09 05:43:06 +11:00
|
|
|
from logging import getLogger
|
2017-12-10 00:35:08 +11:00
|
|
|
from Queue import Queue, Empty
|
2016-09-17 22:02:50 +10:00
|
|
|
from urllib import quote_plus, unquote
|
2016-10-19 05:32:16 +11:00
|
|
|
from threading import Thread
|
2017-12-10 00:35:08 +11:00
|
|
|
import requests
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-05-30 15:53:30 +10:00
|
|
|
import xbmc
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-06-24 02:25:18 +10:00
|
|
|
from . import path_ops
|
2018-06-22 03:24:37 +10:00
|
|
|
from . import utils
|
|
|
|
from . import state
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2016-08-30 03:39:59 +10:00
|
|
|
###############################################################################
|
2018-06-22 03:24:37 +10:00
|
|
|
LOG = getLogger('PLEX.artwork')
|
2016-03-24 02:57:49 +11:00
|
|
|
|
2018-03-02 17:36:45 +11:00
|
|
|
# Disable annoying requests warnings
|
|
|
|
requests.packages.urllib3.disable_warnings()
|
2017-01-21 03:21:51 +11:00
|
|
|
ARTWORK_QUEUE = Queue()
|
2018-04-29 22:11:03 +10:00
|
|
|
IMAGE_CACHING_SUSPENDS = ['SUSPEND_LIBRARY_THREAD', 'DB_SCAN', 'STOP_SYNC']
|
2018-06-22 03:24:37 +10:00
|
|
|
if not utils.settings('imageSyncDuringPlayback') == 'true':
|
2018-04-29 22:11:03 +10:00
|
|
|
IMAGE_CACHING_SUSPENDS.append('SUSPEND_SYNC')
|
|
|
|
|
2018-03-04 23:39:18 +11:00
|
|
|
###############################################################################
|
2017-01-21 03:21:51 +11:00
|
|
|
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2016-09-17 22:02:50 +10:00
|
|
|
def double_urlencode(text):
|
|
|
|
return quote_plus(quote_plus(text))
|
|
|
|
|
|
|
|
|
|
|
|
def double_urldecode(text):
|
|
|
|
return unquote(unquote(text))
|
|
|
|
|
|
|
|
|
2018-06-22 03:24:37 +10:00
|
|
|
@utils.thread_methods(add_suspends=IMAGE_CACHING_SUSPENDS)
|
2016-09-17 19:24:12 +10:00
|
|
|
class Image_Cache_Thread(Thread):
|
2018-05-15 01:56:39 +10:00
|
|
|
sleep_between = 50
|
2016-12-21 02:13:19 +11:00
|
|
|
# Potentially issues with limited number of threads
|
|
|
|
# Hence let Kodi wait till download is successful
|
|
|
|
timeout = (35.1, 35.1)
|
2016-09-17 18:58:08 +10:00
|
|
|
|
2017-01-21 03:21:51 +11:00
|
|
|
def __init__(self):
|
|
|
|
self.queue = ARTWORK_QUEUE
|
2016-09-17 19:24:12 +10:00
|
|
|
Thread.__init__(self)
|
|
|
|
|
|
|
|
def run(self):
|
2018-04-29 22:11:03 +10:00
|
|
|
LOG.info("---===### Starting Image_Cache_Thread ###===---")
|
2018-02-12 00:57:39 +11:00
|
|
|
stopped = self.stopped
|
|
|
|
suspended = self.suspended
|
2016-09-17 19:24:12 +10:00
|
|
|
queue = self.queue
|
2016-09-17 23:39:20 +10:00
|
|
|
sleep_between = self.sleep_between
|
2018-05-16 04:46:16 +10:00
|
|
|
counter = 0
|
|
|
|
set_zero = False
|
2018-02-12 00:57:39 +11:00
|
|
|
while not stopped():
|
2016-09-17 19:24:12 +10:00
|
|
|
# In the event the server goes offline
|
2018-02-12 00:57:39 +11:00
|
|
|
while suspended():
|
2016-09-17 19:24:12 +10:00
|
|
|
# Set in service.py
|
2018-02-12 00:57:39 +11:00
|
|
|
if stopped():
|
2016-09-17 19:24:12 +10:00
|
|
|
# Abort was requested while waiting. We should exit
|
2017-12-09 05:43:06 +11:00
|
|
|
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
|
2016-09-17 19:24:12 +10:00
|
|
|
return
|
2018-05-30 15:53:30 +10:00
|
|
|
xbmc.sleep(1000)
|
2018-05-16 04:46:16 +10:00
|
|
|
|
2016-09-17 19:24:12 +10:00
|
|
|
try:
|
|
|
|
url = queue.get(block=False)
|
2017-01-21 03:21:51 +11:00
|
|
|
except Empty:
|
2018-05-30 15:53:30 +10:00
|
|
|
if not set_zero and not xbmc.getCondVisibility(
|
|
|
|
'Window.IsVisible(DialogAddonSettings.xml)'):
|
2018-05-18 23:59:26 +10:00
|
|
|
# Avoid saving '0' all the time
|
|
|
|
set_zero = True
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('caching_artwork_count', value='0')
|
2018-05-30 15:53:30 +10:00
|
|
|
xbmc.sleep(1000)
|
2016-09-17 19:24:12 +10:00
|
|
|
continue
|
2018-05-18 23:59:26 +10:00
|
|
|
set_zero = False
|
2018-04-29 22:12:39 +10:00
|
|
|
if isinstance(url, ArtworkSyncMessage):
|
2018-05-16 04:46:16 +10:00
|
|
|
if state.IMAGE_SYNC_NOTIFICATIONS:
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.dialog('notification',
|
|
|
|
heading=utils.lang(29999),
|
|
|
|
message=url.message,
|
|
|
|
icon='{plex}',
|
|
|
|
sound=False)
|
2018-04-29 22:12:39 +10:00
|
|
|
queue.task_done()
|
|
|
|
continue
|
2018-06-22 03:24:37 +10:00
|
|
|
url = double_urlencode(utils.try_encode(url))
|
2017-01-21 03:32:28 +11:00
|
|
|
sleeptime = 0
|
2016-09-17 19:24:12 +10:00
|
|
|
while True:
|
2016-09-17 22:02:50 +10:00
|
|
|
try:
|
|
|
|
requests.head(
|
|
|
|
url="http://%s:%s/image/image://%s"
|
2017-12-10 01:41:07 +11:00
|
|
|
% (state.WEBSERVER_HOST,
|
|
|
|
state.WEBSERVER_PORT,
|
|
|
|
url),
|
|
|
|
auth=(state.WEBSERVER_USERNAME,
|
|
|
|
state.WEBSERVER_PASSWORD),
|
2016-10-18 07:34:15 +11:00
|
|
|
timeout=self.timeout)
|
2016-09-17 22:02:50 +10:00
|
|
|
except requests.Timeout:
|
|
|
|
# We don't need the result, only trigger Kodi to start the
|
|
|
|
# download. All is well
|
|
|
|
break
|
|
|
|
except requests.ConnectionError:
|
2018-02-12 00:57:39 +11:00
|
|
|
if stopped():
|
2017-01-25 06:12:46 +11:00
|
|
|
# Kodi terminated
|
|
|
|
break
|
2016-09-17 22:02:50 +10:00
|
|
|
# Server thinks its a DOS attack, ('error 10053')
|
|
|
|
# Wait before trying again
|
2017-01-21 03:32:28 +11:00
|
|
|
if sleeptime > 5:
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.error('Repeatedly got ConnectionError for url %s',
|
|
|
|
double_urldecode(url))
|
2016-09-17 22:02:50 +10:00
|
|
|
break
|
2017-12-09 05:43:06 +11:00
|
|
|
LOG.debug('Were trying too hard to download art, server '
|
2016-09-17 22:02:50 +10:00
|
|
|
'over-loaded. Sleep %s seconds before trying '
|
2018-03-04 23:39:18 +11:00
|
|
|
'again to download %s',
|
|
|
|
2**sleeptime, double_urldecode(url))
|
2018-05-30 15:53:30 +10:00
|
|
|
xbmc.sleep((2**sleeptime) * 1000)
|
2017-01-21 03:32:28 +11:00
|
|
|
sleeptime += 1
|
2016-09-17 22:02:50 +10:00
|
|
|
continue
|
2018-05-13 22:20:39 +10:00
|
|
|
except Exception as err:
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.error('Unknown exception for url %s: %s'.
|
2018-05-13 22:20:39 +10:00
|
|
|
double_urldecode(url), err)
|
2016-09-17 22:02:50 +10:00
|
|
|
import traceback
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.error("Traceback:\n%s", traceback.format_exc())
|
2016-09-17 19:24:12 +10:00
|
|
|
break
|
2016-09-17 22:02:50 +10:00
|
|
|
# We did not even get a timeout
|
|
|
|
break
|
|
|
|
queue.task_done()
|
2018-05-18 23:59:26 +10:00
|
|
|
# Update the caching state in the PKC settings.
|
|
|
|
counter += 1
|
2018-05-30 15:53:30 +10:00
|
|
|
if (counter > 20 and not xbmc.getCondVisibility(
|
|
|
|
'Window.IsVisible(DialogAddonSettings.xml)')):
|
2018-05-18 23:59:26 +10:00
|
|
|
counter = 0
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('caching_artwork_count',
|
|
|
|
value=str(queue.qsize()))
|
2016-09-17 22:02:50 +10:00
|
|
|
# Sleep for a bit to reduce CPU strain
|
2018-05-30 15:53:30 +10:00
|
|
|
xbmc.sleep(sleep_between)
|
2017-12-09 05:43:06 +11:00
|
|
|
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
|
2016-09-17 18:58:08 +10:00
|
|
|
|
2016-09-17 19:24:12 +10:00
|
|
|
|
|
|
|
class Artwork():
|
2018-06-22 03:24:37 +10:00
|
|
|
enableTextureCache = utils.settings('enableTextureCache') == "true"
|
2016-09-17 19:24:12 +10:00
|
|
|
if enableTextureCache:
|
2017-01-21 03:21:51 +11:00
|
|
|
queue = ARTWORK_QUEUE
|
2016-03-04 00:00:48 +11:00
|
|
|
|
2018-04-29 22:12:39 +10:00
|
|
|
def cache_major_artwork(self):
|
|
|
|
"""
|
|
|
|
Takes the existing Kodi library and caches posters and fanart.
|
|
|
|
Necessary because otherwise PKC caches artwork e.g. from fanart.tv
|
|
|
|
which basically blocks Kodi from getting needed artwork fast (e.g.
|
|
|
|
while browsing the library)
|
|
|
|
"""
|
|
|
|
if not self.enableTextureCache:
|
|
|
|
return
|
|
|
|
artworks = list()
|
|
|
|
# Get all posters and fanart/background for video and music
|
|
|
|
for kind in ('video', 'music'):
|
2018-06-22 03:24:37 +10:00
|
|
|
connection = utils.kodi_sql(kind)
|
2018-04-29 22:12:39 +10:00
|
|
|
cursor = connection.cursor()
|
|
|
|
for typus in ('poster', 'fanart'):
|
|
|
|
cursor.execute('SELECT url FROM art WHERE type == ?',
|
|
|
|
(typus, ))
|
|
|
|
artworks.extend(cursor.fetchall())
|
|
|
|
connection.close()
|
|
|
|
artworks_to_cache = list()
|
2018-06-22 03:24:37 +10:00
|
|
|
connection = utils.kodi_sql('texture')
|
2018-04-29 22:12:39 +10:00
|
|
|
cursor = connection.cursor()
|
|
|
|
for url in artworks:
|
|
|
|
query = 'SELECT url FROM texture WHERE url == ? LIMIT 1'
|
|
|
|
cursor.execute(query, (url[0], ))
|
|
|
|
if not cursor.fetchone():
|
|
|
|
artworks_to_cache.append(url)
|
|
|
|
connection.close()
|
|
|
|
if not artworks_to_cache:
|
|
|
|
LOG.info('Caching of major images to Kodi texture cache done')
|
2018-05-13 22:20:39 +10:00
|
|
|
# Set to "None"
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('caching_artwork_count', value=utils.lang(30069))
|
2018-04-29 22:12:39 +10:00
|
|
|
return
|
2018-05-13 22:20:39 +10:00
|
|
|
length = len(artworks_to_cache)
|
2018-04-29 22:12:39 +10:00
|
|
|
LOG.info('Caching has not been completed - caching %s major images',
|
2018-05-13 22:20:39 +10:00
|
|
|
length)
|
2018-06-22 03:24:37 +10:00
|
|
|
utils.settings('caching_artwork_count', value=str(length))
|
2018-05-13 22:20:39 +10:00
|
|
|
# Caching %s Plex images
|
2018-06-22 03:24:37 +10:00
|
|
|
self.queue.put(ArtworkSyncMessage(utils.lang(30006) % length))
|
2018-05-13 22:20:39 +10:00
|
|
|
for i, url in enumerate(artworks_to_cache):
|
2018-04-29 22:12:39 +10:00
|
|
|
self.queue.put(url[0])
|
2018-05-13 22:20:39 +10:00
|
|
|
# Plex image caching done
|
2018-06-22 03:24:37 +10:00
|
|
|
self.queue.put(ArtworkSyncMessage(utils.lang(30007)))
|
2018-04-29 22:12:39 +10:00
|
|
|
|
2016-09-11 21:51:53 +10:00
|
|
|
def fullTextureCacheSync(self):
|
|
|
|
"""
|
|
|
|
This method will sync all Kodi artwork to textures13.db
|
|
|
|
and cache them locally. This takes diskspace!
|
|
|
|
"""
|
2018-06-22 03:24:37 +10:00
|
|
|
if not utils.dialog('yesno', "Image Texture Cache", utils.lang(39250)):
|
2016-01-16 14:07:36 +11:00
|
|
|
return
|
2016-04-26 21:53:19 +10:00
|
|
|
|
2017-12-09 05:43:06 +11:00
|
|
|
LOG.info("Doing Image Cache Sync")
|
2016-04-26 21:53:19 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
# ask to rest all existing or not
|
2018-06-22 03:24:37 +10:00
|
|
|
if utils.dialog('yesno', "Image Texture Cache", utils.lang(39251)):
|
2017-12-09 05:43:06 +11:00
|
|
|
LOG.info("Resetting all cache data first")
|
2016-01-16 14:07:36 +11:00
|
|
|
# Remove all existing textures first
|
2018-06-24 02:25:18 +10:00
|
|
|
path = path_ops.translate_path('special://thumbnails/')
|
|
|
|
if path_ops.exists(path):
|
|
|
|
path_ops.rmtree(path, ignore_errors=True)
|
2018-03-04 23:39:18 +11:00
|
|
|
self.restore_cache_directories()
|
2016-04-26 21:53:19 +10:00
|
|
|
|
2016-01-16 14:07:36 +11:00
|
|
|
# remove all existing data from texture DB
|
2018-06-22 03:24:37 +10:00
|
|
|
connection = utils.kodi_sql('texture')
|
2016-08-30 02:44:27 +10:00
|
|
|
cursor = connection.cursor()
|
2017-05-04 04:30:33 +10:00
|
|
|
query = 'SELECT tbl_name FROM sqlite_master WHERE type=?'
|
|
|
|
cursor.execute(query, ('table', ))
|
2016-08-30 02:44:27 +10:00
|
|
|
rows = cursor.fetchall()
|
2016-01-16 14:07:36 +11:00
|
|
|
for row in rows:
|
|
|
|
tableName = row[0]
|
2016-08-30 02:44:27 +10:00
|
|
|
if tableName != "version":
|
2017-05-12 21:25:46 +10:00
|
|
|
cursor.execute("DELETE FROM %s" % tableName)
|
2016-08-30 02:44:27 +10:00
|
|
|
connection.commit()
|
2016-09-11 21:51:53 +10:00
|
|
|
connection.close()
|
2016-01-16 14:07:36 +11:00
|
|
|
|
2015-12-25 06:51:47 +11:00
|
|
|
# Cache all entries in video DB
|
2018-06-22 03:24:37 +10:00
|
|
|
connection = utils.kodi_sql('video')
|
2015-12-25 06:51:47 +11:00
|
|
|
cursor = connection.cursor()
|
2016-09-11 21:51:53 +10:00
|
|
|
# dont include actors
|
2017-05-04 04:30:33 +10:00
|
|
|
query = "SELECT url FROM art WHERE media_type != ?"
|
|
|
|
cursor.execute(query, ('actor', ))
|
2015-12-25 06:51:47 +11:00
|
|
|
result = cursor.fetchall()
|
2016-01-16 14:07:36 +11:00
|
|
|
total = len(result)
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.info("Image cache sync about to process %s video images", total)
|
2016-09-11 21:51:53 +10:00
|
|
|
connection.close()
|
2016-08-30 02:44:27 +10:00
|
|
|
|
2015-12-25 06:51:47 +11:00
|
|
|
for url in result:
|
2018-03-04 23:39:18 +11:00
|
|
|
self.cache_texture(url[0])
|
2015-12-25 06:51:47 +11:00
|
|
|
# Cache all entries in music DB
|
2018-06-22 03:24:37 +10:00
|
|
|
connection = utils.kodi_sql('music')
|
2015-12-25 06:51:47 +11:00
|
|
|
cursor = connection.cursor()
|
|
|
|
cursor.execute("SELECT url FROM art")
|
|
|
|
result = cursor.fetchall()
|
2016-01-16 14:07:36 +11:00
|
|
|
total = len(result)
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.info("Image cache sync about to process %s music images", total)
|
2016-09-11 21:51:53 +10:00
|
|
|
connection.close()
|
2015-12-25 06:51:47 +11:00
|
|
|
for url in result:
|
2018-03-04 23:39:18 +11:00
|
|
|
self.cache_texture(url[0])
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-03-04 23:39:18 +11:00
|
|
|
def cache_texture(self, url):
|
|
|
|
'''
|
2018-04-29 22:12:39 +10:00
|
|
|
Cache a single image url to the texture cache. url: unicode
|
2018-03-04 23:39:18 +11:00
|
|
|
'''
|
2015-12-25 06:51:47 +11:00
|
|
|
if url and self.enableTextureCache:
|
2018-04-29 22:12:39 +10:00
|
|
|
self.queue.put(url)
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-03-04 23:39:18 +11:00
|
|
|
def modify_artwork(self, artworks, kodi_id, kodi_type, cursor):
|
|
|
|
"""
|
|
|
|
Pass in an artworks dict (see PlexAPI) to set an items artwork.
|
|
|
|
"""
|
|
|
|
for kodi_art, url in artworks.iteritems():
|
|
|
|
self.modify_art(url, kodi_id, kodi_type, kodi_art, cursor)
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-03-04 23:39:18 +11:00
|
|
|
def modify_art(self, url, kodi_id, kodi_type, kodi_art, cursor):
|
|
|
|
"""
|
|
|
|
Adds or modifies the artwork of kind kodi_art (e.g. 'poster') in the
|
|
|
|
Kodi art table for item kodi_id/kodi_type. Will also cache everything
|
|
|
|
except actor portraits.
|
|
|
|
"""
|
|
|
|
query = '''
|
|
|
|
SELECT url FROM art
|
|
|
|
WHERE media_id = ? AND media_type = ? AND type = ?
|
|
|
|
LIMIT 1
|
|
|
|
'''
|
|
|
|
cursor.execute(query, (kodi_id, kodi_type, kodi_art,))
|
2016-09-11 21:51:53 +10:00
|
|
|
try:
|
|
|
|
# Update the artwork
|
2018-03-04 23:39:18 +11:00
|
|
|
old_url = cursor.fetchone()[0]
|
2016-09-11 21:51:53 +10:00
|
|
|
except TypeError:
|
|
|
|
# Add the artwork
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.debug('Adding Art Link for %s kodi_id %s, kodi_type %s: %s',
|
|
|
|
kodi_art, kodi_id, kodi_type, url)
|
|
|
|
query = '''
|
2016-09-11 21:51:53 +10:00
|
|
|
INSERT INTO art(media_id, media_type, type, url)
|
|
|
|
VALUES (?, ?, ?, ?)
|
2018-03-04 23:39:18 +11:00
|
|
|
'''
|
|
|
|
cursor.execute(query, (kodi_id, kodi_type, kodi_art, url))
|
2016-09-11 21:51:53 +10:00
|
|
|
else:
|
2018-03-04 23:39:18 +11:00
|
|
|
if url == old_url:
|
2016-09-11 21:51:53 +10:00
|
|
|
# Only cache artwork if it changed
|
|
|
|
return
|
2018-03-04 23:39:18 +11:00
|
|
|
self.delete_cached_artwork(old_url)
|
|
|
|
LOG.debug("Updating Art url for %s kodi_id %s, kodi_type %s to %s",
|
|
|
|
kodi_art, kodi_id, kodi_type, url)
|
|
|
|
query = '''
|
|
|
|
UPDATE art SET url = ?
|
|
|
|
WHERE media_id = ? AND media_type = ? AND type = ?
|
|
|
|
'''
|
|
|
|
cursor.execute(query, (url, kodi_id, kodi_type, kodi_art))
|
2016-09-11 21:51:53 +10:00
|
|
|
# Cache fanart and poster in Kodi texture cache
|
2018-03-04 23:39:18 +11:00
|
|
|
if kodi_type != 'actor':
|
|
|
|
self.cache_texture(url)
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-03-04 23:39:18 +11:00
|
|
|
def delete_artwork(self, kodiId, mediaType, cursor):
|
2018-02-26 04:06:33 +11:00
|
|
|
query = 'SELECT url FROM art WHERE media_id = ? AND media_type = ?'
|
2016-09-11 23:49:50 +10:00
|
|
|
cursor.execute(query, (kodiId, mediaType,))
|
2018-02-26 04:06:33 +11:00
|
|
|
for row in cursor.fetchall():
|
2018-03-04 23:39:18 +11:00
|
|
|
self.delete_cached_artwork(row[0])
|
2015-12-25 06:51:47 +11:00
|
|
|
|
2018-03-04 23:39:18 +11:00
|
|
|
@staticmethod
|
|
|
|
def delete_cached_artwork(url):
|
|
|
|
"""
|
|
|
|
Deleted the cached artwork with path url (if it exists)
|
|
|
|
"""
|
2018-06-22 03:24:37 +10:00
|
|
|
connection = utils.kodi_sql('texture')
|
2015-12-25 06:51:47 +11:00
|
|
|
cursor = connection.cursor()
|
|
|
|
try:
|
2018-03-04 23:39:18 +11:00
|
|
|
cursor.execute("SELECT cachedurl FROM texture WHERE url=? LIMIT 1",
|
2016-09-11 21:51:53 +10:00
|
|
|
(url,))
|
2015-12-25 06:51:47 +11:00
|
|
|
cachedurl = cursor.fetchone()[0]
|
|
|
|
except TypeError:
|
2018-03-01 03:42:21 +11:00
|
|
|
# Could not find cached url
|
|
|
|
pass
|
2016-09-11 21:51:53 +10:00
|
|
|
else:
|
|
|
|
# Delete thumbnail as well as the entry
|
2018-06-24 02:25:18 +10:00
|
|
|
path = path_ops.translate_path("special://thumbnails/%s"
|
|
|
|
% cachedurl)
|
2018-03-04 23:39:18 +11:00
|
|
|
LOG.debug("Deleting cached thumbnail: %s", path)
|
2018-06-24 02:25:18 +10:00
|
|
|
if path_ops.exists(path):
|
|
|
|
path_ops.rmtree(path, ignore_errors=True)
|
2016-09-17 22:02:50 +10:00
|
|
|
cursor.execute("DELETE FROM texture WHERE url = ?", (url,))
|
|
|
|
connection.commit()
|
2015-12-25 06:51:47 +11:00
|
|
|
finally:
|
2016-09-11 21:51:53 +10:00
|
|
|
connection.close()
|
2018-01-24 07:39:55 +11:00
|
|
|
|
2018-01-29 03:36:36 +11:00
|
|
|
@staticmethod
|
2018-03-04 23:39:18 +11:00
|
|
|
def restore_cache_directories():
|
2018-01-24 07:39:55 +11:00
|
|
|
LOG.info("Restoring cache directories...")
|
2018-03-04 23:39:18 +11:00
|
|
|
paths = ("", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
|
|
"a", "b", "c", "d", "e", "f",
|
|
|
|
"Video", "plex")
|
|
|
|
for path in paths:
|
2018-06-24 02:25:18 +10:00
|
|
|
new_path = path_ops.translate_path("special://thumbnails/%s" % path)
|
|
|
|
path_ops.makedirs(utils.encode_path(new_path))
|
2018-04-29 22:12:39 +10:00
|
|
|
|
|
|
|
|
|
|
|
class ArtworkSyncMessage(object):
|
|
|
|
"""
|
|
|
|
Put in artwork queue to display the message as a Kodi notification
|
|
|
|
"""
|
2018-05-16 04:46:16 +10:00
|
|
|
def __init__(self, message):
|
2018-04-29 22:12:39 +10:00
|
|
|
self.message = message
|