media_v2.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package model
  2. import "go-common/library/ecode"
  3. // SnDetailCore is the common part of pgc media v1 and v2
  4. type SnDetailCore struct {
  5. Cover string `json:"cover"`
  6. Evaluate string `json:"evaluate"`
  7. Link string `json:"link"`
  8. MediaID int `json:"media_id"`
  9. Mode int `json:"mode"`
  10. Paster *Paster `json:"paster"`
  11. Publish *Publish `json:"publish"`
  12. Rating *Rating `json:"rating"`
  13. SeasonID int64 `json:"season_id"`
  14. SeasonStatus int `json:"season_status"`
  15. SeasonTitle string `json:"season_title"`
  16. SeasonType int `json:"season_type"`
  17. ShareURL string `json:"share_url"`
  18. SquareCover string `json:"square_cover"`
  19. Title string `json:"title"`
  20. TotalEp int `json:"total_ep"`
  21. Rights *Rights `json:"rights"`
  22. StyleLabel []*ParamStyle `json:"style_label"`
  23. }
  24. // SnDetailV2 def
  25. type SnDetailV2 struct {
  26. Episodes []*EpisodeV2 `json:"episodes"`
  27. NewestEP *NewEPV2 `json:"new_ep"`
  28. Stat *StatV2 `json:"stat"`
  29. UserStatus *UserStatusV2 `json:"user_status"`
  30. Seasons []*SeasonV2 `json:"seasons"`
  31. Section []*Section `json:"section"`
  32. Type int `json:"type"`
  33. SnDetailCore
  34. }
  35. // TypeTrans def.
  36. func (v *SnDetailV2) TypeTrans() {
  37. v.SeasonType = v.Type
  38. }
  39. // Section def.
  40. type Section struct {
  41. Episodes []*EpisodeV2 `json:"episodes"`
  42. }
  43. // EpisodeV2 def.
  44. type EpisodeV2 struct {
  45. AID int64 `json:"aid"`
  46. Badge string `json:"badge"`
  47. BadgeType int `json:"badge_type"`
  48. CID int64 `json:"cid"`
  49. Cover string `json:"cover"`
  50. From string `json:"from"`
  51. ID int64 `json:"id"`
  52. LongTitle string `json:"long_title"`
  53. ShareURL string `json:"share_url"`
  54. Status int `json:"status"`
  55. Title string `json:"title"`
  56. VID string `json:"vid"`
  57. WaterMark bool `json:"hidemark"` // true means in the whitelist
  58. CornerMark *CornerMark `json:"cornermark"`
  59. }
  60. // CornerMark def.
  61. type CornerMark struct {
  62. Title string `json:"title"`
  63. Cover string `json:"cover"`
  64. }
  65. // SnVipCorner def.
  66. type SnVipCorner struct {
  67. Title string `json:"title"`
  68. Cover string `json:"cover"`
  69. }
  70. // CmsInterv def.
  71. func (v *EpisodeV2) CmsInterv(epCMS *EpCMS) {
  72. if epCMS.Cover != "" {
  73. v.Cover = epCMS.Cover
  74. }
  75. if epCMS.Title != "" {
  76. v.LongTitle = epCMS.Title
  77. }
  78. }
  79. // NewEPV2 def.
  80. type NewEPV2 struct {
  81. Desc string `json:"desc"`
  82. ID int64 `json:"id"`
  83. IsNew int `json:"is_new"`
  84. Title string `json:"title"`
  85. }
  86. // StatV2 def. 3 new fields
  87. type StatV2 struct {
  88. Coin int `json:"coin"`
  89. Reply int `json:"reply"`
  90. Share int `json:"share"`
  91. Stat
  92. }
  93. // UserStatusV2 def.
  94. type UserStatusV2 struct {
  95. Follow int `json:"follow"`
  96. Pay int `json:"pay"`
  97. Progress *WatchProgress `json:"watch_progress"`
  98. Review *ReviewV2 `json:"review"`
  99. Sponsor int `json:"sponsor"`
  100. }
  101. // ReviewV2 def.
  102. type ReviewV2 struct {
  103. IsOpen int `json:"is_open"`
  104. }
  105. // Response standard structure
  106. type Response struct {
  107. Code int `json:"code"`
  108. Message string `json:"message"`
  109. }
  110. // CodeErr generates the code error
  111. func (r *Response) CodeErr() (err error) {
  112. if r.Code != ecode.OK.Code() {
  113. err = ecode.Int(r.Code)
  114. }
  115. return
  116. }
  117. // MediaRespV2 is the structure of PGC display api response
  118. type MediaRespV2 struct {
  119. Response
  120. Result *SnDetailV2 `json:"result"`
  121. }