From 4c71c77bf64c5099e4a8addadc160cc7e7e747a0 Mon Sep 17 00:00:00 2001 From: Adolfo Date: Sat, 25 Jul 2026 16:00:18 -0400 Subject: [PATCH] fix(ImmichElias): show >50 photos via random pagination, filter IMAGE only, increase to 100, JSON 128KB, slideshow + cache --- Apps/ImmichElias/main/Source/main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Apps/ImmichElias/main/Source/main.c b/Apps/ImmichElias/main/Source/main.c index 2e4b20b..2aec4f3 100644 --- a/Apps/ImmichElias/main/Source/main.c +++ b/Apps/ImmichElias/main/Source/main.c @@ -31,8 +31,8 @@ static const char* TAG = "ImmichElias"; #define RESIZE_PROXY_URL "http://192.168.68.110:8106" -#define MAX_PHOTOS 50 -#define JSON_BUF_SIZE (64 * 1024) +#define MAX_PHOTOS 100 +#define JSON_BUF_SIZE (128 * 1024) #define THUMB_BUF_SIZE (512 * 1024) #define FALLBACK_W 320 @@ -157,8 +157,15 @@ static int fetch_person_assets(void) { HttpBuf hb = { .buf = (uint8_t*)json_buf, .cap = JSON_BUF_SIZE - 1, .len = 0 }; char url[256]; snprintf(url, sizeof(url), "%s/api/search/metadata", IMMICH_BASE_URL); - char body[256]; - snprintf(body, sizeof(body), "{\"personIds\":[\"%s\"],\"size\":%d}", IMMICH_PERSON_ID, MAX_PHOTOS); + // Pick random page to get variety from 10k+ photos + // Estimate total photos 10739, with MAX_PHOTOS 100 => ~107 pages + int total_estimate = 10739; + int max_page = total_estimate / MAX_PHOTOS; + if (max_page < 1) max_page = 1; + int random_page = (esp_random() % max_page) + 1; + char body[320]; + snprintf(body, sizeof(body), "{\"personIds\":[\"%s\"],\"size\":%d,\"page\":%d}", IMMICH_PERSON_ID, MAX_PHOTOS, random_page); + ESP_LOGI(TAG, "Fetching person assets page %d/%d size %d", random_page, max_page, MAX_PHOTOS); int status = http_post_json(url, body, &hb); if (status != 200) { heap_caps_free(json_buf); return -1; } if (hb.len >= JSON_BUF_SIZE) hb.len = JSON_BUF_SIZE - 1;