diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po
index 75c05b36..73ae504c 100644
--- a/resources/language/resource.language.en_gb/strings.po
+++ b/resources/language/resource.language.en_gb/strings.po
@@ -429,6 +429,11 @@ msgctxt "#30501"
msgid "Client SSL certificate"
msgstr ""
+# PKC Settings - Artwork
+msgctxt "#30502"
+msgid "Sync Plex artwork from the PMS (recommended)"
+msgstr ""
+
# PKC Settings - Connection
msgctxt "#30505"
msgid "[COLOR yellow]Reset login attempts[/COLOR]"
diff --git a/resources/lib/app/libsync.py b/resources/lib/app/libsync.py
index 0ceb68e3..a994dadc 100644
--- a/resources/lib/app/libsync.py
+++ b/resources/lib/app/libsync.py
@@ -38,6 +38,8 @@ class Sync(object):
self.direct_paths = utils.settings('useDirectPaths') == '1'
# Is synching of Plex music enabled?
self.enable_music = utils.settings('enableMusic') == 'true'
+ # Do we sync artwork from the PMS to Kodi?
+ self.artwork = utils.settings('usePlexArtwork') == 'true'
# Path remapping mechanism (e.g. smb paths)
# Do we replace \\myserver\path to smb://myserver/path?
self.replace_smb_path = utils.settings('replaceSMB') == 'true'
diff --git a/resources/lib/itemtypes/common.py b/resources/lib/itemtypes/common.py
index e05b3479..83e4991d 100644
--- a/resources/lib/itemtypes/common.py
+++ b/resources/lib/itemtypes/common.py
@@ -6,7 +6,7 @@ from ntpath import dirname
from ..plex_db import PlexDB, PLEXDB_LOCK
from ..kodi_db import KodiVideoDB, KODIDB_LOCK
-from .. import utils, timing
+from .. import utils, timing, app
LOG = getLogger('PLEX.itemtypes.common')
@@ -61,8 +61,12 @@ class ItemBase(object):
self.plexcursor = self.plexconn.cursor()
self.kodiconn = utils.kodi_sql('video')
self.kodicursor = self.kodiconn.cursor()
- self.artconn = utils.kodi_sql('texture')
- self.artcursor = self.artconn.cursor()
+ if app.SYNC.artwork:
+ self.artconn = utils.kodi_sql('texture')
+ self.artcursor = self.artconn.cursor()
+ else:
+ self.artconn = None
+ self.artcursor = None
self.plexdb = PlexDB(cursor=self.plexcursor)
self.kodidb = KodiVideoDB(texture_db=True,
cursor=self.kodicursor,
@@ -78,13 +82,15 @@ class ItemBase(object):
# re-raise any exception
return False
self.plexconn.commit()
- self.artconn.commit()
self.kodiconn.commit()
+ if self.artconn:
+ self.artconn.commit()
return self
finally:
self.plexconn.close()
self.kodiconn.close()
- self.artconn.close()
+ if self.artconn:
+ self.artconn.close()
if self.lock:
PLEXDB_LOCK.release()
KODIDB_LOCK.release()
@@ -92,10 +98,11 @@ class ItemBase(object):
def commit(self):
self.plexconn.commit()
self.plexconn.execute('BEGIN')
- self.artconn.commit()
- self.artconn.execute('BEGIN')
self.kodiconn.commit()
self.kodiconn.execute('BEGIN')
+ if self.artconn:
+ self.artconn.commit()
+ self.artconn.execute('BEGIN')
def set_fanart(self, artworks, kodi_id, kodi_type):
"""
diff --git a/resources/lib/itemtypes/movies.py b/resources/lib/itemtypes/movies.py
index 17f80998..6d00c839 100644
--- a/resources/lib/itemtypes/movies.py
+++ b/resources/lib/itemtypes/movies.py
@@ -110,9 +110,10 @@ class Movie(ItemBase):
self.kodidb.modify_people(kodi_id,
v.KODI_TYPE_MOVIE,
api.people_list())
- self.kodidb.modify_artwork(api.artwork(),
- kodi_id,
- v.KODI_TYPE_MOVIE)
+ if app.SYNC.artwork:
+ self.kodidb.modify_artwork(api.artwork(),
+ kodi_id,
+ v.KODI_TYPE_MOVIE)
else:
LOG.info("ADD movie plex_id: %s - %s", plex_id, title)
file_id = self.kodidb.add_file(filename,
@@ -137,9 +138,10 @@ class Movie(ItemBase):
self.kodidb.add_people(kodi_id,
v.KODI_TYPE_MOVIE,
api.people_list())
- self.kodidb.add_artwork(api.artwork(),
- kodi_id,
- v.KODI_TYPE_MOVIE)
+ if app.SYNC.artwork:
+ self.kodidb.add_artwork(api.artwork(),
+ kodi_id,
+ v.KODI_TYPE_MOVIE)
# Update Kodi's main entry
self.kodidb.add_movie(kodi_id,
@@ -179,6 +181,9 @@ class Movie(ItemBase):
# Add any sets from Plex collection tags
kodi_set_id = self.kodidb.create_collection(set_name)
self.kodidb.assign_collection(kodi_set_id, kodi_id)
+ if not app.SYNC.artwork:
+ # Rest below is to get collection artwork
+ continue
if children is None:
# e.g. when added via websocket
LOG.debug('Costly looking up Plex collection %s: %s',
diff --git a/resources/lib/itemtypes/music.py b/resources/lib/itemtypes/music.py
index a8d2d73e..b7412632 100644
--- a/resources/lib/itemtypes/music.py
+++ b/resources/lib/itemtypes/music.py
@@ -24,8 +24,9 @@ class MusicMixin(object):
self.plexcursor = self.plexconn.cursor()
self.kodiconn = utils.kodi_sql('music')
self.kodicursor = self.kodiconn.cursor()
- self.artconn = utils.kodi_sql('texture')
- self.artcursor = self.artconn.cursor()
+ if app.SYNC.artwork:
+ self.artconn = utils.kodi_sql('texture')
+ self.artcursor = self.artconn.cursor()
self.plexdb = PlexDB(self.plexcursor)
self.kodidb = KodiMusicDB(texture_db=True,
cursor=self.kodicursor,
@@ -170,16 +171,18 @@ class Artist(MusicMixin, ItemBase):
# Not yet implemented by Plex
musicBrainzId = None
- # Associate artwork
- artworks = api.artwork()
- if 'poster' in artworks:
- thumb = "%s" % artworks['poster']
+ if app.SYNC.artwork:
+ artworks = api.artwork()
+ if 'poster' in artworks:
+ thumb = "%s" % artworks['poster']
+ else:
+ thumb = None
+ if 'fanart' in artworks:
+ fanart = "%s" % artworks['fanart']
+ else:
+ fanart = None
else:
- thumb = None
- if 'fanart' in artworks:
- fanart = "%s" % artworks['fanart']
- else:
- fanart = None
+ thumb, fanart = None, None
# UPDATE THE ARTIST #####
if update_item:
@@ -198,10 +201,10 @@ class Artist(MusicMixin, ItemBase):
fanart,
timing.unix_date_to_kodi(self.last_sync),
kodi_id)
- # Update artwork
- self.kodidb.modify_artwork(artworks,
- kodi_id,
- v.KODI_TYPE_ARTIST)
+ if app.SYNC.artwork:
+ self.kodidb.modify_artwork(artworks,
+ kodi_id,
+ v.KODI_TYPE_ARTIST)
self.plexdb.add_artist(plex_id,
api.checksum(),
section_id,
@@ -265,10 +268,12 @@ class Album(MusicMixin, ItemBase):
musicBrainzId = None
genres = api.genre_list()
genre = api.list_to_string(genres)
- # Associate artwork
- artworks = api.artwork()
- if 'poster' in artworks:
- thumb = "%s" % artworks['poster']
+ if app.SYNC.artwork:
+ artworks = api.artwork()
+ if 'poster' in artworks:
+ thumb = "%s" % artworks['poster']
+ else:
+ thumb = None
else:
thumb = None
@@ -341,9 +346,10 @@ class Album(MusicMixin, ItemBase):
self.kodidb.add_music_genres(kodi_id,
genres,
v.KODI_TYPE_ALBUM)
- self.kodidb.modify_artwork(artworks,
- kodi_id,
- v.KODI_TYPE_ALBUM)
+ if app.SYNC.artwork:
+ self.kodidb.modify_artwork(artworks,
+ kodi_id,
+ v.KODI_TYPE_ALBUM)
self.plexdb.add_album(plex_id,
api.checksum(),
section_id,
@@ -630,15 +636,16 @@ class Song(MusicMixin, ItemBase):
# Add genres
if genres:
self.kodidb.add_music_genres(kodi_id, genres, v.KODI_TYPE_SONG)
- artworks = api.artwork()
- self.kodidb.modify_artwork(artworks,
- kodi_id,
- v.KODI_TYPE_SONG)
- if xml.get('parentKey') is None:
- # Update album artwork
+ if app.SYNC.artwork:
+ artworks = api.artwork()
self.kodidb.modify_artwork(artworks,
- parent_id,
- v.KODI_TYPE_ALBUM)
+ kodi_id,
+ v.KODI_TYPE_SONG)
+ if xml.get('parentKey') is None:
+ # Update album artwork
+ self.kodidb.modify_artwork(artworks,
+ parent_id,
+ v.KODI_TYPE_ALBUM)
self.plexdb.add_song(plex_id,
api.checksum(),
section_id,
diff --git a/resources/lib/itemtypes/tvshows.py b/resources/lib/itemtypes/tvshows.py
index f4fa90a1..1bfcf60f 100644
--- a/resources/lib/itemtypes/tvshows.py
+++ b/resources/lib/itemtypes/tvshows.py
@@ -204,9 +204,10 @@ class Show(TvShowMixin, ItemBase):
self.kodidb.modify_people(kodi_id,
v.KODI_TYPE_SHOW,
api.people_list())
- self.kodidb.modify_artwork(api.artwork(),
- kodi_id,
- v.KODI_TYPE_SHOW)
+ if app.SYNC.artwork:
+ self.kodidb.modify_artwork(api.artwork(),
+ kodi_id,
+ v.KODI_TYPE_SHOW)
# Update the tvshow entry
self.kodidb.update_show(api.title(),
api.plot(),
@@ -243,9 +244,10 @@ class Show(TvShowMixin, ItemBase):
self.kodidb.add_people(kodi_id,
v.KODI_TYPE_SHOW,
api.people_list())
- self.kodidb.add_artwork(api.artwork(),
- kodi_id,
- v.KODI_TYPE_SHOW)
+ if app.SYNC.artwork:
+ self.kodidb.add_artwork(api.artwork(),
+ kodi_id,
+ v.KODI_TYPE_SHOW)
# Create the tvshow entry
self.kodidb.add_show(kodi_id,
api.title(),
@@ -310,25 +312,28 @@ class Season(TvShowMixin, ItemBase):
LOG.error('Still could not find parent tv show %s', show_id)
return
parent_id = show['kodi_id']
- parent_artwork = api.artwork(kodi_id=parent_id,
- kodi_type=v.KODI_TYPE_SHOW)
- artwork = api.artwork()
- # Remove all artwork that is identical for the season's show
- for key in parent_artwork:
- if key in artwork and artwork[key] == parent_artwork[key]:
- del artwork[key]
+ if app.SYNC.artwork:
+ parent_artwork = api.artwork(kodi_id=parent_id,
+ kodi_type=v.KODI_TYPE_SHOW)
+ artwork = api.artwork()
+ # Remove all artwork that is identical for the season's show
+ for key in parent_artwork:
+ if key in artwork and artwork[key] == parent_artwork[key]:
+ del artwork[key]
if update_item:
LOG.info('UPDATE season plex_id %s - %s', plex_id, api.title())
kodi_id = season['kodi_id']
- self.kodidb.modify_artwork(artwork,
- kodi_id,
- v.KODI_TYPE_SEASON)
+ if app.SYNC.artwork:
+ self.kodidb.modify_artwork(artwork,
+ kodi_id,
+ v.KODI_TYPE_SEASON)
else:
LOG.info('ADD season plex_id %s - %s', plex_id, api.title())
kodi_id = self.kodidb.add_season(parent_id, api.season_number())
- self.kodidb.add_artwork(artwork,
- kodi_id,
- v.KODI_TYPE_SEASON)
+ if app.SYNC.artwork:
+ self.kodidb.add_artwork(artwork,
+ kodi_id,
+ v.KODI_TYPE_SEASON)
self.plexdb.add_season(plex_id=plex_id,
checksum=api.checksum(),
section_id=section_id,
@@ -475,9 +480,10 @@ class Episode(TvShowMixin, ItemBase):
self.kodidb.modify_people(kodi_id,
v.KODI_TYPE_EPISODE,
api.people_list())
- self.kodidb.modify_artwork(api.artwork(),
- kodi_id,
- v.KODI_TYPE_EPISODE)
+ if app.SYNC.artwork:
+ self.kodidb.modify_artwork(api.artwork(),
+ kodi_id,
+ v.KODI_TYPE_EPISODE)
self.kodidb.update_episode(api.title(),
api.plot(),
ratingid,
@@ -537,9 +543,10 @@ class Episode(TvShowMixin, ItemBase):
self.kodidb.add_people(kodi_id,
v.KODI_TYPE_EPISODE,
api.people_list())
- self.kodidb.add_artwork(api.artwork(),
- kodi_id,
- v.KODI_TYPE_EPISODE)
+ if app.SYNC.artwork:
+ self.kodidb.add_artwork(api.artwork(),
+ kodi_id,
+ v.KODI_TYPE_EPISODE)
self.kodidb.add_episode(kodi_id,
kodi_fileid,
api.title(),
diff --git a/resources/lib/kodi_db/music.py b/resources/lib/kodi_db/music.py
index 7dbedf2c..f4f8b288 100644
--- a/resources/lib/kodi_db/music.py
+++ b/resources/lib/kodi_db/music.py
@@ -4,7 +4,7 @@ from __future__ import absolute_import, division, unicode_literals
from logging import getLogger
from . import common
-from .. import variables as v
+from .. import variables as v, app
LOG = getLogger('PLEX.kodi_db.music')
@@ -145,81 +145,159 @@ class KodiMusicDB(common.KodiDBBase):
"""
strReleaseType: 'album' or 'single'
"""
- self.cursor.execute('''
- INSERT INTO album(
- idAlbum,
- strAlbum,
- strMusicBrainzAlbumID,
- strArtists,
- strGenres,
- iYear,
- bCompilation,
- strReview,
- strImage,
- strLabel,
- iUserrating,
- lastScraped,
- strReleaseType)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- ''', (args))
+ if app.SYNC.artwork:
+ self.cursor.execute('''
+ INSERT INTO album(
+ idAlbum,
+ strAlbum,
+ strMusicBrainzAlbumID,
+ strArtists,
+ strGenres,
+ iYear,
+ bCompilation,
+ strReview,
+ strImage,
+ strLabel,
+ iUserrating,
+ lastScraped,
+ strReleaseType)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ''', (args))
+ else:
+ args = list(args)
+ del args[8]
+ self.cursor.execute('''
+ INSERT INTO album(
+ idAlbum,
+ strAlbum,
+ strMusicBrainzAlbumID,
+ strArtists,
+ strGenres,
+ iYear,
+ bCompilation,
+ strReview,
+ strLabel,
+ iUserrating,
+ lastScraped,
+ strReleaseType)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ''', (args))
def update_album_17(self, *args):
- self.cursor.execute('''
- UPDATE album
- SET strAlbum = ?,
- strMusicBrainzAlbumID = ?,
- strArtists = ?,
- strGenres = ?,
- iYear = ?,
- bCompilation = ?,
- strReview = ?,
- strImage = ?,
- strLabel = ?,
- iUserrating = ?,
- lastScraped = ?,
- strReleaseType = ?
- WHERE idAlbum = ?
- ''', (args))
+ if app.SYNC.artwork:
+ self.cursor.execute('''
+ UPDATE album
+ SET strAlbum = ?,
+ strMusicBrainzAlbumID = ?,
+ strArtists = ?,
+ strGenres = ?,
+ iYear = ?,
+ bCompilation = ?,
+ strReview = ?,
+ strImage = ?,
+ strLabel = ?,
+ iUserrating = ?,
+ lastScraped = ?,
+ strReleaseType = ?
+ WHERE idAlbum = ?
+ ''', (args))
+ else:
+ args = list(args)
+ del args[7]
+ self.cursor.execute('''
+ UPDATE album
+ SET strAlbum = ?,
+ strMusicBrainzAlbumID = ?,
+ strArtists = ?,
+ strGenres = ?,
+ iYear = ?,
+ bCompilation = ?,
+ strReview = ?,
+ strLabel = ?,
+ iUserrating = ?,
+ lastScraped = ?,
+ strReleaseType = ?
+ WHERE idAlbum = ?
+ ''', (args))
def add_album(self, *args):
"""
strReleaseType: 'album' or 'single'
"""
- self.cursor.execute('''
- INSERT INTO album(
- idAlbum,
- strAlbum,
- strMusicBrainzAlbumID,
- strArtistDisp,
- strGenres,
- iYear,
- bCompilation,
- strReview,
- strImage,
- strLabel,
- iUserrating,
- lastScraped,
- strReleaseType)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- ''', (args))
+ if app.SYNC.artwork:
+ self.cursor.execute('''
+ INSERT INTO album(
+ idAlbum,
+ strAlbum,
+ strMusicBrainzAlbumID,
+ strArtistDisp,
+ strGenres,
+ iYear,
+ bCompilation,
+ strReview,
+ strImage,
+ strLabel,
+ iUserrating,
+ lastScraped,
+ strReleaseType)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ''', (args))
+ else:
+ args = list(args)
+ del args[8]
+ self.cursor.execute('''
+ INSERT INTO album(
+ idAlbum,
+ strAlbum,
+ strMusicBrainzAlbumID,
+ strArtistDisp,
+ strGenres,
+ iYear,
+ bCompilation,
+ strReview,
+ strLabel,
+ iUserrating,
+ lastScraped,
+ strReleaseType)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ''', (args))
def update_album(self, *args):
- self.cursor.execute('''
- UPDATE album
- SET strAlbum = ?,
- strMusicBrainzAlbumID = ?,
- strArtistDisp = ?,
- strGenres = ?,
- iYear = ?,
- bCompilation = ?,
- strReview = ?,
- strImage = ?,
- strLabel = ?,
- iUserrating = ?,
- lastScraped = ?,
- strReleaseType = ?
- WHERE idAlbum = ?
- ''', (args))
+ if app.SYNC.artwork:
+ self.cursor.execute('''
+ UPDATE album
+ SET strAlbum = ?,
+ strMusicBrainzAlbumID = ?,
+ strArtistDisp = ?,
+ strGenres = ?,
+ iYear = ?,
+ bCompilation = ?,
+ strReview = ?,
+ strImage = ?,
+ strLabel = ?,
+ iUserrating = ?,
+ lastScraped = ?,
+ strReleaseType = ?
+ WHERE idAlbum = ?
+ ''', (args))
+ else:
+ args = list(args)
+ del args[7]
+ self.cursor.execute('''
+ UPDATE album
+ SET strAlbum = ?,
+ strMusicBrainzAlbumID = ?,
+ strArtistDisp = ?,
+ strGenres = ?,
+ iYear = ?,
+ bCompilation = ?,
+ strReview = ?,
+ strLabel = ?,
+ iUserrating = ?,
+ lastScraped = ?,
+ strReleaseType = ?
+ WHERE idAlbum = ?
+ ''', (args))
def add_albumartist(self, artist_id, kodi_id, artistname):
self.cursor.execute('''
@@ -424,15 +502,26 @@ class KodiMusicDB(common.KodiDBBase):
return artistid
def update_artist(self, *args):
- self.cursor.execute('''
- UPDATE artist
- SET strGenres = ?,
- strBiography = ?,
- strImage = ?,
- strFanart = ?,
- lastScraped = ?
- WHERE idArtist = ?
- ''', (args))
+ if app.SYNC.artwork:
+ self.cursor.execute('''
+ UPDATE artist
+ SET strGenres = ?,
+ strBiography = ?,
+ strImage = ?,
+ strFanart = ?,
+ lastScraped = ?
+ WHERE idArtist = ?
+ ''', (args))
+ else:
+ args = list(args)
+ del args[3], args[2]
+ self.cursor.execute('''
+ UPDATE artist
+ SET strGenres = ?,
+ strBiography = ?,
+ lastScraped = ?
+ WHERE idArtist = ?
+ ''', (args))
def remove_song(self, kodi_id):
self.cursor.execute('DELETE FROM song WHERE idSong = ?', (kodi_id, ))
diff --git a/resources/lib/library_sync/fanart.py b/resources/lib/library_sync/fanart.py
index d749dfdc..a04f2734 100644
--- a/resources/lib/library_sync/fanart.py
+++ b/resources/lib/library_sync/fanart.py
@@ -13,7 +13,8 @@ from .. import itemtypes, plex_functions as PF, variables as v, app
LOG = getLogger('PLEX.sync.fanart')
SUPPORTED_TYPES = (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW)
-SYNC_FANART = utils.settings('FanartTV') == 'true'
+SYNC_FANART = (utils.settings('FanartTV') == 'true' and
+ utils.settings('usePlexArtwork') == 'true')
PREFER_KODI_COLLECTION_ART = utils.settings('PreferKodiCollectionArt') == 'false'
BATCH_SIZE = 500
diff --git a/resources/lib/sync.py b/resources/lib/sync.py
index 59e1e737..8120257d 100644
--- a/resources/lib/sync.py
+++ b/resources/lib/sync.py
@@ -136,6 +136,9 @@ class Sync(backgroundthread.KillableThread):
if not utils.settings('FanartTV') == 'true':
LOG.info('Additional fanart download is deactivated')
return False
+ if not app.SYNC.artwork:
+ LOG.info('Not synching Plex PMS artwork, not getting artwork')
+ return False
elif self.fanart is None or not self.fanart.is_alive():
LOG.info('Start downloading additional fanart with refresh %s',
refresh)
@@ -156,6 +159,9 @@ class Sync(backgroundthread.KillableThread):
if not utils.settings('enableTextureCache') == "true":
LOG.info('Image caching has been deactivated')
return
+ if not app.SYNC.artwork:
+ LOG.info('Not synching Plex artwork - not caching')
+ return
if self.image_cache_thread and self.image_cache_thread.is_alive():
self.image_cache_thread.cancel()
self.image_cache_thread.join()
diff --git a/resources/settings.xml b/resources/settings.xml
index 1f81d6e7..ab22b4a4 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -132,16 +132,17 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+