photoprism-client-go/examples/getalbum.go

45 lines
812 B
Go
Raw Normal View History

package main
import (
"fmt"
2021-05-05 16:18:05 +02:00
"github.com/astravexton/logger"
photoprism "github.com/astravexton/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)
}
}