Skip to content

Commit

Permalink
Add logging and fix issue with cleanupAlbum
Browse files Browse the repository at this point in the history
  • Loading branch information
sto3014 committed Feb 19, 2024
1 parent 3d7d0c5 commit e781a14
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ rendition is marked as skipped.

* Refactored AppleScript scripts

## [2.1.0.0] - 2024-02-11
## [2.1.0.0] - 2024-02-18

### Added

Expand All @@ -80,6 +80,7 @@ rendition is marked as skipped.
### Fixed

* Fixed issue when running multiple jobs.
* Fixed issue when removing photos from albums.
* Fixed issue with albums which contains photos without any keywords.

### Changed
Expand Down
71 changes: 55 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LRPhotos is a Lightroom Classic publishing service for Apple's Photos app.

---

1. Download the zip archive from [GitHub](https://github.com/sto3014/LRPhotos/blob/main/target/LRPhotos2.0.0.2_mac.zip).
1. Download the zip archive from [GitHub](https://github.com/sto3014/LRPhotos/blob/main/target/LRPhotos2.1.0.0_mac.zip).
2. Extract the archive in the download folder
3. Copy plug-in, applescript files and automator workflow into ~/Library
Open a terminal window, change to Downloads/LRPhotos and execute install.sh:
Expand All @@ -38,9 +38,8 @@ LRPhotos is a Lightroom Classic publishing service for Apple's Photos app.
* hbPhotosDisplayID.workflow
4. Restart Lightroom
Adobe Lightroom Classic needs to access System Events using Apple Script. When you try to access the Photos app for the
Adobe Lightroom Classic needs to access System Events using Apple Script. When you access the Photos app for the
first time, the system will ask for permission.
sudo tccutil reset AppleEvents com.adobe.LightroomClassicCC7
## Usage
Expand All @@ -49,38 +48,42 @@ sudo tccutil reset AppleEvents com.adobe.LightroomClassicCC7
The publish process…
* imports photos into Photos.app
* the file name of the photo will be different from the file name in Lightroom.
* The name is set to the photo ID in Lightroom. This ID is displayed also in the metadata of Lightroom.
* The suffix reflects the format which is used during publishing. The suffix is displayed also in the metadata
of Lightroom.
* sets tag
* LR:<name of LR catalog file>
* The name is set to the photo ID in Lightroom. This ID is also displayed in the Lightroom metadata.
* The suffix reflects the format which is used during publishing. The format is also displayed in the Lightroom
metadata. For export data in "original" format, the format value is original.
* sets keywords in Photos
* lr:<name of the Lightroom catalog file>
* album:<name of collection>
* saves "Photos App" metadata in Lightroom
* saves "Photos app" metadata in Lightroom
* Lightroom catalog: The name of lightroom catalog
* Lightroom ID: The internal Lightroom id
* Format: The format (i.e. extension of the Photos file)
* Format: The format of the Photos file
* Photos UUID: The unique Photos ID
When creating a new publishing service, there are three predefined options which are not default by Adobe:
* Quality for JPEGs is 85% not 60%
* Person info will NOT be removed from metadata
* Location info will NOT be removed from metadata
Remarks: If you don't export videos as original the create date of the video will be set to the current date.
Remarks: If you don't export videos as original, the create-date of the video will be set to the current date.
Of course, you may change these settings for your service definition.
### Re-Publishing
The re-publishing process…
* puts re-published photos into the same albums as their predecessors.
* puts tag __LR:out-of-date__ on the predecessor
* puts tag __lr:out-of-date__ on the predecessor
* removes out-of-date photos if collection configuration __Keep out of date photos in albums__ is un-checked.
### Remove photos from publishing service
* Removes the photo from the Photos album.
* Set tag __LR:no-longer-published__ to the current media item in Photos if it is no longer used in any album
* Set back the Photos ID in Lightroom, if the photo is no longer used in any album.
* Set tag __lr:no-longer-published__ to the current media item in Photos if it is no longer used in any album
* Set back the Photos metadata in Lightroom, if the photo is no longer used in any album.
### Deleting collections
Deleting collections and removing photos from the Photos app is currently not supported.
### Configuration
The __Use Album__ configuration in the publishing service setup defines the name of the album where photos are imported in.
Expand Down Expand Up @@ -116,14 +119,50 @@ The applescript interface for Photos.app is restricted:
recreated if __Keep out of date photos in albums__ is unchecked.
### Update albums
You must delete "old" photos manually after a re-publish.
Therefore, a smart album helps which filters by LR:out-of-date tag and may be by LR:<catalog name> as well.
You can delete "old" photos manually after a re-publish.
Therefore, a smart album helps which filters by lr:out-of-date tag and may be by lr:<catalog name> as well.
### Update smart albums
If you are using shared albums, you must manually add the updated photos into these albums. Therefore, a second
smart album is helpful which filters by the date, when photos were added to Photos.app.
## Maintenance
Three menu action under Library/Plug-In Extras
* Reset Photos app Attributes
* Search extra Photos in Photos app
* Search missing Photos in Photos app
### Reset Photos App Attributes
This action deletes the 4 metadata values on the selected photos. The action may be helpful if you want to delete a lot
of published photos manually and you do not want to use the normal removal process.
### Search extra Photos in Photos App
This action searches for Photos app media items that still have a lr:catalog-name keyword, but they are no longer
published
in Lightroom. This happens, when you delete a published collection, or when the publish process runs into a timeout (see
[Known Issues](#known-issues))
The action adds the additional photos found to the album Photos /Lightroom/Extra Photos.
You do not need to select any photos for this action. All photos will be included that have the Photos UUID metadata
set.
### Search missing Photos in Photos App
This action searches for published photos in Lightroom for which no photo can be found in the Photos app. Missing photos
occur when published photos were deleted manually in the Photos app. The action adds the missing photos in the
Lightroom collection /Photos app/Missing in Photos.
The search will be only done for the selected photos (unpublished photos will be ignored).
## Known issues
* When adding a lot of photos, or when you update a large album, Photos displays a modal dialog, to inform you that many
photos were added. Since the Photos app window may not be in the foreground, you miss this dialog and after a timeout the
publish action fails.
.
## Acknowledgements
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ on processExtraPhotos(comDir, catalogNames, albumName)
if (count of extraMediaItems) is greater than 0 then
tell script "hbPhotosUtilities" to set targetAlbum to album by path albumName with create if not exists
tell application "Photos"
activate
add extraMediaItems to targetAlbum
spotlight targetAlbum
end tell
Expand Down
28 changes: 24 additions & 4 deletions src/main/lrphotos.lrdevplugin/PhotosPublishTask.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local editionDetailsID = "at.homebrew.lreditiondetails"

PhotosPublishTask = {}

local LrMobdebug = import 'LrMobdebug' -- Import LR/ZeroBrane debug module
-- local LrMobdebug = import 'LrMobdebug' -- Import LR/ZeroBrane debug module
--[[---------------------------------------------------------------------------
local functions
-----------------------------------------------------------------------------]]
Expand Down Expand Up @@ -377,8 +377,6 @@ end
function PhotosPublishTask.processRenderedPhotos(_, exportContext)
logger.trace("PhotosPublishTask.processRenderedPhotos start")
logger.trace("collection=" .. exportContext.publishedCollectionInfo.name)
LrMobdebug.start()
LrMobdebug.on()

local albumPath = getFullAlbumPath(
exportContext.propertyTable.albumBy,
Expand Down Expand Up @@ -562,6 +560,18 @@ function PhotosPublishTask.deletePhotosFromPublishedCollection(publishSettings,

end

--[[---------------------------------------------------------------------------
deletePublishedCollection
-----------------------------------------------------------------------------]]
function PhotosPublishTask.deletePublishedCollection( publishSettings, info )
LrDialogs.message(LOC("$$$/Photos/Msg/Title/DeletePublishedCollection=Deleting collection"),
LOC("$$$/Photos/Msg/DeletePublishedCollection=Deleting collections and removing photos from the Photos app is currently not supported."))
error(LOC("$$$/Photos/Msg/DeletePublishedCollection=Deleting collections and removing photos from the Photos app is currently not supported."))
end

--[[---------------------------------------------------------------------------
showPhoto
-----------------------------------------------------------------------------]]
local function showPhoto(thePhoto)
local photoId = PhotosAPI.getPhotosId(thePhoto)
local queueEntry = createQueueEntry("Show photo " .. photoId)
Expand All @@ -579,13 +589,20 @@ local function showPhoto(thePhoto)
return result
end

--[[---------------------------------------------------------------------------
goToPublishedPhoto
-----------------------------------------------------------------------------]]
function PhotosPublishTask.goToPublishedPhoto( publishSettings, info )
logger.trace("goToPublishedPhoto() start")
showPhoto(info.photo)
logger.trace("goToPublishedPhoto() end")
end

function showCollection(publishSettings, info)
--[[---------------------------------------------------------------------------
showCollection
-----------------------------------------------------------------------------]]

local function showCollection(publishSettings, info)
local albumPath = getFullAlbumPath(
publishSettings.albumBy,
publishSettings.useAlbum,
Expand All @@ -608,6 +625,9 @@ function showCollection(publishSettings, info)
return result

end
--[[---------------------------------------------------------------------------
goToPublishedCollection
-----------------------------------------------------------------------------]]
function PhotosPublishTask.goToPublishedCollection( publishSettings, info )
logger.trace("goToPublishedCollection() start")
showCollection(publishSettings, info)
Expand Down
1 change: 1 addition & 0 deletions src/main/lrphotos.lrdevplugin/PhotosServiceProvider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local PhotosServiceProvider = {
viewForCollectionSettings = PhotosPublishTask.viewForCollectionSettings,
viewForCollectionSetSettings = PhotosPublishTask.viewForCollectionSetSettings,
deletePhotosFromPublishedCollection = PhotosPublishTask.deletePhotosFromPublishedCollection,
deletePublishedCollection= PhotosPublishTask.deletePublishedCollection,
titleForGoToPublishedPhoto=LOC "$$$/Photos/TitleForGoToPublishedPhoto=Show in Photos",
titleForGoToPublishedCollection = LOC "$$$/Photos/TitleForGoToPublishedCollection=Show album in Photos",
goToPublishedPhoto=PhotosPublishTask.goToPublishedPhoto,
Expand Down
3 changes: 0 additions & 3 deletions src/main/lrphotos.lrdevplugin/SearchExtraPhotosInPhotos.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,16 @@ local function sendPhotosToApp(action, maintenanceDir, catalogNames, albumName)

local command = ""
LrFileUtils.delete(maintenanceDir .. "/fromPhotos/photos.txt")
logger.trace("1")
local exePathDev = _PLUGIN.path .. "/" .. "PhotosMaintenance/PhotosMaintenance.app"
local exePathProd = _PLUGIN.path .. "/" .. "PhotosMaintenance.app"
logger.trace("exePathDev=" .. tostring(exePathDev))
if LrFileUtils.exists(exePathDev) then
logger.trace("2")
command = "osascript \"" .. exePathDev .. "\""
.. " " .. action
.. " \"" .. maintenanceDir .. "\""
.. " \"" .. catalogNames .. "\""
.. " \"" .. albumName .. "\""
else
logger.trace("3")
command = "osascript \"" .. exePathProd .. "\""
.. " " .. action
.. " \"" .. maintenanceDir .. "\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,14 @@ local function sendPhotosToApp(action, maintenanceDir)

local command = ""
LrFileUtils.delete(maintenanceDir .. "/fromPhotos/photos.txt")
logger.trace("1")
local exePathDev = _PLUGIN.path .. "/" .. "PhotosMaintenance/PhotosMaintenance.app"
local exePathProd = _PLUGIN.path .. "/" .. "PhotosMaintenance.app"
logger.trace("exePathDev=" .. tostring(exePathDev))
if LrFileUtils.exists(exePathDev) then
logger.trace("2")
command = "osascript \"" .. exePathDev .. "\" "
.. action
.. " \"" .. maintenanceDir .. "\""
else
logger.trace("3")
command = "osascript \"" .. exePathProd .. "\" "
.. action
.. " \"" .. maintenanceDir .. "\""
Expand Down
3 changes: 3 additions & 0 deletions src/main/lrphotos.lrdevplugin/TranslatedStrings_de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@
"$$$/Photos/Error/ExtraPhotos=Fehler in Fotos App bei der Suche nach fehlenden Referenzen."
"$$$/Photos/MsgError/GeneralError=Fehler bei der Suche nach überzähligen Fotos. Meldung war: ^1"
"$$$/Photos/MsgError/ExtraPhotosFound=^1 überzählige(s) Foto(s) gefunden. Siehe Album '^2 für eine Liste von extra Fotos."
"$$$/Photos/Progress/DeletePublishedCollection=Lösche publizierte Sammlung ^[^1^]"
"$$$/Photos/Msg/DeletePublishedCollection=Das Löschen von Sammlungen und das Entfernen von Fotos aus der Fotos-App wird derzeit nicht unterstützt."
"$$$/Photos/Msg/Title/DeletePublishedCollection=Löschen Sammlung"
4 changes: 4 additions & 0 deletions src/main/lrphotos.lrdevplugin/TranslatedStrings_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@
"$$$/Photos/MsgError/GeneralErrorExtra=Error while searching for extra photos. Message was: ^1"
"$$$/Photos/MsgError/GeneralErrorMissing=Error while searching for missing references. Message was: ^1"
"$$$/Photos/MsgError/ExtraPhotosFound=^1 extra photo(s) found. See album '^2' for a list of extra photos."
"$$$/Photos/Progress/DeletePublishedCollection=Deleting published collection ^[^1^]"
"$$$/Photos/Msg/Title/DeletePublishedCollection=Deleting collection"
"$$$/Photos/Msg/DeletePublishedCollection=Deleting collections and removing photos from the Photos app is currently not supported."

Binary file not shown.

0 comments on commit e781a14

Please sign in to comment.