Skip to content

Commit

Permalink
fix(photos): restore ability to enumerate items in a photo album (#71)
Browse files Browse the repository at this point in the history
* fix(photos): restore ability to enumerate items in a photo album

resolves #70

* fix(photos): restore ability to delete

---------

Co-authored-by: Mandar Patil <[email protected]>
  • Loading branch information
fresh2dev and mandarons authored Dec 17, 2024
1 parent 80fffe0 commit ab3527e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions icloudpy/services/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __iter__(self):

def __len__(self):
if self._len is None:
url = f"{self.service.service_endpoint}/internal/records/query/batch?{urlencode(self.service.params)}"
url = f"{self.service._service_endpoint}/internal/records/query/batch?{urlencode(self.service.params)}"
request = self.service.session.post(
url,
data=json.dumps(
Expand All @@ -339,7 +339,7 @@ def __len__(self):
"recordType": "HyperionIndexCountLookup",
},
"zoneWide": True,
"zoneID": {"zoneName": self._zone_id},
"zoneID": {"zoneName": self._zone_id["zoneName"]},
},
],
},
Expand Down Expand Up @@ -751,21 +751,26 @@ def download(self, version="original", **kwargs):

def delete(self):
"""Deletes the photo."""
json_data = (
f'{{"operations":[{{'
f'"operationType":"update",'
f'"record":{{'
f'"recordName":"{self._asset_record["recordName"]}",'
f'"recordType":"{self._asset_record["recordType"]}",'
f'"recordChangeTag":"{self._master_record["recordChangeTag"]}",'
f'"fields":{{"isDeleted":{{"value":1}}'
f'}}}}],'
f'"zoneID":{{'
f'"zoneName":"PrimarySync"'
f'}},"atomic":true}}'
json_data = json.dumps(
{
"atomic": True,
"desiredKeys": ["isDeleted"],
"operations": [
{
"operationType": "update",
"record": {
"fields": {"isDeleted": {"value": 1}},
"recordChangeTag": self._asset_record["recordChangeTag"],
"recordName": self._asset_record["recordName"],
"recordType": self._asset_record["recordType"],
},
},
],
"zoneID": self._service.zone_id,
},
)

endpoint = self._service.service_endpoint
endpoint = self._service._service_endpoint
params = urlencode(self._service.params)
url = f"{endpoint}/records/modify?{params}"

Expand Down

0 comments on commit ab3527e

Please sign in to comment.