mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-24 17:52:36 +02:00
38 lines
738 B
Go
38 lines
738 B
Go
package piwigo
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
func (p *Piwigo) VideoJSSync(imageId int) error {
|
|
Url, err := url.Parse(p.Url)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
Url.Path += "/admin.php"
|
|
q := Url.Query()
|
|
q.Set("page", "plugin")
|
|
q.Set("section", "piwigo-videojs/admin/admin_photo.php")
|
|
q.Set("sync_metadata", "1")
|
|
q.Set("image_id", fmt.Sprint(imageId))
|
|
Url.RawQuery = q.Encode()
|
|
|
|
req, err := http.NewRequest("GET", Url.String(), nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if p.Token != "" {
|
|
req.AddCookie(&http.Cookie{Name: "pwg_id", Value: p.Token, HttpOnly: true})
|
|
}
|
|
|
|
r, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
//goland:noinspection GoUnhandledErrorResult
|
|
defer r.Body.Close()
|
|
return nil
|
|
}
|