Edit Library and Show's Advanced Settings#507
Conversation
allow for editing a show's advanced settings using kwargs
allows for defaulting all advanced settings
|
I can move/add these methods to def preferences(self):
""" Returns a list of :class:`~plexapi.settings.Preferences` objects. """
items = []
data = self._server.query(self._details_key)
for item in data.iter('Preferences'):
for elem in item:
setting = settings.Preferences(data=elem, server=self._server)
setting._initpath = self.key
items.append(setting)
return itemsThis way the settings could be updated from the show object in mass or from the preference object. |
|
I should add some tests to this. Switch settings, reload, assert. |
|
@Hellowlol this should be ready for review. |
plexapi/settings.py
Outdated
| if self.type == 'int': | ||
| url = key + '%s=%s' % (self.id, self.default) | ||
| else: | ||
| url = key + '%s=%s' % (self.id, self.default.decode()) |
There was a problem hiding this comment.
Is it still needed to decode this? py2 has been dropped.
There was a problem hiding this comment.
.default is a value so it also is a byte that is either an int or str.
plexapi/video.py
Outdated
| try: | ||
| enumValues = [int(x) for x in preferences.get(settingID)] | ||
| except ValueError: | ||
| enumValues = [x.decode() for x in preferences.get(settingID)] |
There was a problem hiding this comment.
same again, why do we need to decode?
There was a problem hiding this comment.
The .value can be classed as a byte that is either an int or str. Majority of the time they're int -1, 1, 2 something like that.
There was a problem hiding this comment.
_bool_cast = lambda x: True if x == 'true' or x == '1' else False
_bool_str = lambda x: str(x).lower()
_str = lambda x: str(x).encode('utf-8') # py2 dependant?
TYPES = {
'bool': {'type': bool, 'cast': _bool_cast, 'tostr': _bool_str},
'double': {'type': float, 'cast': float, 'tostr': _str},
'int': {'type': int, 'cast': int, 'tostr': _str},
'text': {'type': str, 'cast': _str , 'tostr': _str},
}Updating the the tostr: _str references to tostr: str should resolve the issue.
update _str references to use builin str instead update settings.Preferences class for py2 drop
…nt/int based change
|
Calling |
py2 support has been dropped. returning str instead of bytes now due to 5045ddc
|
This PR should be gtg. |
Allow for editing a show's advanced settings
show.editAdvanced(showOrdering='aired', autoDeletionItemPolicyWatchedLibrary=0)Allow for editing a library's advanced settings
library.editAdvanced(enableBIFGeneration=0, collectionMode=2)