Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions request_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,24 @@ def getAuth(regenerate=False, second_factor='sms'):

unixEpoch = int(datetime.datetime.now().strftime('%s'))
startdate = unixEpoch - (60 * 60 * args.hours)
data = { "search": [{"startDate": startdate *1000, "endDate": unixEpoch *1000, "ids": list(names.keys())}] }

r = requests.post("https://gateway.icloud.com/acsnservice/fetch",
auth=getAuth(regenerate=args.regen, second_factor='trusted_device' if args.trusteddevice else 'sms'),
headers=generate_anisette_headers(),
json=data)
res = json.loads(r.content.decode())['results']
print(f'{r.status_code}: {len(res)} reports received.')
# batch requests with max 4 IDs each
all_ids = list(names.keys())
batch_size = 4
res = []

for i in range(0, len(all_ids), batch_size):
batch_ids = all_ids[i:i+batch_size]
data = { "search": [{"startDate": startdate *1000, "endDate": unixEpoch *1000, "ids": batch_ids}] }

r = requests.post("https://gateway.icloud.com/acsnservice/fetch",
auth=getAuth(regenerate=args.regen, second_factor='trusted_device' if args.trusteddevice else 'sms'),
headers=generate_anisette_headers(),
json=data)
batch_res = json.loads(r.content.decode())['results']
res.extend(batch_res)
print(f'batch {i//batch_size + 1}: {r.status_code}: {len(batch_res)} reports received.')

print(f'total: {len(res)} reports received.')

ordered = []
found = set()
Expand Down