@@ -244,7 +244,7 @@ def parse_album_properties_file(album_properties_file_path: str):
244
244
# Backward compatibility, remove when archive is removed:
245
245
if album_props_template .archive is not None :
246
246
logging .warning ("Found deprecated property archive in %s! This will be removed in the future, use visibility: archive instead!" , album_properties_file_path )
247
- if album_props_template .visibility == None :
247
+ if album_props_template .visibility is None :
248
248
album_props_template .visibility = 'archive'
249
249
# End backward compatibility
250
250
return album_props_template
@@ -739,13 +739,13 @@ def fetch_assets(is_not_in_album: bool, visibility_options: list[str]) -> list:
739
739
"""
740
740
if version ['major' ] == 1 and version ['minor' ] < 133 :
741
741
return fetch_assets_with_options ({'isNotInAlbum' : is_not_in_album , 'withArchived' : 'archive' in visibility_options })
742
- else :
743
- asset_list = fetch_assets_with_options ({'isNotInAlbum' : is_not_in_album })
744
- for visiblity_option in visibility_options :
745
- # Do not fetch agin for 'timeline', that's the default!
746
- if visiblity_option != 'timeline' :
747
- asset_list += fetch_assets_with_options ({'isNotInAlbum' : is_not_in_album , 'visibility' : visiblity_option })
748
- return asset_list
742
+
743
+ asset_list = fetch_assets_with_options ({'isNotInAlbum' : is_not_in_album })
744
+ for visiblity_option in visibility_options :
745
+ # Do not fetch agin for 'timeline', that's the default!
746
+ if visiblity_option != 'timeline' :
747
+ asset_list += fetch_assets_with_options ({'isNotInAlbum' : is_not_in_album , 'visibility' : visiblity_option })
748
+ return asset_list
749
749
750
750
def check_for_and_remove_live_photo_video_components (asset_list : list [dict ], is_not_in_album : bool , find_archived : bool ) -> list [dict ]:
751
751
"""
@@ -1452,7 +1452,7 @@ def update_album_properties(album_to_update: AlbumModel):
1452
1452
response = requests .patch (root_url + api_endpoint , json = data , ** requests_kwargs , timeout = api_timeout )
1453
1453
check_api_response (response )
1454
1454
1455
- def set_assets_visibility (asset_ids_for_visibility : list [str ], visibility : str ):
1455
+ def set_assets_visibility (asset_ids_for_visibility : list [str ], visibility_setting : str ):
1456
1456
"""
1457
1457
Sets the visibility of assets identified by the passed list of UUIDs.
1458
1458
@@ -1468,22 +1468,20 @@ def set_assets_visibility(asset_ids_for_visibility: list[str], visibility: str):
1468
1468
Exception if the API call fails
1469
1469
"""
1470
1470
api_endpoint = 'assets'
1471
- data = dict ()
1472
- data ["ids" ] = asset_ids_for_visibility
1471
+ data = {"ids" : asset_ids_for_visibility }
1473
1472
# Remove when minimum supported version is >= 133
1474
1473
if version ['major' ] == 1 and version ['minor' ] < 133 :
1475
- if visibility is not None and visibility not in ['archive' , 'timeline' ]:
1474
+ if visibility_setting is not None and visibility_setting not in ['archive' , 'timeline' ]:
1476
1475
# Warnings have been logged earlier, silently abort
1477
1476
return
1478
- else :
1479
- is_archived = True
1480
- if visibility == 'timeline' :
1481
- is_archived = False
1482
- data ["isArchived" ] = is_archived
1477
+ is_archived = True
1478
+ if visibility_setting == 'timeline' :
1479
+ is_archived = False
1480
+ data ["isArchived" ] = is_archived
1483
1481
# Up-to-date Immich Server versions
1484
1482
else :
1485
- data ["visibility" ] = visibility
1486
-
1483
+ data ["visibility" ] = visibility_setting
1484
+
1487
1485
r = requests .put (root_url + api_endpoint , json = data , ** requests_kwargs , timeout = api_timeout )
1488
1486
check_api_response (r )
1489
1487
@@ -1826,7 +1824,7 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
1826
1824
Set this option to automatically archive all assets that were newly added to albums.
1827
1825
If this option is set in combination with --mode = CLEANUP or DELETE_ALL, archived images of deleted albums will be unarchived.
1828
1826
Archiving hides the assets from Immich's timeline.""" )
1829
- # End Backward compaibility
1827
+ # End Backward compaibility
1830
1828
parser .add_argument ("--visibility" , choices = ['archive' , 'hidden' , 'locked' , 'timeline' ],
1831
1829
help = """Set this option to automatically set the visibility of all assets that are discovered by the script and assigned to albums.
1832
1830
Exception for value 'locked': Assets will not be added to any albums, but to the 'locked' folder only.
@@ -1900,10 +1898,11 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
1900
1898
unattended = False
1901
1899
1902
1900
# Backward compatibility, remove when archive is removed
1903
- if visibility == None and archive :
1901
+ if visibility is None and archive :
1902
+ # pylint: disable=C0103
1904
1903
visibility = 'archive'
1905
1904
logging .warning ('-v/--archive is DEPRECATED! Use --visibility=archive instead! This option will be removed in the future!' )
1906
- # End Backward compaibility
1905
+ # End Backward compaibility
1907
1906
1908
1907
is_docker = os .environ .get (ENV_IS_DOCKER , False )
1909
1908
@@ -1931,7 +1930,7 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
1931
1930
logging .debug ("set_album_thumbnail = %s" , set_album_thumbnail )
1932
1931
# Backward compatibility, remove when archive is removed
1933
1932
logging .debug ("archive = %s" , archive )
1934
- # End Backward compaibility
1933
+ # End Backward compaibility
1935
1934
logging .debug ("visibility = %s" , visibility )
1936
1935
logging .debug ("find_archived_assets = %s" , find_archived_assets )
1937
1936
logging .debug ("read_album_properties = %s" , read_album_properties )
@@ -2050,7 +2049,8 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
2050
2049
albums_to_create = dict (sorted (albums_to_create .items (), key = lambda item : item [0 ]))
2051
2050
2052
2051
if version ['major' ] == 1 and version ['minor' ] < 133 :
2053
- albums_with_visibility = [album_check_to_check for album_check_to_check in albums_to_create .values () if album_check_to_check .visibility is not None and album_check_to_check .visibility != 'archive' ]
2052
+ albums_with_visibility = [album_check_to_check for album_check_to_check in albums_to_create .values ()
2053
+ if album_check_to_check .visibility is not None and album_check_to_check .visibility != 'archive' ]
2054
2054
if len (albums_with_visibility ) > 0 :
2055
2055
logging .warning ("Option 'visibility' is only supported in Immich Server v1.133.x and newer! Option will be ignored!" )
2056
2056
@@ -2099,11 +2099,11 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
2099
2099
for album in albums_to_create .values ():
2100
2100
# Special case: Add assets to Locked folder
2101
2101
# Locked assets cannot be part of an album, so don't create albums in the first place
2102
- if ( album .visibility == 'locked' ) :
2102
+ if album .visibility == 'locked' :
2103
2103
set_assets_visibility (album .get_asset_uuids (), album .visibility )
2104
2104
logging .info ("Added %d assets to locked folder" , len (album .get_asset_uuids ()))
2105
2105
continue
2106
-
2106
+
2107
2107
# Create album if inexistent:
2108
2108
if not album .id :
2109
2109
album .id = create_album (album .get_final_name ())
@@ -2117,7 +2117,7 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
2117
2117
logging .info ("%d new assets added to %s" , len (assets_added ), album .get_final_name ())
2118
2118
2119
2119
# Set assets visibility
2120
- if ( album .visibility is not None ) :
2120
+ if album .visibility is not None :
2121
2121
set_assets_visibility (assets_added , album .visibility )
2122
2122
logging .info ("Set visibility for %d assets to %s" , len (assets_added ), album .visibility )
2123
2123
0 commit comments