Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/icloudpd/autodelete.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def autodelete_photos(
"""
logger.info("Deleting any files found in 'Recently Deleted'...")

recently_deleted = library_object.albums["Recently Deleted"]
recently_deleted = library_object.recently_deleted

for media in recently_deleted:
try:
Expand Down
21 changes: 13 additions & 8 deletions src/pyicloud_ipd/services/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class PhotoLibrary(object):
"direction": "ASCENDING",
"query_filter": None
}
RECENTLY_DELETED = {
"obj_type": "CPLAssetDeletedByExpungedDate",
"list_type": "CPLAssetAndMasterDeletedByExpungedDate",
"direction": "ASCENDING",
"query_filter": None
}
SMART_FOLDERS = {
"Time-lapse": {
"obj_type": "CPLAssetInSmartAlbumByAssetDate:Timelapse",
Expand Down Expand Up @@ -140,12 +146,7 @@ class PhotoLibrary(object):
}
}]
},
"Recently Deleted": {
"obj_type": "CPLAssetDeletedByExpungedDate",
"list_type": "CPLAssetAndMasterDeletedByExpungedDate",
"direction": "ASCENDING",
"query_filter": None
},
"Recently Deleted": RECENTLY_DELETED,
"Hidden": {
"obj_type": "CPLAssetHiddenByAssetDate",
"list_type": "CPLAssetAndMasterHiddenByAssetDate",
Expand All @@ -162,6 +163,7 @@ def __init__(self, service: "PhotosService", zone_id: Dict[str, Any], library_ty

self._albums: Optional[Dict[str, PhotoAlbum]] = None
self._all: Optional[PhotoAlbum] = None
self._recently_deleted: Optional[PhotoAlbum] = None

url = ('%s/records/query?%s' %
(self.service_endpoint, urlencode(self.service.params)))
Expand Down Expand Up @@ -243,10 +245,13 @@ def _fetch_folders(self) -> Sequence[Dict[str, Any]]:
def all(self) -> "PhotoAlbum":
if not self._all:
self._all = PhotoAlbum(self.service, self.service_endpoint, "", zone_id=self.zone_id, **self.WHOLE_COLLECTION) # type: ignore[arg-type] # dynamically builing params
# need to pull all albums because existing recorded tests expect all albums to be pulled...
self.albums
return self._all

@property
def recently_deleted(self) -> "PhotoAlbum":
if not self._recently_deleted:
self._recently_deleted = PhotoAlbum(self.service, self.service_endpoint, "", zone_id=self.zone_id, **self.RECENTLY_DELETED) # type: ignore[arg-type] # dynamically builing params
return self._recently_deleted

class PhotosService(PhotoLibrary):
"""The 'Photos' iCloud service.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_download_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def mocked_authenticate(self: PyiCloudService) -> None:
self.assertEqual,
self.root_path,
base_dir,
"listing_photos.yml",
"listing_albums.yml",
[],
[],
[
Expand Down
2 changes: 1 addition & 1 deletion tests/test_download_photos_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def mocked_authenticate(self: PyiCloudService) -> None:
self.assertEqual,
self.root_path,
base_dir,
"listing_photos.yml",
"listing_albums.yml",
[],
[],
[
Expand Down
6 changes: 3 additions & 3 deletions tests/test_listing_recent_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ def test_listing_recent_photos_with_missing_downloadURL(self) -> None:
mock_open.assert_called_once_with(
file="icloudpd-photo-error.json", mode="w", encoding="utf8"
)
# Multiple JSON "dumps" occur with the new pyicloud 1.0.0 implementation
# mock_json.assert_called_once()
mock_json.assert_called()
self.assertEqual(len(mock_json.call_args_list), 7)
# Check a few keys in the dict
first_arg = mock_json.call_args_list[7][0][0]
first_arg = mock_json.call_args_list[6][0][0]
self.assertEqual(
first_arg["master_record"]["recordName"], "AY6c+BsE0jjaXx9tmVGJM1D2VcEO"
)
Expand Down
638 changes: 0 additions & 638 deletions tests/vcr_cassettes/autodelete_photos.yml

Large diffs are not rendered by default.

638 changes: 0 additions & 638 deletions tests/vcr_cassettes/autodelete_photos_heic.yml

Large diffs are not rendered by default.

592 changes: 0 additions & 592 deletions tests/vcr_cassettes/download_autodelete_photos.yml

Large diffs are not rendered by default.

616 changes: 0 additions & 616 deletions tests/vcr_cassettes/download_live_photos.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_bad_filename.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_bad_filename_base64_encoding.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_bad_filename_utf8_encoding.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_chinese.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_filename_string_encoding.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_keep_icloud_recent_days.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_missing_downloadUrl.yml

Large diffs are not rendered by default.

596 changes: 0 additions & 596 deletions tests/vcr_cassettes/listing_photos_missing_filenameEnc.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_missing_item_type.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_missing_item_type_value.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_no_delete.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_raw.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_raw_alt.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_raw_alt_adj.yml

Large diffs are not rendered by default.

595 changes: 0 additions & 595 deletions tests/vcr_cassettes/listing_photos_two_sizes.yml

Large diffs are not rendered by default.

Loading