You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: immich_auto_album.py
+95-18Lines changed: 95 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,25 @@
4
4
importlogging
5
5
importsys
6
6
importdatetime
7
+
importarrayasarr
7
8
fromcollectionsimportdefaultdict
8
9
10
+
# Trying to deal with python's isnumeric() function
11
+
# not recognizing negative numbers
12
+
defis_integer(str):
13
+
try:
14
+
int(str)
15
+
returnTrue
16
+
exceptValueError:
17
+
returnFalse
9
18
10
19
parser=argparse.ArgumentParser(description="Create Immich Albums from an external library path based on the top level folders", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
11
20
parser.add_argument("root_path", action='append', help="The external libarary's root path in Immich")
12
21
parser.add_argument("api_url", help="The root API URL of immich, e.g. https://immich.mydomain.com/api/")
13
22
parser.add_argument("api_key", help="The Immich API Key to use")
14
23
parser.add_argument("-r", "--root-path", action="append", help="Additional external libarary root path in Immich; May be specified multiple times for multiple import paths or external libraries.")
15
24
parser.add_argument("-u", "--unattended", action="store_true", help="Do not ask for user confirmation after identifying albums. Set this flag to run script as a cronjob.")
16
-
parser.add_argument("-a", "--album-levels", default=1, type=int, help="Number of sub-folders below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers from the bottom. Cannot be 0.")
25
+
parser.add_argument("-a", "--album-levels", default="1", type=str, help="Number of sub-folders or range of sub-folder levels below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers from the bottom. Cannot be 0. If a range should be set, the start level and end level must be separated by a comma like '<startLevel>,<endLevel>'. If negative levels are used in a range, <startLevel> must be less than or equal to <endLevel>.")
17
26
parser.add_argument("-s", "--album-separator", default=" ", type=str, help="Separator string to use for compound album names created from nested folders. Only effective if -a is set to a value > 1")
18
27
parser.add_argument("-c", "--chunk-size", default=2000, type=int, help="Maximum number of assets to add to an album with a single API call")
19
28
parser.add_argument("-C", "--fetch-chunk-size", default=5000, type=int, help="Maximum number of assets to fetch with a single API call")
or (int(album_levels_range_split[0]) >=0andint(album_levels_range_split[1]) <0)
69
+
or (int(album_levels_range_split[0]) <0andint(album_levels_range_split[1]) >=0)
70
+
or (int(album_levels_range_split[0]) <0andint(album_levels_range_split[1]) <0) andint(album_levels_range_split[0]) >int(album_levels_range_split[1])):
71
+
logging.error("Invalid album_levels range format! If a range should be set, the start level and end level must be separated by a comma like '<startLevel>,<endLevel>'. If negative levels are used in a range, <startLevel> must be less than or equal to <endLevel>.")
0 commit comments