智盟项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_cinema5bms.go 2.2 KiB

пре 10 месеци
пре 10 месеци
пре 10 месеци
пре 10 месеци
пре 10 месеци
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package svc
  2. import (
  3. offical "applet/app/db/official"
  4. md2 "applet/app/es/md"
  5. "applet/app/task/md"
  6. "applet/app/utils"
  7. "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
  8. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/cinema_5bms"
  9. "encoding/json"
  10. "fmt"
  11. "github.com/syyongx/php2go"
  12. "github.com/tidwall/gjson"
  13. "time"
  14. )
  15. func Cinema5bms() {
  16. cinema5bmsAppid := offical.SysCfgByKeyStr("cinema5bms_appid")
  17. cinema5bmsAppsecret := offical.SysCfgByKeyStr("cinema5bms_appSecret")
  18. page := 1
  19. //es.CreateIndexIfNotExists(md2.ZhiosNewVideo, md2.ZhiosNewVideoEsMapping)
  20. for {
  21. args := map[string]string{
  22. "app_id": cinema5bmsAppid,
  23. "p": utils.IntToStr(page),
  24. "limit": "200",
  25. }
  26. cinema, _ := cinema_5bms.GetCinema("open/getNewFilmList", cinema5bmsAppsecret, args)
  27. data := make([]md.Cinema5bms, 0)
  28. json.Unmarshal([]byte(gjson.Get(cinema, "data.list").String()), &data)
  29. for _, v := range data {
  30. tmp := md.Cinema5bmsData{
  31. Id: v.Id,
  32. IsHot: 0,
  33. Appid: cinema5bmsAppid,
  34. FirstCate: "cinema",
  35. Type: "5bms",
  36. Title: v.Name,
  37. Description: v.Intro,
  38. SecondCate: v.FilmTypes,
  39. Episode: 0,
  40. Platform: "tikTok,kuaishou",
  41. UpdateTime: int(time.Now().Unix()),
  42. ImageUrl: v.Pic,
  43. IsEnd: 0,
  44. PayEpisode: 0,
  45. Material: "",
  46. OnlineTime: v.PublishDate,
  47. Time: int(utils.TimeStdParseUnix(v.PublishDate)),
  48. }
  49. if v.IsSession == 0 || tmp.Time > int(time.Now().Unix()+86400) {
  50. tmp.IsClose = 1
  51. }
  52. uniqueId := php2go.Md5(tmp.Appid + "_" + tmp.Type + "_" + tmp.FirstCate + "_" + utils.IntToStr(tmp.Id))
  53. tmp.Key = uniqueId
  54. fmt.Println(uniqueId)
  55. commAddNew(uniqueId, tmp)
  56. }
  57. if len(data) == 0 || len(data) < 200 {
  58. break
  59. }
  60. page++
  61. }
  62. }
  63. func commAddNew(uniqueId string, tmp md.Cinema5bmsData) {
  64. doc, _ := es.FirstDoc(md2.ZhiosNewVideo, uniqueId)
  65. if doc == nil && tmp.IsClose == 0 {
  66. createDocRet, err := es.CreateDoc(md2.ZhiosNewVideo, uniqueId, tmp)
  67. if err != nil {
  68. return
  69. }
  70. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  71. } else {
  72. createDocRet, err := es.UpdateDoc(md2.ZhiosNewVideo, uniqueId, tmp)
  73. if err != nil {
  74. return
  75. }
  76. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  77. }
  78. }