2021-01-31 07:41:23 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-01-31 08:59:44 +01:00
|
|
|
"fmt"
|
2021-01-31 07:41:23 +01:00
|
|
|
"os"
|
2021-01-31 08:59:44 +01:00
|
|
|
|
|
|
|
photoprism "github.com/kris-nova/client-go"
|
|
|
|
|
|
|
|
"github.com/kris-nova/logger"
|
2021-01-31 07:41:23 +01:00
|
|
|
)
|
|
|
|
|
2021-01-31 08:59:44 +01:00
|
|
|
// format string, a ...interface{}
|
|
|
|
func halt(code int, msg string, a ...interface{}) {
|
|
|
|
str := fmt.Sprintf(msg, a...)
|
|
|
|
logger.Critical(str)
|
2021-01-31 07:41:23 +01:00
|
|
|
os.Exit(code)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
user := os.Getenv("PHOTOPRISM_USER")
|
|
|
|
if user == "" {
|
|
|
|
halt(1, "Missing PHOTOPRISM_USER")
|
|
|
|
}
|
|
|
|
pass := os.Getenv("PHOTOPRISM_PASS")
|
|
|
|
if pass == "" {
|
2021-01-31 08:59:44 +01:00
|
|
|
halt(2, "Missing PHOTOPRISM_PASS")
|
2021-01-31 07:41:23 +01:00
|
|
|
}
|
2021-01-31 09:08:52 +01:00
|
|
|
login := photoprism.NewClientAuthLogin("username", "password")
|
|
|
|
photoclient := photoprism.New(login)
|
2021-01-31 08:59:44 +01:00
|
|
|
photo, err := photoclient.V1().GetPhoto("123")
|
|
|
|
if err != nil {
|
|
|
|
halt(3, "Error fetching photo: %v", err)
|
|
|
|
}
|
|
|
|
fmt.Println(*photo)
|
2021-01-31 07:41:23 +01:00
|
|
|
}
|