alvistar / immich-albums

Create immich albums from folder structure
MIT License
38 stars 7 forks source link

Trying to help / setting it up for myself #3

Closed ajnart closed 7 months ago

ajnart commented 7 months ago

Hello ! I am trying to use this script in order to create an album for each directory in my file system, the structure is the following

... (And about 200 more directories)

Is it possible to create an album with each folder ? Ideally each album would contain the files in all its children directories, but I guess this might not be possible.

I have encountered some issues with .DS_STORE files on MacOS (I have my photos mounted on SMB so it created this file every time I enter a directory) I've added in im.py line 89:

 for filename in os.listdir(folder):
            full_path = os.path.join(folder, filename)
+            ## If the file is hidden (starts with .) skip it or it doens't end with jpg, jpeg, raf, png, skip it
+            if filename.startswith('.') or not filename.lower().endswith(('.jpg', '.jpeg', '.raf', '.png')):
+                continue
            if os.path.isfile(full_path):
                replaced_path = full_path.replace(original_path, replace_path)

In order for it to skip my hidden/non photos files but I still get an issue :

Exception when calling create_album: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'X-Powered-By': 'Express', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '69', 'ETag': '"45-ZIXwJFYuB0um"', 'Date': 'Tue, 28 Nov 2023 17:58:08 GMT', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=5'})
HTTP response body: {"message":"Cannot POST /album","error":"Not Found","statusCode":404}
Creating .album

Issue

Have I done something wrong ? My library is mounted as an external library inside of Immich, but I mounted the/Photos directory as read-only. Does immich create a .album files / directories in order to create albums ? Any help would be much appreciated

alvistar commented 7 months ago

Can you send me how you invoked the script?

I have mac too. Having .DS_STORE should not be a problem, just slow down the script as it would check if it exists as assets.

Yes, it creates .album to store the albumID created for a folder.

As it now it creates an album for each folder, there is not an option to flat directory structure. If you want to implement that you probably need also to specify the depth. Ex -depth 1 to create album only for first level and store all assets in subdir.

ajnart commented 7 months ago

Actually I gave up after my issue and ended up another script to achieve what I wanted : https://gist.github.com/REDVM/d8b3830b2802db881f5b59033cf35702

It ended up working well enough for my use case