photoprism-client-go/examples/getalbum.go

45 lines
800 B
Go
Raw Permalink Normal View History

package main
import (
"fmt"
2023-02-08 14:07:22 +01:00
"git.zio.sh/astra/logger"
2023-01-18 01:20:55 +01:00
photoprism "git.zio.sh/astra/photoprism-client-go"
)
func main() {
// ---
// Log Level 4 (Most)
// Log Level 3
// Log Level 2
// Log Level 1
// Log Level 0 (Least)
//
logger.Level = 4
//
// ---
uuid := "aqnzih81icziiyae"
client := photoprism.New("http://localhost:8080")
err := client.Auth(photoprism.NewClientAuthLogin("admin", "missy"))
if err != nil {
halt(4, "Error logging into API: %v", err)
}
logger.Always("Logged in...")
album, err := client.V1().GetAlbum(uuid)
if err != nil {
halt(3, "Error getting album %s", uuid)
}
fmt.Println(album)
albums, err := client.V1().GetAlbums(nil)
if err != nil {
halt(2, "Error listing albums: %v", err)
}
for _, album := range albums {
fmt.Println(album)
}
}