video_up.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package newbiedao
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "go-common/app/interface/main/growup/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. "go-common/library/net/metadata"
  9. "net/url"
  10. "strconv"
  11. )
  12. // GetVideoUp get video up
  13. func (d *Dao) GetVideoUp(c context.Context, aid int64) (videoUpArchive *model.VideoUpArchive, err error) {
  14. uv := url.Values{}
  15. uv.Set("aid", strconv.FormatInt(aid, 10))
  16. videoUpRes := new(model.VideoUpRes)
  17. err = d.httpRead.Get(c, d.c.Host.VideoUpURI, metadata.String(c, metadata.RemoteIP), uv, videoUpRes)
  18. if err != nil {
  19. log.Error("s.dao.GetVideoUp error(%v)", err)
  20. return
  21. }
  22. if videoUpRes.Code != ecode.OK.Code() {
  23. err = errors.Wrap(ecode.Int(videoUpRes.Code), "get video up failed")
  24. log.Error("s.dao.GetVideoUp get video up failed, ecode: %d", videoUpRes.Code)
  25. return
  26. }
  27. if videoUpRes.Data == nil || videoUpRes.Data.Archive == nil {
  28. err = errors.Wrap(ecode.Int(videoUpRes.Code), "get video up nil")
  29. log.Error("s.dao.GetVideoUp get video up is empty")
  30. return
  31. }
  32. videoUpArchive = videoUpRes.Data.Archive
  33. return
  34. }