diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 4cf19292..e592d5ea 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -319,6 +319,7 @@ Always pick best quality for trailers Kodi runs on a low-power device (e.g. Raspberry Pi) Artwork + Force transcode pictures Welcome diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index bdd2f012..c3711496 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -36,6 +36,7 @@ Trailer immer in der besten Qualität abspielen Kodi läuft auf langsamer Hardware (z.B. Raspberry Pi) Artwork + Bilder immer transkodieren Verbindung Netzwerk diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index de7d1b53..c7339805 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -51,7 +51,7 @@ from utils import window, settings, language as lang, tryDecode, tryEncode, \ DateToKodi, KODILANGUAGE from PlexFunctions import PLEX_TO_KODI_TIMEFACTOR, PMSHttpsEnabled, \ REMAP_TYPE_FROM_PLEXTYPE, PLEX_TYPE_MOVIE, PLEX_TYPE_SHOW, \ - PLEX_TYPE_EPISODE + PLEX_TYPE_EPISODE, KODI_SUPPORTED_IMAGES import plexdb_functions as plexdb ############################################################################### @@ -2359,23 +2359,30 @@ class API(): else: listItem.setLabel(title) listItem.setProperty('IsPlayable', 'true') - if settings('useDirectPaths') == '0': - # Addon paths - if not self.item[0][0].attrib['key'][self.item[0][0].attrib['key'].rfind('.'):].lower() in ('.bmp', '.jpg', '.jpeg', '.gif', '.png', '.tiff', '.mng', '.ico', '.pcx', '.tga'): - # Check if Kodi supports the file, if not transcode it by Plex - # extensions from: http://kodi.wiki/view/Features_and_supported_codecs#Format_support (RAW image formats, BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX and Targa/TGA) - path = str(self.server) + str(PlexAPI().getTranscodeImagePath(self.item[0][0].attrib.get('key'), window('pms_token'), "%s%s" % (self.server, self.item[0][0].attrib.get('key')), 1920, 1080)) - # max width/height supported by plex image transcoder is 1920x1080 - else: - # Just give the path of the file to Kodi - path = self.addPlexCredentialsToUrl( - '%s%s' % (window('pms_server'), - self.item[0][0].attrib['key'])) + extension = self.item[0][0].attrib['key'][self.item[0][0].attrib['key'].rfind('.'):].lower() + if (window('plex_force_transcode_pix') == 'true' or + extension not in KODI_SUPPORTED_IMAGES): + # Let Plex transcode + # max width/height supported by plex image transcoder is 1920x1080 + path = self.server + PlexAPI().getTranscodeImagePath( + self.item[0][0].attrib.get('key'), + window('pms_token'), + "%s%s" % (self.server, self.item[0][0].attrib.get('key')), + 1920, + 1080) else: - # Native direct paths - path = self.validatePlayurl( - self.getFilePath(forceFirstMediaStream=True), - 'photo') + # Don't transcode + if settings('useDirectPaths') == '0': + # Addon Mode. Just give the path of the file to Kodi + path = self.addPlexCredentialsToUrl( + '%s%s' % (window('pms_server'), + self.item[0][0].attrib['key'])) + else: + # Native direct paths + path = self.validatePlayurl( + self.getFilePath(forceFirstMediaStream=True), + 'photo') + path = tryEncode(path) metadata = { 'date': self.GetKodiPremierDate(), diff --git a/resources/lib/PlexFunctions.py b/resources/lib/PlexFunctions.py index 774f559b..a76ec7f1 100644 --- a/resources/lib/PlexFunctions.py +++ b/resources/lib/PlexFunctions.py @@ -147,6 +147,23 @@ REMAP_TYPE_FROM_PLEXTYPE = { } +# extensions from: +# http://kodi.wiki/view/Features_and_supported_codecs#Format_support (RAW image +# formats, BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX and Targa/TGA) +KODI_SUPPORTED_IMAGES = ( + '.bmp', + '.jpg', + '.jpeg', + '.gif', + '.png', + '.tiff', + '.mng', + '.ico', + '.pcx', + '.tga' +) + + def ConvertPlexToKodiTime(plexTime): """ Converts Plextime to Koditime. Returns an int (in seconds). diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 019c1b5f..0232a28a 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -53,6 +53,7 @@ class KodiMonitor(Monitor): 'dbSyncIndicator': 'dbSyncIndicator', 'remapSMB': 'remapSMB', 'replaceSMB': 'replaceSMB', + 'force_transcode_pix': 'plex_force_transcode_pix' } # Path replacement for typus in REMAP_TYPE_FROM_PLEXTYPE.values(): diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 75ff98bb..483d7356 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -180,6 +180,8 @@ class UserClient(threading.Thread): window('useDirectPaths', value='true' if settings('useDirectPaths') == "1" else 'false') + window('plex_force_transcode_pix', value='true' + if settings('force_transcode_pix') == "1" else 'false') # Start DownloadUtils session doUtils.startSession(reset=True) diff --git a/resources/settings.xml b/resources/settings.xml index aab11e2d..6b2008fa 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -108,6 +108,7 @@ + diff --git a/service.py b/service.py index de3ca487..557d032a 100644 --- a/service.py +++ b/service.py @@ -113,7 +113,7 @@ class Service(): "suspend_LibraryThread", "plex_terminateNow", "kodiplextimeoffset", "countError", "countUnauthorized", "plex_restricteduser", "plex_allows_mediaDeletion", - "plex_play_new_item", "plex_result" + "plex_play_new_item", "plex_result", "plex_force_transcode_pix" ] for prop in properties: window(prop, clear=True)