mattdavis90 / immich-stacker

A small application to help you stack images in Immich
MIT License
3 stars 1 forks source link

Doesn't work with latest version of Immich #2

Closed Pikachews closed 2 months ago

Pikachews commented 2 months ago

It appears that the newest version of Immich has some API changes that breaks this module.

2024/06/25 04:52:44 Connecting to Immich on https://immich/api
2024/06/25 04:52:44 Requesting all assets
2024/06/25 04:52:44 Expected HTTP 200 but received 404

🙁

mattdavis90 commented 2 months ago

Well, that's frustrating. I hadn't updated yet so haven't noticed. I just ran the OpenAPI update script to look for new calls. I can't see the depreciation in the release notes either. Nothing is jumping out at me as a possible replacement so I might have to leave through the buckets like the UI does. I'll look to fix asap

mattdavis90 commented 2 months ago

I've updated the code and pushed a new release. Should be working now.

Pikachews commented 2 months ago

Thanks for the update! It seems to be partially working but it's only grabbing the first 250 images and stacking those, despite more un-stacked images being available.

first run

2024/06/25 20:16:51 Connecting to Immich on https://immich/api
2024/06/25 20:16:51 Requesting all assets
2024/06/25 20:16:52 Retrieved 250 assets
2024/06/25 20:16:52 Found 125 rule matches
2024/06/25 20:16:52 Created stack for DSC02178
...
2024/06/25 20:16:54 Finished: 125 Stackable, 125 Succeeded, 0 Failed, 0 Not Stackable

second run

2024/06/25 20:18:39 Connecting to Immich on https://immich/api
2024/06/25 20:18:39 Requesting all assets
2024/06/25 20:18:39 Retrieved 250 assets
2024/06/25 20:18:39 Found 0 rule matches
2024/06/25 20:18:39 Finished: 0 Stackable, 0 Succeeded, 0 Failed, 0 Not Stackable
mattdavis90 commented 2 months ago

Doh. I had a feeling something was off but it stacked all my new uploads. I guess I only tested within the first 250. I'll have a look what options are available on the search API. Tracking down the new call was a pain and not well documented but I guess they do advertise as a beta project.

mattdavis90 commented 2 months ago

Sorry, that turned out to be fairly trivial - I missed the page and nextPage options on the request. v1.1.1 is now released

Pikachews commented 2 months ago

Thanks for the quick replies!

Running into a bit of a weird problem: after running the stacker, I'm seeing a subset of images not appear in a stack, but the RAW image counterpart doesn't show up in the library unless I search for the file explicitly.

For example, here are three sets of photos that should be stacked: image After running the stacker, I see this: image Notice that there is no marker indicating that the image is stacked. If I click into each individual photo, it appears to be the JPG version, plus there is no "Unstack" option, nor does it show any stacked images. However, if I search for the file by name, I see both the JPG and RAW images appear in the search results: image and if I view the RAW image, I see an "Unstack" option in the menu (but it doesn't display any stacked images still). image If I do click "Unstack" both images will reappear in the Photos view as normal. If I unstack and restack the images manually, the images appear stacked as expected.

It also appears to occur if I unstack and restack (via immich-stacker) any of the 125 stacks that were created prior to the pagination fix.

mattdavis90 commented 2 months ago

I've seen something with my own installation but it was fixed by refreshing the Immich web interface. I haven't ever seen it persist.

I'll do some more testing here and see if I can replicate your results. When I ran the stacker after the fixes it stacked around 50 images and I haven't noticed issues. I'll try some other combinations.

mattdavis90 commented 2 months ago

I'm afraid I can't recreate the issue you're seeing. I've unstacked a number of my photos - some within the initial 250 and some after the 250 and they all seem to stack ok. They're not stacked immediately in the UI though, I do have to refresh.

mattdavis90 commented 2 months ago

I've created a new release with better logging. You should be able to set IMMICH_LOG_LEVEL to DEBUG to hopefully get a better idea of what's going wrong

Pikachews commented 2 months ago

Alright, I think I've finally figured out what happened, and it's not inherently due to immich-stacker: I didn't realize my camera's photo counter reset and now I have multiple images in Immich with the same name, and when immich-stacker attempts to stack the images, it's stacking the RAW with the earlier image of the same name.

I guess it properly stacked the first 250 images before the pagination fix because it didn't see the earlier photos with the duplicate naming due to the lack of pagination. Guess I'll have to change my photo name prefix...

Thanks again for all your work on this module and help in debugging this issue.

mattdavis90 commented 2 months ago

I'm glad you found the issue. No problem.

Pikachews commented 2 months ago

For what it's worth, I went around resolving this by adding the FileCreatedAt timestamp to the stack bucket key. Not sure it'll work as a generic solution for all, but works for my use case. 🙃

key := string(m.ReplaceAll([]byte(a.OriginalFileName), []byte(""))) + " - " + a.FileCreatedAt.Local().String()
mattdavis90 commented 2 months ago

I could add it as an environment variable as another comparison point

mattdavis90 commented 2 months ago

I've pushed code to the main branch that adds an IMMICH_COMPARE_CREATED environment variable that should have the same affect as your code above :)

mattdavis90 commented 2 months ago

I haven't released it yet because I haven't had chance to test it properly