playurl.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package http
  2. import (
  3. "go-common/app/interface/main/app-intl/model"
  4. "go-common/app/interface/main/app-intl/model/player"
  5. "go-common/library/conf/env"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/stat/prom"
  10. )
  11. var errCount = prom.BusinessErrCount
  12. func playurl(c *bm.Context) {
  13. params := &player.Param{}
  14. if err := c.Bind(params); err != nil {
  15. return
  16. }
  17. var mid int64
  18. if midInter, ok := c.Get("mid"); ok {
  19. mid = midInter.(int64)
  20. }
  21. header := c.Request.Header
  22. buvid := header.Get("Buvid")
  23. fp := header.Get("X-BVC-FINGERPRINT")
  24. if params.AID <= 0 {
  25. errCount.Incr("no_aid")
  26. log.Warn("juranmeichuan aid %s", c.Request.URL.Path+"?"+c.Request.Form.Encode())
  27. if env.DeployEnv != env.DeployEnvProd {
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. }
  32. if params.CID <= 0 {
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. if params.Qn < 0 {
  37. c.JSON(nil, ecode.RequestErr)
  38. return
  39. }
  40. if params.Npcybs < 0 {
  41. c.JSON(nil, ecode.RequestErr)
  42. return
  43. }
  44. if params.Otype != "json" && params.Otype != "xml" {
  45. params.Otype = "json"
  46. }
  47. plat := model.Plat(params.MobiApp, params.Device)
  48. c.JSON(playerSvc.Playurl(c, mid, params, plat, buvid, fp))
  49. }