Skip to content

Commit e5df09c

Browse files
committed
fix settings for py 2
1 parent 4f5ce34 commit e5df09c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

plexapi/settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ class Setting(PlexObject):
101101
"""
102102
_bool_cast = lambda x: True if x == 'true' or x == '1' else False
103103
_bool_str = lambda x: str(x).lower()
104+
_str = lambda x: str(x).encode('utf-8')
104105
TYPES = {
105106
'bool': {'type': bool, 'cast': _bool_cast, 'tostr': _bool_str},
106-
'double': {'type': float, 'cast': float, 'tostr': string_type},
107-
'int': {'type': int, 'cast': int, 'tostr': string_type},
108-
'text': {'type': string_type, 'cast': string_type, 'tostr': string_type},
107+
'double': {'type': float, 'cast': float, 'tostr': _str},
108+
'int': {'type': int, 'cast': int, 'tostr': _str},
109+
'text': {'type': string_type, 'cast': _str, 'tostr': _str},
109110
}
110111

111112
def _loadData(self, data):

tests/test_settings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ def test_settings_set(plex):
1717
plex.settings.save()
1818
plex._settings = None
1919
assert plex.settings.get('autoEmptyTrash').value == new_value
20+
21+
22+
def test_settings_set_str(plex):
23+
cd = plex.settings.get('OnDeckWindow')
24+
new_value = 99
25+
cd.set(new_value)
26+
plex.settings.save()
27+
plex._settings = None
28+
assert plex.settings.get('autoEmptyTrash').value == 99

0 commit comments

Comments
 (0)