diff --git a/README.md b/README.md index 9c18901..61e46a3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Go client for the Photoprism Application. ```bash -go get github.com/astravexton/photoprism-client-go +go get git.zio.sh/astra/photoprism-client-go ``` @@ -59,12 +59,12 @@ import ( "io/ioutil" "path" - photoprism "github.com/astravexton/photoprism-client-go" - "github.com/astravexton/logger" + photoprism "git.zio.sh/astra/photoprism-client-go" + "git.zio.sh/astra/logger" ) func main() - logger.Level = 4 + logger.BitwiseLevel = logger.LogEverything uuid := "pqnzigq351j2fqgn" // This is a known ID client := photoprism.New("http://localhost:8080") @@ -111,10 +111,3 @@ func main() } ``` - - -# Pipeline - - - [ ] Upload photo methods/tests - - [ ] Code generation - - [ ] Finish the remaining methods diff --git a/api/v1/types.go b/api/v1/types.go index e10d8a1..3703759 100644 --- a/api/v1/types.go +++ b/api/v1/types.go @@ -220,7 +220,7 @@ type File struct { type PhotoLabel struct { PhotoID uint `json:"PhotoID"` LabelID uint `json:"LabelID"` - LabelSrc string `json:"LabelSrc""` + LabelSrc string `json:"LabelSrc"` Uncertainty int `json:"Uncertainty"` Photo *Photo `json:"Photo"` Label *Label `json:"Label"` diff --git a/client.go b/client.go index 702cb41..b5da638 100644 --- a/client.go +++ b/client.go @@ -147,9 +147,12 @@ func (c *Client) LoginV1() error { } token := resp.Header.Get(APIAuthHeaderKey) - if token == "" { + if token == "" && cfg.AccessToken == "" { return fmt.Errorf("missing auth token from successful login") } + if cfg.AccessToken != "" { + token = cfg.AccessToken + } c.v1client = v1.New(c.connectionURL, token, cfg.Config.DownloadToken) return nil } diff --git a/examples/album.go b/examples/album.go index 0a2d6ec..d725a7d 100644 --- a/examples/album.go +++ b/examples/album.go @@ -1,9 +1,9 @@ package main import ( + "git.zio.sh/astra/logger" photoprism "git.zio.sh/astra/photoprism-client-go" "git.zio.sh/astra/photoprism-client-go/api/v1" - "github.com/astravexton/logger" ) func main() { diff --git a/examples/common.go b/examples/common.go index cf6e4da..5e5fda3 100644 --- a/examples/common.go +++ b/examples/common.go @@ -6,7 +6,7 @@ import ( photoprism "git.zio.sh/astra/photoprism-client-go" - "github.com/astravexton/logger" + "git.zio.sh/astra/logger" ) // format string, a ...interface{} diff --git a/examples/getalbum.go b/examples/getalbum.go index 1f6ec37..cb719d6 100644 --- a/examples/getalbum.go +++ b/examples/getalbum.go @@ -3,8 +3,8 @@ package main import ( "fmt" + "git.zio.sh/astra/logger" photoprism "git.zio.sh/astra/photoprism-client-go" - "github.com/astravexton/logger" ) func main() { diff --git a/examples/login.go b/examples/login.go index 5f8af14..800f800 100644 --- a/examples/login.go +++ b/examples/login.go @@ -1,8 +1,8 @@ package main import ( + "git.zio.sh/astra/logger" photoprism "git.zio.sh/astra/photoprism-client-go" - "github.com/astravexton/logger" ) func main() { diff --git a/examples/photo.go b/examples/photo.go index 621f949..cb45db8 100644 --- a/examples/photo.go +++ b/examples/photo.go @@ -5,8 +5,8 @@ import ( "io/ioutil" "path" + "git.zio.sh/astra/logger" photoprism "git.zio.sh/astra/photoprism-client-go" - "github.com/astravexton/logger" ) func main() { diff --git a/go.mod b/go.mod index e68ce8d..853dd1f 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,10 @@ -module git.zio.sh/astra/photoprism-client-go +module git.zio.sh/astra/photoprism-client-go/v2 -go 1.18 +go 1.21.1 -require github.com/astravexton/logger v0.2.2-0.20211216142523-c1e08a465709 // indirect +require git.zio.sh/astra/logger v1.0.1 + +require ( + github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect +) diff --git a/go.sum b/go.sum index cf4246f..c9a0142 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,10 @@ -github.com/astravexton/logger v0.2.2-0.20211216142523-c1e08a465709 h1:S+dBCax7wdg3ikWx5t6cClPKQIerrmD404qAzWhO2V4= -github.com/astravexton/logger v0.2.2-0.20211216142523-c1e08a465709/go.mod h1:6BlG5E0U3CImXLmDtGpEwdoc8PHiiDv0kbvJBCbfiMY= -github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/kris-nova/lolgopher v0.0.0-20210112022122-73f0047e8b65/go.mod h1:V0HF/ZBlN86HqewcDC/cVxMmYDiRukWjSrgKLUAn9Js= +git.zio.sh/astra/logger v1.0.1 h1:vEdHDT5L8n6rHihVblJ9Be1AtGQvKK9tzPHeX4DEBCw= +git.zio.sh/astra/logger v1.0.1/go.mod h1:4FJwzSIWGI8S0HxwSns5r+tuS7GcKAe78AjeEKEjt10= +github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/types.go b/types.go index 1083c1b..b4acc9e 100644 --- a/types.go +++ b/types.go @@ -1,7 +1,8 @@ package photoprism type Config struct { - Config *Options `json:"config"` + Config *Options `json:"config"` + AccessToken string `json:"access_token"` } type Options struct { @@ -68,7 +69,7 @@ type Options struct { //FFmpegBin string `yaml:"FFmpegBin" json:"-" flag:"ffmpeg-bin"` //ExifToolBin string `yaml:"ExifToolBin" json:"-" flag:"exiftool-bin"` //DetachServer bool `yaml:"DetachServer" json:"-" flag:"detach-server"` - DownloadToken string `yaml:"DownloadToken" json:"downloadToken" flag:"download-token"` + DownloadToken string `json:"downloadToken"` //PreviewToken string `yaml:"PreviewToken" json:"-" flag:"preview-token"` //ThumbFilter string `yaml:"ThumbFilter" json:"ThumbFilter" flag:"thumb-filter"` //ThumbUncached bool `yaml:"ThumbUncached" json:"ThumbUncached" flag:"thumb-uncached"`