Merge branch 'hotfixes' into playlists
This commit is contained in:
commit
29d9a29cb7
7 changed files with 96 additions and 11 deletions
|
@ -41,6 +41,26 @@ msgctxt "#30005"
|
||||||
msgid "Username: "
|
msgid "Username: "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
# Sync notification displayed if there is still artwork to be cached to Kodi
|
||||||
|
msgctxt "#30006"
|
||||||
|
msgid "Caching %s images"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
# Sync notification displayed if syncing of major artwork is done
|
||||||
|
msgctxt "#30007"
|
||||||
|
msgid "Major image caching done"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
# PKC settings artwork: Enable notifications for artwork image sync
|
||||||
|
msgctxt "#30008"
|
||||||
|
msgid "Enable notifications for image caching"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
# PKC settings artwork: Enable image caching during Kodi playback
|
||||||
|
msgctxt "#30009"
|
||||||
|
msgid "Enable image caching during Kodi playback (restart Kodi!)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
# Button text
|
# Button text
|
||||||
msgctxt "#30012"
|
msgctxt "#30012"
|
||||||
msgid "OK"
|
msgid "OK"
|
||||||
|
|
|
@ -22,6 +22,10 @@ LOG = getLogger("PLEX." + __name__)
|
||||||
# Disable annoying requests warnings
|
# Disable annoying requests warnings
|
||||||
requests.packages.urllib3.disable_warnings()
|
requests.packages.urllib3.disable_warnings()
|
||||||
ARTWORK_QUEUE = Queue()
|
ARTWORK_QUEUE = Queue()
|
||||||
|
IMAGE_CACHING_SUSPENDS = ['SUSPEND_LIBRARY_THREAD', 'DB_SCAN', 'STOP_SYNC']
|
||||||
|
if not settings('imageSyncDuringPlayback') == 'true':
|
||||||
|
IMAGE_CACHING_SUSPENDS.append('SUSPEND_SYNC')
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,11 +37,9 @@ def double_urldecode(text):
|
||||||
return unquote(unquote(text))
|
return unquote(unquote(text))
|
||||||
|
|
||||||
|
|
||||||
@thread_methods(add_suspends=['SUSPEND_LIBRARY_THREAD',
|
@thread_methods(add_suspends=IMAGE_CACHING_SUSPENDS)
|
||||||
'DB_SCAN',
|
|
||||||
'STOP_SYNC'])
|
|
||||||
class Image_Cache_Thread(Thread):
|
class Image_Cache_Thread(Thread):
|
||||||
sleep_between = 50
|
sleep_between = 200
|
||||||
# Potentially issues with limited number of threads
|
# Potentially issues with limited number of threads
|
||||||
# Hence let Kodi wait till download is successful
|
# Hence let Kodi wait till download is successful
|
||||||
timeout = (35.1, 35.1)
|
timeout = (35.1, 35.1)
|
||||||
|
@ -47,6 +49,7 @@ class Image_Cache_Thread(Thread):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
LOG.info("---===### Starting Image_Cache_Thread ###===---")
|
||||||
stopped = self.stopped
|
stopped = self.stopped
|
||||||
suspended = self.suspended
|
suspended = self.suspended
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
|
@ -65,6 +68,16 @@ class Image_Cache_Thread(Thread):
|
||||||
except Empty:
|
except Empty:
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
continue
|
continue
|
||||||
|
if isinstance(url, ArtworkSyncMessage):
|
||||||
|
if state.IMAGE_SYNC_NOTIFICATIONS:
|
||||||
|
dialog('notification',
|
||||||
|
heading=lang(29999),
|
||||||
|
message=url.message,
|
||||||
|
icon='{plex}',
|
||||||
|
sound=False)
|
||||||
|
queue.task_done()
|
||||||
|
continue
|
||||||
|
url = double_urlencode(try_encode(url))
|
||||||
sleeptime = 0
|
sleeptime = 0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -116,6 +129,44 @@ class Artwork():
|
||||||
if enableTextureCache:
|
if enableTextureCache:
|
||||||
queue = ARTWORK_QUEUE
|
queue = ARTWORK_QUEUE
|
||||||
|
|
||||||
|
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'):
|
||||||
|
connection = kodi_sql(kind)
|
||||||
|
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()
|
||||||
|
connection = kodi_sql('texture')
|
||||||
|
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')
|
||||||
|
return
|
||||||
|
LOG.info('Caching has not been completed - caching %s major images',
|
||||||
|
len(artworks_to_cache))
|
||||||
|
self.queue.put(ArtworkSyncMessage(lang(30006) % len(artworks_to_cache)))
|
||||||
|
for url in artworks_to_cache:
|
||||||
|
self.queue.put(url[0])
|
||||||
|
self.queue.put(ArtworkSyncMessage(lang(30007)))
|
||||||
|
|
||||||
def fullTextureCacheSync(self):
|
def fullTextureCacheSync(self):
|
||||||
"""
|
"""
|
||||||
This method will sync all Kodi artwork to textures13.db
|
This method will sync all Kodi artwork to textures13.db
|
||||||
|
@ -174,10 +225,10 @@ class Artwork():
|
||||||
|
|
||||||
def cache_texture(self, url):
|
def cache_texture(self, url):
|
||||||
'''
|
'''
|
||||||
Cache a single image url to the texture cache
|
Cache a single image url to the texture cache. url: unicode
|
||||||
'''
|
'''
|
||||||
if url and self.enableTextureCache:
|
if url and self.enableTextureCache:
|
||||||
self.queue.put(double_urlencode(try_encode(url)))
|
self.queue.put(url)
|
||||||
|
|
||||||
def modify_artwork(self, artworks, kodi_id, kodi_type, cursor):
|
def modify_artwork(self, artworks, kodi_id, kodi_type, cursor):
|
||||||
"""
|
"""
|
||||||
|
@ -266,3 +317,11 @@ class Artwork():
|
||||||
for path in paths:
|
for path in paths:
|
||||||
makedirs(try_decode(translatePath("special://thumbnails/%s"
|
makedirs(try_decode(translatePath("special://thumbnails/%s"
|
||||||
% path)))
|
% path)))
|
||||||
|
|
||||||
|
|
||||||
|
class ArtworkSyncMessage(object):
|
||||||
|
"""
|
||||||
|
Put in artwork queue to display the message as a Kodi notification
|
||||||
|
"""
|
||||||
|
def __init__(self, message):
|
||||||
|
self.message = message
|
||||||
|
|
|
@ -369,7 +369,7 @@ def getRecentEpisodes(viewid, mediatype, tagname, limit):
|
||||||
append_show_title = settings('RecentTvAppendShow') == 'true'
|
append_show_title = settings('RecentTvAppendShow') == 'true'
|
||||||
append_sxxexx = settings('RecentTvAppendSeason') == 'true'
|
append_sxxexx = settings('RecentTvAppendSeason') == 'true'
|
||||||
# First we get a list of all the TV shows - filtered by tag
|
# First we get a list of all the TV shows - filtered by tag
|
||||||
allshowsIds = set()
|
allshowsIds = list()
|
||||||
params = {
|
params = {
|
||||||
'sort': {'order': "descending", 'method': "dateadded"},
|
'sort': {'order': "descending", 'method': "dateadded"},
|
||||||
'filter': {'operator': "is", 'field': "tag", 'value': "%s" % tagname},
|
'filter': {'operator': "is", 'field': "tag", 'value': "%s" % tagname},
|
||||||
|
|
|
@ -50,7 +50,8 @@ STATE_SETTINGS = {
|
||||||
'remapSMBphotoNew': 'remapSMBphotoNew',
|
'remapSMBphotoNew': 'remapSMBphotoNew',
|
||||||
'enableMusic': 'ENABLE_MUSIC',
|
'enableMusic': 'ENABLE_MUSIC',
|
||||||
'forceReloadSkinOnPlaybackStop': 'FORCE_RELOAD_SKIN',
|
'forceReloadSkinOnPlaybackStop': 'FORCE_RELOAD_SKIN',
|
||||||
'fetch_pms_item_number': 'FETCH_PMS_ITEM_NUMBER'
|
'fetch_pms_item_number': 'FETCH_PMS_ITEM_NUMBER',
|
||||||
|
'imageSyncNotifications': 'IMAGE_SYNC_NOTIFICATIONS'
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -16,6 +16,7 @@ from downloadutils import DownloadUtils as DU
|
||||||
import itemtypes
|
import itemtypes
|
||||||
import plexdb_functions as plexdb
|
import plexdb_functions as plexdb
|
||||||
import kodidb_functions as kodidb
|
import kodidb_functions as kodidb
|
||||||
|
import artwork
|
||||||
import videonodes
|
import videonodes
|
||||||
import variables as v
|
import variables as v
|
||||||
|
|
||||||
|
@ -1463,7 +1464,6 @@ class LibrarySync(Thread):
|
||||||
elif state.RUN_LIB_SCAN == 'textures':
|
elif state.RUN_LIB_SCAN == 'textures':
|
||||||
state.DB_SCAN = True
|
state.DB_SCAN = True
|
||||||
window('plex_dbScan', value="true")
|
window('plex_dbScan', value="true")
|
||||||
import artwork
|
|
||||||
artwork.Artwork().fullTextureCacheSync()
|
artwork.Artwork().fullTextureCacheSync()
|
||||||
window('plex_dbScan', clear=True)
|
window('plex_dbScan', clear=True)
|
||||||
state.DB_SCAN = False
|
state.DB_SCAN = False
|
||||||
|
@ -1527,8 +1527,6 @@ class LibrarySync(Thread):
|
||||||
last_time_sync = utils.unix_timestamp()
|
last_time_sync = utils.unix_timestamp()
|
||||||
window('plex_dbScan', clear=True)
|
window('plex_dbScan', clear=True)
|
||||||
state.DB_SCAN = False
|
state.DB_SCAN = False
|
||||||
# Start the fanart download thread
|
|
||||||
self.fanartthread.start()
|
|
||||||
kodi_playlist_monitor = None
|
kodi_playlist_monitor = None
|
||||||
|
|
||||||
while not self.stopped():
|
while not self.stopped():
|
||||||
|
@ -1555,6 +1553,7 @@ class LibrarySync(Thread):
|
||||||
initial_sync_done = True
|
initial_sync_done = True
|
||||||
kodi_db_version_checked = True
|
kodi_db_version_checked = True
|
||||||
last_sync = utils.unix_timestamp()
|
last_sync = utils.unix_timestamp()
|
||||||
|
self.fanartthread.start()
|
||||||
else:
|
else:
|
||||||
LOG.error('Initial start-up full sync unsuccessful')
|
LOG.error('Initial start-up full sync unsuccessful')
|
||||||
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
||||||
|
@ -1599,6 +1598,8 @@ class LibrarySync(Thread):
|
||||||
if settings('FanartTV') == 'true':
|
if settings('FanartTV') == 'true':
|
||||||
self.sync_fanart()
|
self.sync_fanart()
|
||||||
LOG.info('Done initial sync on Kodi startup')
|
LOG.info('Done initial sync on Kodi startup')
|
||||||
|
artwork.Artwork().cache_major_artwork()
|
||||||
|
self.fanartthread.start()
|
||||||
else:
|
else:
|
||||||
LOG.info('Startup sync has not yet been successful')
|
LOG.info('Startup sync has not yet been successful')
|
||||||
window('plex_dbScan', clear=True)
|
window('plex_dbScan', clear=True)
|
||||||
|
|
|
@ -39,6 +39,8 @@ FORCE_RELOAD_SKIN = True
|
||||||
# Stemming from the PKC settings.xml
|
# Stemming from the PKC settings.xml
|
||||||
# Shall we show Kodi dialogs when synching?
|
# Shall we show Kodi dialogs when synching?
|
||||||
SYNC_DIALOG = True
|
SYNC_DIALOG = True
|
||||||
|
# Shall Kodi show dialogs for syncing/caching images? (e.g. images left to sync)
|
||||||
|
IMAGE_SYNC_NOTIFICATIONS = True
|
||||||
# Is synching of Plex music enabled?
|
# Is synching of Plex music enabled?
|
||||||
ENABLE_MUSIC = True
|
ENABLE_MUSIC = True
|
||||||
# How often shall we sync?
|
# How often shall we sync?
|
||||||
|
|
|
@ -125,6 +125,8 @@
|
||||||
<setting id="enableTextureCache" label="30512" type="bool" default="true" /> <!-- Force Artwork Caching -->
|
<setting id="enableTextureCache" label="30512" type="bool" default="true" /> <!-- Force Artwork Caching -->
|
||||||
<setting id="FanartTV" label="30539" type="bool" default="false" /><!-- Download additional art from FanArtTV -->
|
<setting id="FanartTV" label="30539" type="bool" default="false" /><!-- Download additional art from FanArtTV -->
|
||||||
<setting label="39222" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=fanart)" option="close" visible="eq(-1,true)" subsetting="true" /> <!-- Look for missing fanart on FanartTV now -->
|
<setting label="39222" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=fanart)" option="close" visible="eq(-1,true)" subsetting="true" /> <!-- Look for missing fanart on FanartTV now -->
|
||||||
|
<setting id="imageSyncNotifications" label="30008" type="bool" default="true" /><!-- Enable notifications for image caching -->
|
||||||
|
<setting id="imageSyncDuringPlayback" label="30009" type="bool" default="true" /><!-- Enable image caching during Kodi playback (restart Kodi!) -->
|
||||||
<setting label="39020" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=texturecache)" option="close" /> <!-- Cache all images to Kodi texture cache now -->
|
<setting label="39020" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=texturecache)" option="close" /> <!-- Cache all images to Kodi texture cache now -->
|
||||||
</category>
|
</category>
|
||||||
<!--
|
<!--
|
||||||
|
|
Loading…
Reference in a new issue