2021-02-04 06:01:21 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
photoprism "github.com/kris-nova/client-go"
|
|
|
|
"github.com/kris-nova/logger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-02-09 20:17:06 +01:00
|
|
|
logger.Level = 4
|
|
|
|
uuid := "pqnzigq351j2fqgn" // This is a known ID
|
|
|
|
creds := photoprism.NewClientAuthLogin("admin", "missy")
|
|
|
|
client := photoprism.New("localhost:8080")
|
|
|
|
err := client.Auth(creds)
|
2021-02-04 06:01:21 +01:00
|
|
|
if err != nil {
|
|
|
|
halt(4, "Error logging into API: %v", err)
|
|
|
|
}
|
2021-02-09 20:17:06 +01:00
|
|
|
//logger.Always("Login Success!")
|
2021-02-04 06:01:21 +01:00
|
|
|
photo, err := client.V1().GetPhoto(uuid)
|
|
|
|
if err != nil {
|
|
|
|
halt(3, "Error fetching photo: %v", err)
|
|
|
|
}
|
|
|
|
bytes, err := json.Marshal(photo)
|
|
|
|
if err != nil {
|
|
|
|
halt(5, "Error: %v", err)
|
|
|
|
}
|
|
|
|
fmt.Println(string(bytes))
|
|
|
|
}
|