Add min_version parameter to register_device API command

This commit is contained in:
JonnyWong16 2020-10-12 11:56:55 -07:00
parent 7914f56ec3
commit 36aa795c52
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 17 additions and 7 deletions

4
API.md
View file

@ -2906,12 +2906,12 @@ Required parameters:
Optional parameters: Optional parameters:
friendly_name (str): A friendly name to identify the mobile device friendly_name (str): A friendly name to identify the mobile device
onesignal_id (str): The OneSignal id for the mobile device onesignal_id (str): The OneSignal id for the mobile device
min_version (str): The minimum Tautulli version supported by the mobile device, e.g. v2.5.6
Returns: Returns:
json: json:
{"pms_name": "Winterfell-Server", {"pms_name": "Winterfell-Server",
"server_id": "ds48g4r354a8v9byrrtr697g3g79w", "server_id": "ds48g4r354a8v9byrrtr697g3g79w"
"tautulli_version": "v2.5.6"
} }
``` ```

View file

@ -396,7 +396,8 @@ class API2(object):
return data return data
def register_device(self, device_id='', device_name='', friendly_name='', onesignal_id=None, **kwargs): def register_device(self, device_id='', device_name='', friendly_name='', onesignal_id=None,
min_version='', **kwargs):
""" Registers the Tautulli Android App for notifications. """ Registers the Tautulli Android App for notifications.
``` ```
@ -407,12 +408,12 @@ class API2(object):
Optional parameters: Optional parameters:
friendly_name (str): A friendly name to identify the mobile device friendly_name (str): A friendly name to identify the mobile device
onesignal_id (str): The OneSignal id for the mobile device onesignal_id (str): The OneSignal id for the mobile device
min_version (str): The minimum Tautulli version supported by the mobile device, e.g. v2.5.6
Returns: Returns:
json: json:
{"pms_name": "Winterfell-Server", {"pms_name": "Winterfell-Server",
"server_id": "ds48g4r354a8v9byrrtr697g3g79w", "server_id": "ds48g4r354a8v9byrrtr697g3g79w"
"tautulli_version": "v2.5.6"
} }
``` ```
""" """
@ -426,6 +427,12 @@ class API2(object):
self._api_result_type = 'error' self._api_result_type = 'error'
return return
elif min_version and helpers.version_to_tuple(min_version) > helpers.version_to_tuple(common.RELEASE):
self._api_msg = 'Device registration failed: Tautulli version {} ' \
'does not meet the minimum requirement of {}.'.format(common.RELEASE, min_version)
self._api_result_type = 'error'
return
## TODO: Temporary for backwards compatibility, assume device_id is onesignal_id ## TODO: Temporary for backwards compatibility, assume device_id is onesignal_id
if device_id and onesignal_id is None: if device_id and onesignal_id is None:
onesignal_id = device_id onesignal_id = device_id
@ -444,8 +451,7 @@ class API2(object):
data = { data = {
"pms_name": plexpy.CONFIG.PMS_NAME, "pms_name": plexpy.CONFIG.PMS_NAME,
"server_id": plexpy.CONFIG.PMS_UUID, "server_id": plexpy.CONFIG.PMS_UUID
"tautulli_version": common.RELEASE
} }
return data return data

View file

@ -1470,6 +1470,10 @@ def is_hdr(bit_depth, color_space):
return bit_depth > 8 and color_space == 'bt2020nc' return bit_depth > 8 and color_space == 'bt2020nc'
def version_to_tuple(version):
return tuple(cast_to_int(v) for v in version.strip('v').split('.'))
def page(endpoint, *args, **kwargs): def page(endpoint, *args, **kwargs):
endpoints = { endpoints = {
'pms_image_proxy': pms_image_proxy, 'pms_image_proxy': pms_image_proxy,