1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-30 11:35:50 +00:00
bazarr/libs/plex/interfaces/preferences.py

41 lines
963 B
Python
Raw Normal View History

2018-10-31 16:08:29 +00:00
from plex.core.idict import idict
from plex.interfaces.core.base import Interface
class PreferencesInterface(Interface):
path = ':/prefs'
def get(self, id=None):
response = self.http.get()
container = self.parse(response, idict({
'MediaContainer': ('MediaContainer', idict({
'Setting': 'Setting'
}))
}))
if container is None or id is None:
return container
for setting in container:
if setting.id == id:
return setting
return None
def set(self, id, value):
response = self.http.put(query={
id: self.to_setting_value(value, type(value))
})
return response.status_code == 200
def to_setting_value(self, value, value_type=None):
if value is None:
return None
if value_type is bool:
return str(value).lower()
return str(value)