license.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package pgc
  2. import (
  3. "fmt"
  4. "strconv"
  5. "go-common/app/job/main/tv/conf"
  6. "go-common/app/job/main/tv/dao/lic"
  7. model "go-common/app/job/main/tv/model/pgc"
  8. )
  9. var categories = map[int8]string{
  10. 1: "番剧",
  11. 2: "电影",
  12. 3: "纪录片",
  13. 4: "国漫",
  14. 5: "电视剧",
  15. }
  16. var zones = map[int64]string{
  17. 1: "中国",
  18. 2: "日本",
  19. }
  20. const _zoneNotFound = "其他"
  21. // newLic create the skeleton of the license struct
  22. func newLic(Season *model.TVEpSeason, conf *conf.Sync) *model.License {
  23. // one license stryct oer season
  24. var (
  25. ps []*model.PS
  26. sign = conf.Sign
  27. area string
  28. ok bool
  29. )
  30. if areaInt, _ := strconv.ParseInt(Season.Area, 10, 64); areaInt != 0 { //compatible with old version ( area was int )
  31. if area, ok = zones[areaInt]; !ok {
  32. area = _zoneNotFound
  33. }
  34. } else { // new logic, directly transform
  35. area = Season.Area
  36. }
  37. var programS = &model.PS{
  38. ProgramSetID: conf.AuditPrefix + fmt.Sprintf("%d", Season.ID),
  39. ProgramSetName: Season.Title,
  40. ProgramSetClass: Season.Style,
  41. ProgramSetType: categories[Season.Category],
  42. PublishDate: Season.PlayTime.Time().Format("2006-01-02"),
  43. Copyright: Season.Copyright,
  44. ProgramCount: int(Season.TotalNum),
  45. CREndData: "1970-01-01",
  46. DefinitionType: "SD",
  47. CpCode: conf.LConf.CPCode,
  48. PayStatus: Season.Status,
  49. PrimitiveName: Season.OriginName,
  50. Alias: Season.Alias,
  51. Zone: area,
  52. LeadingRole: Season.Role,
  53. ProgramSetDesc: Season.Desc,
  54. Staff: Season.Staff,
  55. ProgramSetPoster: Season.Cover,
  56. ProgramList: &model.ProgramList{},
  57. Producer: Season.Producer,
  58. SubGenre: Season.Version,
  59. }
  60. ps = append(ps, programS)
  61. return lic.BuildLic(sign, ps, 0)
  62. }