diff --git a/API.md b/API.md index 1eb8ab4b..46d5b3ef 100644 --- a/API.md +++ b/API.md @@ -240,7 +240,8 @@ Remove a mobile device from the database. ``` Required parameters: - mobile_device_id (int): The device id to delete + mobile_device_id (int): The mobile device database id to delete, OR + device_id (str): The unique device identifier for the mobile device Optional parameters: None diff --git a/plexpy/mobile_app.py b/plexpy/mobile_app.py index a4653368..3f784c40 100644 --- a/plexpy/mobile_app.py +++ b/plexpy/mobile_app.py @@ -149,13 +149,17 @@ def set_mobile_device_config(mobile_device_id=None, **kwargs): return False -def delete_mobile_device(mobile_device_id=None): +def delete_mobile_device(mobile_device_id=None, device_id=None): db = database.MonitorDatabase() if mobile_device_id: - logger.debug("Tautulli MobileApp :: Deleting device_id %s from the database." % mobile_device_id) + logger.debug("Tautulli MobileApp :: Deleting mobile_device_id %s from the database." % mobile_device_id) result = db.action('DELETE FROM mobile_devices WHERE id = ?', args=[mobile_device_id]) return True + elif device_id: + logger.debug("Tautulli MobileApp :: Deleting device_id %s from the database." % device_id) + result = db.action('DELETE FROM mobile_devices WHERE device_id = ?', args=[device_id]) + return True else: return False diff --git a/plexpy/webserve.py b/plexpy/webserve.py index e7700532..882d9919 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -3823,12 +3823,13 @@ class WebInterface(object): @cherrypy.tools.json_out() @requireAuth(member_of("admin")) @addtoapi() - def delete_mobile_device(self, mobile_device_id=None, **kwargs): + def delete_mobile_device(self, mobile_device_id=None, device_id=None, **kwargs): """ Remove a mobile device from the database. ``` Required parameters: - mobile_device_id (int): The device id to delete + mobile_device_id (int): The mobile device database id to delete, OR + device_id (str): The unique device identifier for the mobile device Optional parameters: None @@ -3837,7 +3838,8 @@ class WebInterface(object): None ``` """ - result = mobile_app.delete_mobile_device(mobile_device_id=mobile_device_id) + result = mobile_app.delete_mobile_device(mobile_device_id=mobile_device_id, + device_id=device_id) if result: return {'result': 'success', 'message': 'Deleted mobile device.'} else: