Skip to content

Commit

Permalink
Add collection configuration "Keep no longer published photos in albums"
Browse files Browse the repository at this point in the history
  • Loading branch information
sto3014 committed Nov 10, 2024
1 parent c512856 commit 7f066f3
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,10 @@ rendition is marked as skipped.
### Added

* Add preference Truncate Version. If set to true the version in the catalog name will be truncated.

## [2.1.2.0]

### Added

* Add collection configuration "Keep no longer published photos in albums". If set to false (default value) photos will
be removed from Photos app if they are removed from collection, otherwise photos must be removed from album manually.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ LRPhotos is a Lightroom Classic publishing service for Apple's Photos app.
* MacOS 10.10 (Yosemite) or later.
* Windows is not supported.

## Installation
## Installaftion

---

1. Download the zip archive from [GitHub](https://github.com/sto3014/LRPhotos/blob/main/target/LRPhotos2.1.1.0_mac.zip).
1. Download the zip archive from [GitHub](https://github.com/sto3014/LRPhotos/blob/main/target/LRPhotos2.1.2.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 Down Expand Up @@ -74,10 +74,13 @@ The re-publishing process…
* puts re-published photos into the same albums as their predecessors.
* 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.
* removes photos that were removed from publish service if collection configuration __Keep no longer published photos in
albums__ is unchecked.
### Remove photos from publishing service
* Removes the photo from the Photos album.
* Removes the photo from the Photos album if collection configuration __Keep no longer published photos in albums__ is
unchecked.
* 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.
Expand Down
2 changes: 1 addition & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export SOURCE_DIR=$SCRIPT_DIR/src/main/$PACKAGE_NAME.lrdevplugin
export SOURCE_DIR_SERVICES=/Users/dieterstockhausen/Projekte/Automation/Services
export SOURCE_DIR_SCRIPT_LIBRARIES="/Users/dieterstockhausen/Projekte/Automation/Script Libraries/src"
export RESOURCE_DIR=$SCRIPT_DIR/res
export VERSION=2.1.1.0
export VERSION=2.1.2.0
#
# mac
#
Expand Down
2 changes: 1 addition & 1 deletion src/main/lrphotos.lrdevplugin/Info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ return {

LrPluginName = 'Photos',
LrToolkitIdentifier = 'at.homebrew.lrphotos',
VERSION = { major = 2, minor = 1, revision = 1, build = 0, },
VERSION = { major = 2, minor = 1, revision = 2, build = 0, },
LrInitPlugin = "InitPlugin.lua",
-- Add the Metadata Definition File
LrMetadataProvider = 'PhotosMetadataDefinition.lua',
Expand Down
11 changes: 9 additions & 2 deletions src/main/lrphotos.lrdevplugin/PhotosImport.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end getMode
-------------------------------------------------------------------------------
on getSession(sessionContents)
local session
set session to {mode:"", albumName:"", ignoreByRegex:"", hasErrors:false, errorMsg:"", exportDone:false, keepOldPhotos:true} as record
set session to {mode:"", albumName:"", ignoreByRegex:"", hasErrors:false, errorMsg:"", exportDone:false, keepOldPhotos:true, keepNoLongerPublishedPhotos:true} as record
local allLines
set allLines to every paragraph of sessionContents
repeat with aLine in allLines
Expand Down Expand Up @@ -117,6 +117,10 @@ on getSession(sessionContents)
else
if aKey is equal to "keepOldPhotos" then
set keepOldPhotos of session to value is equal to "true"
else
if aKey is equal to "keepNoLongerPublishedPhotos" then
set keepNoLongerPublishedPhotos of session to value is equal to "true"
end if
end if
end if
end if
Expand Down Expand Up @@ -667,7 +671,9 @@ on remove(photoDescriptors, session)
end try
end repeat
--
tell me to set targetAlbum to removePhotosFromAlbum(targetAlbum, photosToBeRemovedFromAlbum)
if not keepNoLongerPublishedPhotos of session then
tell me to set targetAlbum to removePhotosFromAlbum(targetAlbum, photosToBeRemovedFromAlbum)
end if
end tell
log message "remove() end"
set AppleScript's text item delimiters to ""
Expand Down Expand Up @@ -696,6 +702,7 @@ on updateSessionFile(sessionFile, session)
"ignoreByRegex=" & ignoreByRegex of session & linefeed & ¬
"hasErrors=" & hasErrors of session & linefeed & ¬
"keepOldPhotos=" & keepOldPhotos of session & linefeed & ¬
"keepNoLongerPublishedPhotos=" & keepNoLongerPublishedPhotos of session & linefeed & ¬
"errorMsg=" & errorMsg of session
set utf8Content to transform macroman text romanContent to UTF8
write utf8Content to sessionFile
Expand Down
17 changes: 6 additions & 11 deletions src/main/lrphotos.lrdevplugin/PhotosPublishDialogSections.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,17 @@ function PhotosPublishDialogSections.sectionsForBottomOfDialog( f, _ )
},
},
f:row {
-- f:spacer
-- width = share 'labelWidth'
-- },

--[[
f:static_text({
title = LOC("$$$/Photos/KeepOldPhotos=Keep out of date photos in albums:"),
width_in_chars = 25,
}),
]]--

f:checkbox {
title = LOC "$$$/Photos/KeepOldPhotos=Keep out of date photos in albums.",
value = bind 'keepOldPhotos',
},
},
f:row {
f:checkbox {
title = LOC "$$$/Photos/KeepNoLongerPublishedPhotos=Keep no longer published photos in albums.",
value = bind 'keepNoLongerPublishedPhotos',
},
},
},
}

