video_cover.go 751 B

123456789101112131415161718192021222324252627282930313233
  1. package archive
  2. import (
  3. "context"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. "net/url"
  7. )
  8. // AICover get covers from ai
  9. func (d *Dao) AICover(c context.Context, filename string) (covers []string, err error) {
  10. params := url.Values{}
  11. params.Set("filename", filename)
  12. params.Set("from", "videoup-job")
  13. var res struct {
  14. Code int `json:"code"`
  15. Data []string `json:"data"`
  16. }
  17. if err = d.client.Get(c, d.recommendURI, "", params, &res); err != nil {
  18. log.Error("AICover error(%v), url(%s)", err, d.recommendURI+"?"+params.Encode())
  19. return
  20. }
  21. if res.Code != 0 {
  22. err = ecode.CreativeDataErr
  23. log.Error("AICover code not 0, url(%s) res(%v)", d.recommendURI+"?"+params.Encode(), err)
  24. return
  25. }
  26. covers = res.Data
  27. return
  28. }