Salvoxia / immich-folder-album-creator

Automatically create and populate albums in Immich from a folder structure in external libraries
https://hub.docker.com/r/salvoxia/immich-folder-album-creator
222 stars 13 forks source link

Add option to ignore specific folders #23

Closed clombt closed 3 months ago

clombt commented 3 months ago

Hi,

I really like this tool. It works great and is perfect for my usecase of immich. Due to the way how my photo library is structured I wanted to add the feature to ignore certain folders. I thought this might be a nice feature for other users too and it could be added to this repo.

I just added an additional argument at the top, which takes the folder list separated by a colon:

parser.add_argument("-i", "--ignore", default="", type=str, help="A string containing a list of folders separated by ':' that will be ignored if found in the album name.")
ignore_albums = args["ignore"]
if not ignore_albums == "":
    ignore_albums = ignore_albums.split(":")
else:
    ignore_albums = False

After fetching all the assets and the object album_to_assets is created, I remove the albums that are in the ignored list:

# Ignore albums
if ignore_albums is not False:
    keys_to_remove = [key for key in album_to_assets if any(word in key for word in ignore_albums)]
    for key in keys_to_remove:
        del album_to_assets[key]

Thanks for creating this script!

Salvoxia commented 3 months ago

Thanks for that idea! One question about your use case: Since Immich has the possibility to add exclusion paths in the external library settings, do you want to import images from your external libraries to Immich but you do not to add them to any albums?

clombt commented 3 months ago

Yes, this is the case for me sometimes. For example, when the folder just contains a bunch of random pictures. I guess it's not very common.

Salvoxia commented 3 months ago

Implemented with 0.7.0. I used your code as a template, but the actual implementation is a little bit different. Instead of removing entries from album_to_assets, the asset is not considered for album creation if its path contains an entry from ignore_albums.

Thanks again for the proposal!

dsakura commented 2 weeks ago

Hello! How I add a list of folders to be ignored? IGNORE: "folder_1" "folder_2" ? Thanks

Salvoxia commented 2 weeks ago

When using Docker, pass a colon : separated string IGNORE: "folder_1:folder_2"