package svc import ( offical "applet/app/db/official" md2 "applet/app/es/md" "applet/app/task/md" "applet/app/utils" "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/cinema_5bms" "encoding/json" "fmt" "github.com/syyongx/php2go" "github.com/tidwall/gjson" "time" ) func Cinema5bms() { cinema5bmsAppid := offical.SysCfgByKeyStr("cinema5bms_appid") cinema5bmsAppsecret := offical.SysCfgByKeyStr("cinema5bms_appSecret") page := 1 //es.CreateIndexIfNotExists(md2.ZhiosNewVideo, md2.ZhiosNewVideoEsMapping) for { args := map[string]string{ "app_id": cinema5bmsAppid, "p": utils.IntToStr(page), "limit": "200", } cinema, _ := cinema_5bms.GetCinema("open/getNewFilmList", cinema5bmsAppsecret, args) data := make([]md.Cinema5bms, 0) json.Unmarshal([]byte(gjson.Get(cinema, "data.list").String()), &data) for _, v := range data { tmp := md.Cinema5bmsData{ Id: v.Id, IsHot: 0, Appid: cinema5bmsAppid, FirstCate: "cinema", Type: "5bms", Title: v.Name, Description: v.Intro, SecondCate: v.FilmTypes, Episode: 0, Platform: "tikTok,kuaishou", UpdateTime: int(time.Now().Unix()), ImageUrl: v.Pic, IsEnd: 0, PayEpisode: 0, Material: "", OnlineTime: v.PublishDate, Time: int(utils.TimeStdParseUnix(v.PublishDate)), } if v.IsSession == 0 || tmp.Time > int(time.Now().Unix()+86400) { tmp.IsClose = 1 } uniqueId := php2go.Md5(tmp.Appid + "_" + tmp.Type + "_" + tmp.FirstCate + "_" + utils.IntToStr(tmp.Id)) tmp.Key = uniqueId fmt.Println(uniqueId) commAddNew(uniqueId, tmp) } if len(data) == 0 || len(data) < 200 { break } page++ } } func commAddNew(uniqueId string, tmp md.Cinema5bmsData) { doc, _ := es.FirstDoc(md2.ZhiosNewVideo, uniqueId) if doc == nil && tmp.IsClose == 0 { createDocRet, err := es.CreateDoc(md2.ZhiosNewVideo, uniqueId, tmp) if err != nil { return } fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) } else { createDocRet, err := es.UpdateDoc(md2.ZhiosNewVideo, uniqueId, tmp) if err != nil { return } fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) } }