diff options
Diffstat (limited to '')
| -rw-r--r-- | .envrc | 1 | ||||
| -rwxr-xr-x | scripts/immich-api-tool (renamed from bundles/immich/files/immich-api-tool) | 23 |
2 files changed, 17 insertions, 7 deletions
diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..f9d77ee --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +PATH_add scripts 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 |