Skip to content

Commit

Permalink
Core/Cache/Settings: Disallow writing (and showing) cache settings fr…
Browse files Browse the repository at this point in the history
…om within the plugin when installed from the official Kodi repository and we don't have the modern API
  • Loading branch information
pannal committed Aug 2, 2024
1 parent ad959df commit 178038e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from plexnet import plexapp

from lib.kodijsonrpc import rpc
from lib.util import ADDON, translatePath, KODI_BUILD_NUMBER, DEBUG_LOG, LOG, ERROR
from lib.util import ADDON, translatePath, KODI_BUILD_NUMBER, DEBUG_LOG, LOG, FROM_KODI_REPOSITORY
from lib.advancedsettings import adv


Expand Down Expand Up @@ -100,6 +100,10 @@ def load(self):
# self._cleanData = data

def write(self, memorySize=None, readFactor=None):
# never write to advancedSettings when we're installed from the Kodi repository and don't have the modern API
if FROM_KODI_REPOSITORY and not self.useModernAPI:
return

memorySize = self.memorySize = memorySize if memorySize is not None else self.memorySize
readFactor = self.readFactor = readFactor if readFactor is not None else self.readFactor

Expand Down
2 changes: 1 addition & 1 deletion lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
translatePath = xbmc.translatePath

SKIN_PLEXTUARY = xbmc.getSkinDir() == "skin.plextuary"

FROM_KODI_REPOSITORY = ADDON.getAddonInfo('name') == "PM4K for Plex"
PROFILE = translatePath(ADDON.getAddonInfo('profile'))


Expand Down
7 changes: 5 additions & 2 deletions lib/windows/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ class Settings(object):
'{}{}'.format(T(33614, 'stub1').format(
lib.cache.kcm.free, lib.cache.kcm.recMax),
'' if lib.cache.kcm.useModernAPI else ' ' + T(32954, 'stub2'))
),
) if not util.FROM_KODI_REPOSITORY or lib.cache.kcm.useModernAPI else None,
ReadFactorSetting('readfactor',
T(32922, 'Kodi Cache Readfactor'),
4,
Expand All @@ -776,7 +776,7 @@ class Settings(object):
'fill fast/aggressively enough.').format(lib.cache.kcm.defRF,
lib.cache.kcm.recRFRange,
lib.cache.kcm.defRFSM)
),
) if not util.FROM_KODI_REPOSITORY or lib.cache.kcm.useModernAPI else None,
BoolSetting(
'slow_connection', T(32915, 'Slow connection'), False
).description("Use with a wonky/slow connection, e.g. in a hotel room. Adjusts the UI to visually "
Expand Down Expand Up @@ -921,6 +921,9 @@ def showSettings(self, section):

items = []
for setting in settings:
if setting is None:
continue

item = kodigui.ManagedListItem(setting.label, setting.type != 'BOOL' and setting.valueLabel() or '',
data_source=setting)
item.setProperty('description', setting.desc)
Expand Down

0 comments on commit 178038e

Please sign in to comment.