Expand Down
15 changes: 12 additions & 3 deletions src/main/lrphotos.lrdevplugin/PhotosPublishTask.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ end
--[[---------------------------------------------------------------------------
-----------------------------------------------------------------------------]]
local function writeSessionFile(albumPath, ignoreAlbums, ignoreRegex, mode, keepOldPhotos)
local function writeSessionFile(albumPath, ignoreAlbums, ignoreRegex, mode, keepOldPhotos, keepNoLongerPublishedPhotos)
-- Write Lightroom input to a session.txt file for AppleScript later on
logger.trace("sessionFile=" .. Utils.getSessionFile(albumPath))
local f = assert(io.open(Utils.getSessionFile(albumPath), "w+"))
f:write("mode=" .. mode .. "\n")
f:write("exportDone=false\n")
f:write("albumName=" .. albumPath .. "\n")
f:write("keepOldPhotos=" .. tostring(keepOldPhotos) .. "\n")
f:write("keepNoLongerPublishedPhotos=" .. tostring(keepNoLongerPublishedPhotos) .. "\n")

if ignoreAlbums == true then
f:write("ignoreByRegex=" .. ignoreRegex .. "\n")
Expand Down Expand Up @@ -421,7 +422,8 @@ function PhotosPublishTask.processRenderedPhotos(_, exportContext)
exportContext.propertyTable.ignoreAlbums,
exportContext.propertyTable.ignoreRegex,
"publish",
exportContext.propertyTable.keepOldPhotos
exportContext.propertyTable.keepOldPhotos,
exportContext.propertyTable.keepNoLongerPublishedPhotos
)


Expand Down Expand Up @@ -510,7 +512,14 @@ function PhotosPublishTask.deletePhotosFromPublishedCollection(publishSettings,
return
end

writeSessionFile(albumPath, publishSettings.ignoreAlbums, publishSettings.ignoreRegex, "remove", publishSettings.keepOldPhotos)
writeSessionFile(
albumPath,
publishSettings.ignoreAlbums,
publishSettings.ignoreRegex,
"remove",
publishSettings.keepOldPhotos,
publishSettings.keepNoLongerPublishedPhotos)

local activeCatalog = LrApplication.activeCatalog()
local catName = LrPathUtils.leafName(activeCatalog:getPath())

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 @@ -18,6 +18,7 @@ local PhotosServiceProvider = {
{ key = 'ignoreRegex', default = "^!|!$" },
{ key = 'rootFolder', default = "/" },
{ key = 'keepOldPhotos', default = true },
{ key = 'keepNoLongerPublishedPhotos', default = false},
},
canExportVideo = true,
sectionsForBottomOfDialog = PhotosPublishDialogSections.sectionsForBottomOfDialog,
Expand Down
1 change: 1 addition & 0 deletions src/main/lrphotos.lrdevplugin/TranslatedStrings_de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@
"$$$/Photos/PluginSettings=Plug-in Einstellungen"
"$$$/Photos/CatalogName=Lightroom Katalog"
"$$$/Photos/CatalogName/TruncateVersion=Entferne Version"
"$$$/Photos/KeepNoLongerPublishedPhotos=Behalte nicht mehr publizierte Fotos in den Alben."
1 change: 1 addition & 0 deletions src/main/lrphotos.lrdevplugin/TranslatedStrings_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"$$$/Photos/PluginSettings=Plug-in Settings"
"$$$/Photos/CatalogName=Lightroom Catalog"
"$$$/Photos/CatalogName/TruncateVersion=Truncate Version"
"$$$/Photos/KeepNoLongerPublishedPhotos=Keep no longer published photos in albums."


Binary file removed target/LRPhotos2.1.1.0_mac.zip
Binary file not shown.
Binary file added target/LRPhotos2.1.2.0_mac.zip
Binary file not shown.

0 comments on commit 7f066f3

Please sign in to comment.