2021-02-03 20:00:11 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2023-01-18 01:20:55 +01:00
|
|
|
photoprism "git.zio.sh/astra/photoprism-client-go"
|
2021-02-03 20:00:11 +01:00
|
|
|
|
2021-05-05 16:18:05 +02:00
|
|
|
"github.com/astravexton/logger"
|
2021-02-03 20:00:11 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// format string, a ...interface{}
|
|
|
|
func halt(code int, msg string, a ...interface{}) {
|
|
|
|
str := fmt.Sprintf(msg, a...)
|
|
|
|
logger.Critical(str)
|
|
|
|
os.Exit(code)
|
|
|
|
}
|
|
|
|
|
|
|
|
func auth() photoprism.ClientAuthenticator {
|
|
|
|
user := os.Getenv("PHOTOPRISM_USER")
|
|
|
|
if user == "" {
|
|
|
|
halt(1, "Missing PHOTOPRISM_USER")
|
|
|
|
}
|
|
|
|
pass := os.Getenv("PHOTOPRISM_PASS")
|
|
|
|
if pass == "" {
|
|
|
|
halt(2, "Missing PHOTOPRISM_PASS")
|
|
|
|
}
|
|
|
|
auth := photoprism.NewClientAuthLogin(user, pass)
|
|
|
|
return auth
|
|
|
|
}
|