Skip to content

Commit

Permalink
Bug fix in Album
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Sep 14, 2020
1 parent 3ae8d60 commit e0a60e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion photoscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def export(self, export_path, original=False, overwrite=False, timeout=120):
return exported_photos

def remove_by_id(self, photo_ids):
"""Remove photos from album.
"""Remove photos from album.
Note: Photos does not provide a way to remove photos from an album via AppleScript.
This method actually creates a new Album with the same name as the original album and
copies all photos from original album with exception of those to remove to the new album
Expand All @@ -633,6 +633,7 @@ def remove_by_id(self, photo_ids):
photoslib.delete_album(self)
new_album.name = name
self.id = new_album.id
self._uuid = new_album.uuid
return new_album

def remove(self, photos):
Expand Down
13 changes: 10 additions & 3 deletions photoscript/photoscript.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,16 @@ end _album_add
on _album_set_name(_id, _title)
(* set name or title of album *)
_photoslibrary_waitforphotos(WAIT_FOR_PHOTOS)
tell application "Photos"
set name of album id (_id) to _title
end tell
set count_ to 0
repeat while count_ < MAX_RETRY
tell application "Photos"
set name of album id (_id) to _title
if name of album id (_id) = _title then
return _title
end if
end tell
set count_ to count_ + 1
end repeat
end _album_set_name

on _album_get_path(id_, path_delimiter_)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_2_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ def test_album_remove_by_id(photoslib):
uuids = [photo.id for photo in new_album.photos()]
assert sorted(uuids) == sorted(ALBUM_1_POST_REMOVE_UUIDS)
assert new_album.title == ALBUM_1_NAME
assert new_album.id == album.id
assert new_album.parent.id == parent_id
assert album.id == new_album.id
assert album.uuid == new_album.uuid


def test_album_remove(photoslib):
Expand Down

0 comments on commit e0a60e4

Please sign in to comment.