Skip to content

Commit f6c6e7e

Browse files
authored
Merge pull request #90 from Salvoxia/enhancement/disableAlbumCommmentsLikes
Enhancement/disable album commments likes
2 parents 4c40aa0 + bf39e5f commit f6c6e7e

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ good-names=e,ex,id,r,i,j
99
max-line-length=200
1010

1111
# Maximum number of lines in a module
12-
max-module-lines=2000
12+
max-module-lines=2500

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ This script is mostly based on the following original script: [REDVM/immich_auto
113113
If set, the script tries to access all passed root paths and recursively search for .albumprops files in all contained folders. These properties will be used to set custom options on an per-album level. Check the readme for a complete documentation. (default: False)
114114
--api-timeout API_TIMEOUT
115115
Timeout when requesting Immich API in seconds (default: 20)
116+
--comments-and-likes-enabled
117+
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)
116120
```
117121
118122
__Plain example without optional arguments:__
@@ -169,6 +173,7 @@ The environment variables are analoguous to the script's command line arguments.
169173
| FIND_ARCHIVED_ASSETS | no | By default, the script only finds assets that are not archived in Immich. Set this option make the script discover assets that are already archived. If -A/--find-assets-in-albums is set as well, both options apply. (default: `False`)<br>Refer to [Automatic Archiving](#automatic-archiving). |
170174
| READ_ALBUM_PROPERTIES | no | Set to `True` to enable discovery of `.albumprops` files in root paths, allowing to set different album properties for differnt albums. (default: `False`)<br>Refer to [Setting Album-Fine Properties](#setting-album-fine-properties). |
171175
| API_TIMEOUT | no | Timeout when requesting Immich API in seconds (default: `20`) |
176+
| COMMENTS_AND_LIKES | no | Set to `1` to explicitly enable Comments & Likes functionality for all albums this script adds assets to, set to `0` to disable. If not set, this setting is left alone by the script. |
172177
173178
#### Run the container with Docker
174179

docker/immich_auto_album.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,11 @@ if [ ! -z "$API_TIMEOUT" ]; then
149149
args="--api-timeout \"$API_TIMEOUT\" $args"
150150
fi
151151

152+
if [ "$COMMENTS_AND_LIKES" == "1" ]; then
153+
args="--comments-and-likes-enabled $args"
154+
elif [ "$COMMENTS_AND_LIKES" == "0" ]; then
155+
args="--comments-and-likes-disabled $args"
156+
fi
157+
152158
BASEDIR=$(dirname "$0")
153159
echo $args | xargs python3 -u $BASEDIR/immich_auto_album.py

immich_auto_album.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,12 @@ def set_album_properties_in_model(album_model_to_update: AlbumModel):
15201520
if album_order:
15211521
album_model_to_update.sort_order = album_order
15221522

1523+
# Comments and Likes
1524+
if comments_and_likes_enabled:
1525+
album_model_to_update.comments_and_likes_enabled = True
1526+
elif comments_and_likes_disabled:
1527+
album_model_to_update.comments_and_likes_enabled = False
1528+
15231529
def build_album_list(asset_list : list[dict], root_path_list : list[str], album_props_templates: dict) -> dict:
15241530
"""
15251531
Builds a list of album models, enriched with assets assigned to each album.
@@ -1685,6 +1691,10 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
16851691
help="""If set, the script tries to access all passed root paths and recursively search for .albumprops files in all contained folders.
16861692
These properties will be used to set custom options on an per-album level. Check the readme for a complete documentation.""")
16871693
parser.add_argument("--api-timeout", default=REQUEST_TIMEOUT_DEFAULT, type=int, help="Timeout when requesting Immich API in seconds")
1694+
parser.add_argument("--comments-and-likes-enabled", action="store_true",
1695+
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")
16881698

16891699

16901700
args = vars(parser.parse_args())
@@ -1720,6 +1730,11 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
17201730
find_archived_assets = args["find_archived_assets"]
17211731
read_album_properties = args["read_album_properties"]
17221732
api_timeout = args["api_timeout"]
1733+
comments_and_likes_enabled = args["comments_and_likes_enabled"]
1734+
comments_and_likes_disabled = args["comments_and_likes_disabled"]
1735+
if comments_and_likes_disabled and comments_and_likes_enabled:
1736+
logging.fatal("Arguments --comments-and-likes-enabled and --comments-and-likes-disabled cannot be used together! Choose one!")
1737+
sys.exit(1)
17231738

17241739
# Override unattended if we're running in destructive mode
17251740
if mode != SCRIPT_MODE_CREATE:
@@ -1753,6 +1768,8 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
17531768
logging.debug("find_archived_assets = %s", find_archived_assets)
17541769
logging.debug("read_album_properties = %s", read_album_properties)
17551770
logging.debug("api_timeout = %s", api_timeout)
1771+
logging.debug("comments_and_likes_enabled = %s", comments_and_likes_enabled)
1772+
logging.debug("comments_and_likes_disabled = %s", comments_and_likes_disabled)
17561773

17571774
# Verify album levels
17581775
if is_integer(album_levels) and album_levels == 0:

0 commit comments

Comments
 (0)