def main(): email, password = get_login() api = RiCloud() try: api.login(email, password) except TwoFactorAuthenticationRequired: trusted_device = choose_trusted_device(api.trusted_devices) api.request_2fa_challenge(challenge_device=trusted_device) code = get_2fa_code() api.submit_2fa_challenge(code=code) api.login(email, password) device_id = choose_device(api.devices) mask = get_data_mask() data = api.backup_client.request_data(device_id=device_id, data_mask=mask) # Let's setup the output try: os.mkdir('out') except OSError: # Dir already exists (most likely) pass with open(os.path.join('out', 'data.json'), 'wb') as out: json.dump(data, out, indent=4) if 'photos' in data and isinstance(data['photos'], list): for photo in data['photos']: with open(os.path.join('out', photo['filename']), 'wb') as out: api.backup_client.download_file(device_id, photo['file_id'], out) print 'Complete! All data is in the directory "out".'
# check for the credentials file if os.path.isfile('./credentials.py'): from credentials import APPLE_ID, APPLE_PASSWORD else: print "credentials.py file missing, please create one. ie:\n{cred}".format( cred=example_credentials) raise SystemExit if APPLE_ID == '*****@*****.**' and APPLE_PASSWORD == 1234: # test if variables are test credentials print "these are test credentials, search will be performed against test document." from test_data import data else: # if all exists, try and connect to the api api = RiCloud() api.login(APPLE_ID, APPLE_PASSWORD) # then request history for device in api.devices: data = api.backup_client.request_data(device_id=device, data_mask=4) # simple request for string search = raw_input('what is your search term? i.e. google\n') # attempts to match search string to url if search in data['url']: print "site found, {url}, visited on {visit}.".format( url=data['url'], visit=data['last_visit']) else: print "pattern not found."
example_credentials = "APPLE_ID='*****@*****.**'\nAPPLE_PASSWORD=1234" # check for the credentials file if os.path.isfile('./credentials.py'): from credentials import APPLE_ID, APPLE_PASSWORD else: print "credentials.py file missing, please create one. ie:\n{cred}".format(cred=example_credentials) raise SystemExit if APPLE_ID == '*****@*****.**' and APPLE_PASSWORD == 1234: # test if variables are test credentials print "these are test credentials, search will be performed against test document." from test_data import data else: # if all exists, try and connect to the api api = RiCloud() api.login(APPLE_ID, APPLE_PASSWORD) # then request history for device in api.devices: data = api.backup_client.request_data(device_id=device, data_mask=4) # simple request for string search = raw_input('what is your search term? i.e. google\n') # attempts to match search string to url if search in data['url']: print "site found, {url}, visited on {visit}.".format(url=data['url'],visit=data['last_visit']) else: print "pattern not found."