media.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package pgc
  2. import (
  3. "context"
  4. "go-common/app/interface/main/tv/model"
  5. "go-common/library/log"
  6. )
  7. // Media gets the media detail data from PGC API
  8. func (d *Dao) Media(ctx context.Context, tvParam *model.MediaParam) (detail *model.SeasonDetail, err error) {
  9. var result model.MediaResp
  10. if err = d.client.Get(ctx, d.conf.Host.APIMedia, "", tvParam.GenerateUrl(), &result); err != nil {
  11. log.Error("ClientGet Sid %d, error[%v]", tvParam.SeasonID, err)
  12. return
  13. }
  14. if err = result.CodeErr(); err != nil {
  15. log.Error("PGC API MediaResp: [CODE:(%d),MESSAGE:(%s)]", result.Code, result.Message)
  16. return
  17. }
  18. detail = result.Result
  19. return
  20. }
  21. // MediaV2 gets the media detail data from PGC API V2
  22. func (d *Dao) MediaV2(ctx context.Context, tvParam *model.MediaParam) (detail *model.SnDetailV2, err error) {
  23. var result model.MediaRespV2
  24. if err = d.client.Get(ctx, d.conf.Host.APIMediaV2, "", tvParam.GenerateUrl(), &result); err != nil {
  25. log.Error("ClientGet Sid %d, error[%v]", tvParam.SeasonID, err)
  26. return
  27. }
  28. if err = result.CodeErr(); err != nil {
  29. log.Error("PGC API MediaResp: [CODE:(%d),MESSAGE:(%s)]", result.Code, result.Message)
  30. return
  31. }
  32. detail = result.Result
  33. return
  34. }