mango.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package thirdp
  2. import (
  3. "go-common/app/interface/main/tv/model"
  4. "go-common/library/time"
  5. )
  6. // MangoSn is the plus version of Dangbei Season
  7. type MangoSn struct {
  8. SID int64 `json:"sid"`
  9. DBeiSeason
  10. OriginName string `json:"origin_name"`
  11. Alias string `json:"alias"`
  12. Autorised bool `json:"autorised"`
  13. Mtime time.Time `json:"mtime"`
  14. EpCover string `json:"ep_cover"`
  15. }
  16. // ToMangoSn transforms an seasonCMS to mangoSn
  17. func ToMangoSn(s *model.SeasonCMS, mtime time.Time, autorised bool) *MangoSn {
  18. mSn := &MangoSn{
  19. DBeiSeason: *DBeiSn(s),
  20. SID: s.SeasonID,
  21. OriginName: s.OriginName,
  22. Alias: s.Alias,
  23. Mtime: mtime,
  24. Autorised: autorised,
  25. }
  26. mSn.SeasonID = nil
  27. return mSn
  28. }
  29. // MangoEP is mango ep structure
  30. type MangoEP struct {
  31. model.EpCMS
  32. SeasonID int64 `json:"sid"`
  33. Autorised bool `json:"autorised"`
  34. Mtime time.Time `json:"mtime"`
  35. }
  36. // MangoSnPage is mango sn page structure
  37. type MangoSnPage struct {
  38. List []*MangoSn `json:"list"`
  39. Pager *model.IdxPager `json:"pager"`
  40. }
  41. // MangoEpPage is mango ep page structure
  42. type MangoEpPage struct {
  43. SeasonID int64 `json:"sid"`
  44. List []*MangoEP `json:"list"`
  45. Pager *model.IdxPager `json:"pager"`
  46. }
  47. // MangoArc is mango archive structure
  48. type MangoArc struct {
  49. AVID int64 `json:"avid"`
  50. Cover string `json:"cover"`
  51. Desc string `json:"desc"`
  52. Title string `json:"title"`
  53. PlayTime string `json:"play_time"`
  54. Category1 string `json:"category_1"`
  55. Category2 string `json:"category_2"`
  56. Autorised bool `json:"autorised"`
  57. Mtime time.Time `json:"mtime"`
  58. }
  59. // MangoVideo is mango video structure
  60. type MangoVideo struct {
  61. CID int64 `json:"cid"`
  62. Page int `json:"page"`
  63. Desc string `json:"desc"`
  64. Title string `json:"title"`
  65. Duration int64 `json:"duration"`
  66. Autorised bool `json:"autorised"`
  67. Mtime time.Time `json:"mtime"`
  68. }
  69. // MangoArcPage is mango arc page structure
  70. type MangoArcPage struct {
  71. List []*MangoArc `json:"list"`
  72. Pager *model.IdxPager `json:"pager"`
  73. }
  74. // MangoVideoPage is mango video page structure
  75. type MangoVideoPage struct {
  76. AVID int64 `json:"avid"`
  77. List []*MangoVideo `json:"list"`
  78. Pager *model.IdxPager `json:"pager"`
  79. }
  80. // RespSid is response structure for sid
  81. type RespSid struct {
  82. Sid int64
  83. Mtime time.Time
  84. }
  85. // PickSids picks sids from resp slices
  86. func PickSids(resps []*RespSid) (sids []int64) {
  87. for _, v := range resps {
  88. sids = append(sids, v.Sid)
  89. }
  90. return
  91. }
  92. // ToMangoArc transforms an ArcCMS to MangoArc
  93. func ToMangoArc(a *model.ArcCMS, mtime time.Time, cat1, cat2 string) *MangoArc {
  94. return &MangoArc{
  95. AVID: a.AID,
  96. Cover: a.Cover,
  97. Desc: a.Content,
  98. Title: a.Title,
  99. PlayTime: a.Pubtime.Time().Format("2006-01-02"),
  100. Autorised: a.CanPlay(),
  101. Mtime: mtime,
  102. Category1: cat1,
  103. Category2: cat2,
  104. }
  105. }