diff options
| author | Robert Günzler <r@gnzler.io> | 2025-09-07 17:32:13 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2025-09-25 13:16:25 +0200 |
| commit | 99e5cfd96016c2816affda1ceba50e2673ba42fc (patch) | |
| tree | b10a2bc2be79f8afe277718ef2b26f1a4a6c1fb8 /scripts/immich-api-tool | |
| parent | 7f9285e827dab648e72e1fbcbf4cd4e6709fb591 (diff) | |
immich: move api tool to root
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
| -rwxr-xr-x | scripts/immich-api-tool (renamed from bundles/immich/files/immich-api-tool) | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/bundles/immich/files/immich-api-tool b/scripts/immich-api-tool index d0a1a41..14212a9 100755 --- a/bundles/immich/files/immich-api-tool +++ b/scripts/immich-api-tool @@ -1,11 +1,12 @@ #!/bin/sh +# shellcheck disable=SC3043 # local is basically supported set -eu API_URL=https://photos.gzr.im/api API_KEY=zaJUJGHpFqY9OA6kAhuauTj9tC1YVfA8umtZc6ls8U request() { - ENDPOINT=${1:?} + local ENDPOINT="${1:?}" shift 1 curl -sSfL "${API_URL}${ENDPOINT}" \ @@ -28,22 +29,30 @@ searchFavorites() { # requires '{"assetIds":["list","of","ids",...]}' on stdin # downloads to PWD downloadArchive() { + local OUTPUT="${1:?}" + request '/download/archive' \ -H 'Accept: application/octet-stream' \ -d @- \ - -o "archive.zip" \ + -o "$OUTPUT" \ --no-silent } +searchAlbum() { + local ID="${1:?}" + + request "/albums/$ID" +} + main() { validateAccessToken || exit 1 - # download favorites as archive - searchFavorites | - jq '[.assets.items[].id] | {assetIds:.}' -rc | - downloadArchive + case "${1:?}" in + album-dl) searchAlbum "${2:?}" | jq '[.assets[].id]|{assetIds:.}' -rc | downloadArchive "${3:?}" ;; + album-ls) searchAlbum "${2:?}" | jq '.assets[].originalPath' -r ;; + esac } test -n "${DEBUG:-}" && set -x -main +main $@ exit 0 |