From ffadb4cf3a71eca843f73fbff2b7fef162a0276d Mon Sep 17 00:00:00 2001 From: Quentame Date: Tue, 10 Mar 2020 00:10:22 +0100 Subject: [PATCH] Choose to fetch family devices (#235) --- pyicloud/base.py | 6 ++++-- pyicloud/services/findmyiphone.py | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pyicloud/base.py b/pyicloud/base.py index 34bd6a6..24cfc0b 100644 --- a/pyicloud/base.py +++ b/pyicloud/base.py @@ -145,13 +145,14 @@ class PyiCloudService(object): def __init__( self, apple_id, password=None, cookie_directory=None, verify=True, - client_id=None + client_id=None, with_family=True ): if password is None: password = get_password_from_keyring(apple_id) self.data = {} self.client_id = client_id or str(uuid.uuid1()).upper() + self.with_family = with_family self.user = {'apple_id': apple_id, 'password': password} self._password_filter = PyiCloudPasswordFilter(password) @@ -314,7 +315,8 @@ class PyiCloudService(object): return FindMyiPhoneServiceManager( service_root, self.session, - self.params + self.params, + self.with_family ) @property diff --git a/pyicloud/services/findmyiphone.py b/pyicloud/services/findmyiphone.py index 653fa6b..dc7c0ba 100644 --- a/pyicloud/services/findmyiphone.py +++ b/pyicloud/services/findmyiphone.py @@ -14,15 +14,16 @@ class FindMyiPhoneServiceManager(object): """ - def __init__(self, service_root, session, params): + def __init__(self, service_root, session, params, with_family=False): self.session = session self.params = params - self._service_root = service_root - self._fmip_endpoint = '%s/fmipservice/client/web' % self._service_root - self._fmip_refresh_url = '%s/refreshClient' % self._fmip_endpoint - self._fmip_sound_url = '%s/playSound' % self._fmip_endpoint - self._fmip_message_url = '%s/sendMessage' % self._fmip_endpoint - self._fmip_lost_url = '%s/lostDevice' % self._fmip_endpoint + self.with_family = with_family + + fmip_endpoint = '%s/fmipservice/client/web' % service_root + self._fmip_refresh_url = '%s/refreshClient' % fmip_endpoint + self._fmip_sound_url = '%s/playSound' % fmip_endpoint + self._fmip_message_url = '%s/sendMessage' % fmip_endpoint + self._fmip_lost_url = '%s/lostDevice' % fmip_endpoint self._devices = {} self.refresh_client() @@ -39,7 +40,7 @@ class FindMyiPhoneServiceManager(object): data=json.dumps( { 'clientContext': { - 'fmly': True, + 'fmly': self.with_family, 'shouldLocate': True, 'selectedDevice': 'all', } @@ -134,7 +135,7 @@ class AppleDevice(object): 'device': self.content['id'], 'subject': subject, 'clientContext': { - 'fmly': True + 'fmly': self.with_family } }) self.session.post(