Skip to content

Commit 1d74d0c

Browse files
authored
Merge pull request #100 from Salvoxia/readme/massUpdatingAlbums
Readme Enhancements
2 parents eefcae8 + 1624d55 commit 1d74d0c

File tree

2 files changed

+133
-13
lines changed

2 files changed

+133
-13
lines changed

README.md

Lines changed: 131 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ This script is mostly based on the following original script: [REDVM/immich_auto
2727
8. [Assets in Multiple Albums](#assets-in-multiple-albums)
2828
9. [Setting Album Thumbnails](#setting-album-thumbnails)
2929
10. [Setting Album-Fine Properties](#setting-album-fine-properties)
30-
11. [Automatic Archiving](#automatic-archiving)
31-
12. [Dealing with External Library Changes](#dealing-with-external-library-changes)
30+
11. [Mass Updating Album Properties](#mass-updating-album-properties)
31+
12. [Automatic Archiving](#automatic-archiving)
32+
13. [Dealing with External Library Changes](#dealing-with-external-library-changes)
3233

3334
## Usage
3435
### Bare Python Script
@@ -115,8 +116,6 @@ This script is mostly based on the following original script: [REDVM/immich_auto
115116
Timeout when requesting Immich API in seconds (default: 20)
116117
--comments-and-likes-enabled
117118
Pass this argument to enable comment and like functionality in all albums this script adds assets to. Cannot be used together with --comments-and-likes-disabled (default: False)
118-
--comments-and-likes-disabled
119-
Pass this argument to disable comment and like functionality in all albums this script adds assets to. Cannot be used together with --comments-and-likes-enabled (default: False)
120119
--update-album-props-mode
121120
Change how album properties are updated whenever new assets are added to an album. Album properties can either come from script arguments or the `.albumprops` file. Possible values:
122121
0 = Do not change album properties.
@@ -439,17 +438,33 @@ Two arguments control this feature:
439438
440439
To share new albums with users `User A` and `User B` as `viewer`, use the following call:
441440
```bash
442-
python3 ./immich_auto_album.py --share-with "User A" --share-with "User B" /path/to/external/lib https://immich.mydomain.com/api thisIsMyApiKeyCopiedFromImmichWebGui
441+
python3 ./immich_auto_album.py \
442+
--share-with "User A" \
443+
--share-with "User B" \
444+
/path/to/external/lib \
445+
https://immich.mydomain.com/api \
446+
thisIsMyApiKeyCopiedFromImmichWebGui
443447
```
444448
445449
To share new albums with users `User A` and `User B` as `editor`, use the following call:
446450
```bash
447-
python3 ./immich_auto_album.py --share-with "User A" --share-with "User B" --share-role "editor" /path/to/external/lib https://immich.mydomain.com/api thisIsMyApiKeyCopiedFromImmichWebGui
451+
python3 ./immich_auto_album.py \
452+
--share-with "User A" \
453+
--share-with "User B" \
454+
--share-role "editor" \
455+
/path/to/external/lib \
456+
https://immich.mydomain.com/api \
457+
thisIsMyApiKeyCopiedFromImmichWebGui
448458
```
449459
450460
To share new albums with users `User A` and a user with mail address `userB@mydomain.com`, but `User A` should be an editor, use the following call:
451461
```bash
452-
python3 ./immich_auto_album.py --share-with "User A=editor" --share-with "userB@mydomain.com" /path/to/external/lib https://immich.mydomain.com/api thisIs
462+
python3 ./immich_auto_album.py \
463+
--share-with "User A=editor" \
464+
--share-with "userB@mydomain.com" \
465+
path/to/external/lib \
466+
https://immich.mydomain.com/api \
467+
thisIs
453468
```
454469
455470
Per default these share settings are applied once when the album is created and remain unchanged if an asset is added to an album later. If you want to override the share state whenever an asset is added to an album you can set `--update-album-props-mode` to `2`. Note that this will completely override all shared users, any changes made within Immich will be lost.
@@ -461,17 +476,39 @@ Two environment variables control this feature:
461476
462477
To share new albums with users `User A` and `User B` as `viewer`, use the following call:
463478
```bash
464-
docker run -e SHARE_WITH="User A:User B" -e UNATTENDED="1" -e API_URL="https://immich.mydomain.com/api/" -e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e ROOT_PATH="/external_libs/photos" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh
479+
docker run \
480+
-e SHARE_WITH="User A:User B" \
481+
-e UNATTENDED="1" \
482+
-e API_URL="https://immich.mydomain.com/api/" \
483+
-e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
484+
-e ROOT_PATH="/external_libs/photos" \
485+
salvoxia/immich-folder-album-creator:latest \
486+
/script/immich_auto_album.sh
465487
```
466488
467489
To share new albums with users `User A` and `User B` as `editor`, use the following call:
468490
```bash
469-
docker run -e SHARE_WITH="User A:User B" -e SHARE_ROLE="editor" -e UNATTENDED="1" -e API_URL="https://immich.mydomain.com/api/" -e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e ROOT_PATH="/external_libs/photos" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh
491+
docker run \
492+
-e SHARE_WITH="User A:User B" \
493+
-e SHARE_ROLE="editor" \
494+
-e UNATTENDED="1" \
495+
-e API_URL="https://immich.mydomain.com/api/" \
496+
-e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
497+
-e ROOT_PATH="/external_libs/photos" \
498+
salvoxia/immich-folder-album-creator:latest \
499+
/script/immich_auto_album.sh
470500
```
471501
472502
To share new albums with users `User A` and a user with mail address `userB@mydomain.com`, but `User A` should be an editor, use the following call:
473503
```bash
474-
docker run -e SHARE_WITH="User A=editor:userB@mydomain.com" -e UNATTENDED="1" -e API_URL="https://immich.mydomain.com/api/" -e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e ROOT_PATH="/external_libs/photos" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh
504+
docker run \
505+
-e SHARE_WITH="User A=editor:userB@mydomain.com" \
506+
-e UNATTENDED="1" \
507+
-e API_URL="https://immich.mydomain.com/api/" \
508+
-e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
509+
-e ROOT_PATH="/external_libs/photos" \
510+
salvoxia/immich-folder-album-creator:latest \
511+
/script/immich_auto_album.sh
475512
```
476513
477514
Per default these share settings are applied once when the album is created and remain unchanged if an asset is added to an album later. If you want to override the share state whenever an asset is added to an album you can set `UPDATE_ALBUM_PROPS_MODE` to `2`. Note that this will completely override all shared users, any changes made within Immich will be lost.
@@ -580,6 +617,54 @@ share_with:
580617
```
581618
If the script is called with `--share-with "Mom"` and `--archive`, the album created from the folder the file above resides in will only be shared with user `Dad` using `editor` permissions, and assets will be archived. All other albums will be shared with user `Mom` (using `viewer` permissions, as defined by default) and assets will be archived.
582619
620+
## Mass Updating Album Properties
621+
622+
The script supports updating album properties after the fact, i.e. after they already have been created. Useful examples for this are mass sharing albums or enabling/disabling the "Comments and Likes" functionality. All album properties supported by `.albumprops` files (Refer to [Setting Album-Fine Properties](#setting-album-fine-properties)) are supported. They can be provided either by placing an `.albumprops` file in each folder, or by passing the appropriate argument to the script.
623+
Updating already existing albums is done by setting the `--find-assets-in-albums` argument (or appropriate [environment variable](#environment-variables)) to discover assets that are already assigned to albums, and also setting the `--update-album-props-mode` argument ((or appropriate [environment variable](#environment-variables))).
624+
When setting `--update-album-props-mode` to `1`, all album properties __except__ the shared status are updated. When setting it to `2`, the shared status is updated as well.
625+
By applying `--path-filter` and/or `--ignore` options, it is possible to get a more fine granular control over the albums to update.
626+
627+
>[!IMPORTANT]
628+
> The shared status is always updated to match exactly the users and roles provided to the script, the changes are not additive.
629+
630+
### Examples:
631+
1. Share all albums (either existing or newly ) created from a `Birhtdays` folder with users `User A` and `User B`:
632+
```bash
633+
python3 ./immich_auto_album.py \
634+
--find-assets-in-albums \
635+
--update-album-props-mode 2 \
636+
--share-with "User A" \
637+
--share-with "User B" \
638+
--path-filter "Birthdays/**" \
639+
/path/to/external/lib \
640+
https://immich.mydomain.com/api \
641+
thisIsMyApiKeyCopiedFromImmichWebGui
642+
```
643+
644+
To unshare the same albums simply run the same command without the `--share-with` arguments. The script will make sure all identified albums are shared with all people passed in `--share-with`, that is no-one.
645+
```bash
646+
python3 ./immich_auto_album.py \
647+
--find-assets-in-albums \
648+
--update-album-props-mode 2 \
649+
--path-filter "Birthdays/**" \
650+
/path/to/external/lib \
651+
https://immich.mydomain.com/api \
652+
thisIsMyApiKeyCopiedFromImmichWebGui
653+
```
654+
655+
2. Disable comments and likes in all albums but the ones created from a `Birthdays` folder, without changing the "shared with" settings:
656+
```bash
657+
python3 ./immich_auto_album.py \
658+
--find-assets-in-albums \
659+
--update-album-props-mode 1 \
660+
--disable-comments-an-likes \
661+
--ignore "Birthdays/**" \
662+
/path/to/external/lib \
663+
https://immich.mydomain.com/api \
664+
thisIsMyApiKeyCopiedFromImmichWebGui
665+
```
666+
667+
583668
## Automatic Archiving
584669
585670
In Immich, 'archiving' an image means to hide it from the main timeline.
@@ -619,6 +704,41 @@ Option `2` will first delete all "offline" assets automatically, then do the sam
619704
620705
It is up to you whether you want to use the full capabilities Sync Mode offers, parts of it or none.
621706
An example for the Immich `docker-compose.yml` stack when using full Sync Mode might look like this:
707+
708+
### `docker-compose` example passing the API key as environment variable
709+
```yml
710+
#
711+
# WARNING: Make sure to use the docker-compose.yml of the current release:
712+
#
713+
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
714+
#
715+
# The compose file on main may not be compatible with the latest release.
716+
#
717+
718+
name: immich
719+
720+
services:
721+
immich-server:
722+
container_name: immich_server
723+
volumes:
724+
- /path/to/my/photos:/external_libs/photos
725+
...
726+
immich-folder-album-creator:
727+
container_name: immich_folder_album_creator
728+
image: salvoxia/immich-folder-album-creator:latest
729+
restart: unless-stopped
730+
environment:
731+
API_URL: http://immich_server:2283/api
732+
API_KEY: "This_Is_My_API_Key_Generated_In_Immich"
733+
ROOT_PATH: /external_libs/photos
734+
# Run every full hour
735+
CRON_EXPRESSION: "0 * * * *"
736+
TZ: Europe/Berlin
737+
# Remove offline assets and delete empty albums after each run
738+
SYNC_MODE: "2"
739+
```
740+
741+
### `docker-compose` example using a secrets file for the API key
622742
```yml
623743
#
624744
# WARNING: Make sure to use the docker-compose.yml of the current release:
@@ -645,6 +765,7 @@ services:
645765
API_URL: http://immich_server:2283/api
646766
API_KEY_FILE: "/immich_api_key.secret"
647767
ROOT_PATH: /external_libs/photos
768+
# Run every full hour
648769
CRON_EXPRESSION: "0 * * * *"
649770
TZ: Europe/Berlin
650771
# Remove offline assets and delete empty albums after each run

immich_auto_album.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,10 +1693,9 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
16931693
parser.add_argument("--api-timeout", default=REQUEST_TIMEOUT_DEFAULT, type=int, help="Timeout when requesting Immich API in seconds")
16941694
parser.add_argument("--comments-and-likes-enabled", action="store_true",
16951695
help="Pass this argument to enable comment and like functionality in all albums this script adds assets to. Cannot be used together with --comments-and-likes-disabled")
1696-
parser.add_argument("--comments-and-likes-disabled", action="store_true",
1697-
help="Pass this argument to disable comment and like functionality in all albums this script adds assets to. Cannot be used together with --comments-and-likes-enabled")
16981696
parser.add_argument("--update-album-props-mode", type=int, choices=[0, 1, 2], default=0,
1699-
help="""Change how album properties are updated whenever new assets are added to an album. Album properties can either come from script arguments or the .albumprops file. Possible values:
1697+
help="""Change how album properties are updated whenever new assets are added to an album. Album properties can either come from script arguments or the .albumprops file.
1698+
Possible values:
17001699
0 = Do not change album properties.
17011700
1 = Only override album properties but do not change the share status.
17021701
2 = Override album properties and share status, this will remove all users from the album which are not in the SHARE_WITH list.""")

0 commit comments

Comments
 (0)