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

Detects all photos but album list is empty #4

Closed nothing2obvi closed 4 months ago

nothing2obvi commented 7 months ago

Am I doing something wrong? I tried it with -a '3' and -a '4' but get the same result.

username@Mac-Mini immich-folder-album-creator % python3 ./immich_auto_album.py -a '4' -s ' - ' '/Volumes/ExternalHDD/Photos/Shared Photos' 'http://10.0.0.224:2283/api' 'apikeyhere'
time=2024-04-02T16:43:31.108-07:00 level=INFO msg=Requesting all assets
time=2024-04-02T16:43:37.332-07:00 level=INFO msg=22474 photos found
time=2024-04-02T16:43:37.332-07:00 level=INFO msg=Sorting assets to corresponding albums using folder name
time=2024-04-02T16:43:37.337-07:00 level=INFO msg=0 albums identified
time=2024-04-02T16:43:37.337-07:00 level=INFO msg=Album list: []
Press Enter to continue, Ctrl+C to abort

time=2024-04-02T16:43:43.744-07:00 level=INFO msg=Listing existing albums on immich
time=2024-04-02T16:43:43.867-07:00 level=INFO msg=0 existing albums identified
time=2024-04-02T16:43:43.867-07:00 level=INFO msg=Creating albums if needed
time=2024-04-02T16:43:43.867-07:00 level=INFO msg=0 albums created
time=2024-04-02T16:43:43.867-07:00 level=INFO msg=Adding assets to albums
time=2024-04-02T16:43:43.867-07:00 level=INFO msg=Done!
username@Mac-Mini immich-folder-album-creator % 
nothing2obvi commented 7 months ago

Nvm I figured it out. I was using the root path on the host instead of the root path for Immich. Thanks, it works really well!

LjaPb commented 4 months ago

I have a similar error. The point is that the script sees all photos (not limited to the specified folder). I can’t limit his search to only a specific folder. The path to the external library is correct (copied directly from the application itself)

Salvoxia commented 4 months ago

Hi, could you please share the arguments/environment variables you're using, the log the script produces and how your folder structure within the Immich container looks like?

LjaPb commented 4 months ago

Of cource,

Снимок экрана 2024-06-21 в 13 28 52
 python3 ./immich_auto_album.py root_path="/mnt/main_pool/archive/Photos/Travel/"                                     [9:17:23]
time=2024-06-21T09:18:21.569-03:00 level=INFO msg=Detected Immich server version 1.106.4
time=2024-06-21T09:18:21.569-03:00 level=INFO msg=Requesting all assets
time=2024-06-21T09:20:03.904-03:00 level=INFO msg=41465 photos found
time=2024-06-21T09:20:03.904-03:00 level=INFO msg=Sorting assets to corresponding albums using folder name
time=2024-06-21T09:20:03.930-03:00 level=INFO msg=0 albums identified
time=2024-06-21T09:20:03.930-03:00 level=INFO msg=Album list: []
Press Enter to continue, Ctrl+C to abort
^CTraceback (most recent call last):
  File "./immich_auto_album.py", line 336, in <module>
    input()
KeyboardInterrupt

Variables api_url and api_key added in the script itself. if I add a variable to the script root_paths = '/mnt/main_pool/archive/Photos/Travel' I get another error:

python3 ./immich_auto_album.py                                                                                      [12:49:40]
time=2024-06-21T13:07:05.585-03:00 level=INFO msg=Detected Immich server version 1.106.4
time=2024-06-21T13:07:05.586-03:00 level=INFO msg=Requesting all assets
time=2024-06-21T13:08:48.933-03:00 level=INFO msg=41465 photos found
time=2024-06-21T13:08:48.933-03:00 level=INFO msg=Sorting assets to corresponding albums using folder name
time=2024-06-21T13:08:48.933-03:00 level=WARNING msg=Got empty album name for asset path /mnt/main_pool/archive/Photos/Travel/qwe/IMG_2914.JPG, check your album_level settings!
-------
**there are a lot of lines like this + I see folders one level higher (where he shouldn’t go)**
------
time=2024-06-21T13:09:38.312-03:00 level=INFO msg=5 albums identified
time=2024-06-21T13:09:38.312-03:00 level=INFO msg=Album list: ['uload', 'uplad', 'upload', 'uplod', 'upoad']
-------
**strange albums о_0**
------
Press Enter to continue, Ctrl+C to abort
^CTraceback (most recent call last):
  File "./immich_auto_album.py", line 336, in <module>
    input()
KeyboardInterrupt

maybe this is important, I use the official immich app in TrueNAS tell me if there is anything else I can show

Salvoxia commented 4 months ago

Ok, I think I know what's going on. The call

 python3 ./immich_auto_album.py root_path="/mnt/main_pool/archive/Photos/Travel/" 

is not actually correct. By default, the script expects three positional arguments in a very specific order: root_path, api_url, and api_key. Now you say you added api_url and api_key to the script itself, that's fine. Now the script stills expect one positional argument root_path. The option -r or --root-path is only intended to be used if you have multiple import paths or multiple external libraries the script should work with. The positional argument for root_path must always be supplied, --root-path is optional.

Since the script expects one positional argument, it interprets the whole string you provide as the root_path, meaning your root_path is currently set to root_path="/mnt/main_pool/archive/Photos/Travel/". Adding -l DEBUG (setting log level to DEBUG) and running it again should confirm this by showing the following output:

time=2024-06-21T18:58:36.399+02:00 level=DEBUG msg=root_path = ['root_path=/mnt/main_pool/archive/Photos/Travel/']

So the correct call for a single root_path (taking your modifications into consideration) would be

 python3 ./immich_auto_album.py /mnt/main_pool/archive/Photos/Travel/

Please let me know if that fixes your issue.

LjaPb commented 4 months ago

Everything was exactly like that, it works! Thank you;)