New setting to force transcode all Plex images

This commit is contained in:
tomkat83 2017-01-15 18:01:27 +01:00
parent ccaeca0019
commit 8680410ab2
8 changed files with 48 additions and 18 deletions

View file

@ -319,6 +319,7 @@
<string id="30542">Always pick best quality for trailers</string>
<string id="30543">Kodi runs on a low-power device (e.g. Raspberry Pi)</string>
<string id="30544">Artwork</string>
<string id="30545">Force transcode pictures</string>
<!-- service add-on -->
<string id="33000">Welcome</string>

View file

@ -36,6 +36,7 @@
<string id="30542">Trailer immer in der besten Qualität abspielen</string>
<string id="30543">Kodi läuft auf langsamer Hardware (z.B. Raspberry Pi)</string>
<string id="30544">Artwork</string>
<string id="30545">Bilder immer transkodieren</string>
<string id="30014">Verbindung</string>
<string id="30015">Netzwerk</string>

View file

@ -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(),

View file

@ -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).

View file

@ -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():

View file

@ -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)

View file

@ -108,6 +108,7 @@
<setting id="networkCreds" type="text" visible="false" default="" />
<setting id="bestQuality" type="bool" label="30541" default="false" />
<setting id="bestTrailer" type="bool" label="30542" default="true" />
<setting id="force_transcode_pix" type="bool" label="30545" default="false" />
</category>
<category label="30544"><!-- artwork -->

View file

@ -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)