Replies: 2 comments 2 replies
-
Ok, I figured it out... I came up with a small script, that performs login, searching, downloading and viewing of images. Have fun. #!/usr/bin/env sh
base_url="http://127.0.0.1:2342"
# Credentials
username=""
password=""
# Creating Session
response=$(curl -s -H "Content-Type: application/json" -d '{"username": "'$username'", "password": "'$password'"}' $base_url"/api/v1/session")
session_id=$(echo $response | jq -r ".id")
# Alternatively supply a $session_id directly
# session_id=
# Find Images
images=$(curl -s $base_url"/api/v1/photos/view?count=720&offset=0&merged=true&country=&camera=2&lens=0&label=&year=0&month=0&color=&order=newest&q=&public=true&quality=3" \
-H "X-Session-ID: "$session_id)
# Select first image
selected=$(echo $images | jq ".[0]")
# Retrieve download url
download_url=$(echo $selected | jq -r ".DownloadUrl")
# download image
curl -s -o temp.jpg $base_url$download_url
eog temp.jpg &
|
Beta Was this translation helpful? Give feedback.
2 replies
-
One note though: At the moment the script assumes, that the selected image is a type 'image/jpeg'. To make this more robust, it should retrieve the file metadata first and extract a filetype or even filename from there. But this requires an additional call since file metadata comes along the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, so as the title suggests I want to access my photos stored in photoprism from an external script. The basic idea is to have a bash script retrieve a random picture and display it on a display. It is just for personal use within a secured private network, so no need for big security measures.
I found this guide https://docs.photoprism.app/developer-guide/api/ and it suggests to extract the
session_id
from your browser session to use it within a curl script. This works fine for me when calling/api/v1/photos
,/api/v1/photos/:uid
, etc.But if I call
/api/v1/photos/:uid/dl
or/api/v1/dl
I only get some svg returned.In the code I traced it back to this piece
photoprism/internal/api/photos.go
Line 130 in afe2190
It looks like as if my extracted token is note elligible to download.
Since the manual extraction of browser sessions is not a feasible solution in the long run, I am asking on how to authenticate to the API for my script. Any advice? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions