智盟项目
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

375 líneas
18 KiB

  1. package svc
  2. import (
  3. "applet/app/cfg"
  4. offical "applet/app/db/official"
  5. md2 "applet/app/es/md"
  6. md3 "applet/app/md"
  7. "applet/app/task/md"
  8. "applet/app/utils"
  9. "applet/app/utils/cache"
  10. "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
  11. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok"
  12. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  13. "encoding/json"
  14. "fmt"
  15. "github.com/jinzhu/copier"
  16. "github.com/syyongx/php2go"
  17. "github.com/tidwall/gjson"
  18. "strings"
  19. "time"
  20. )
  21. func TikTokTask() {
  22. //doc, _ := es.FirstDoc(md2.ZhiosTikTokTaskEsIndex, "tik_tok_task_tt99fdef4006c36ff001")
  23. //fmt.Println(string(doc.Source))
  24. //return
  25. //es.CreateIndexIfNotExists(md2.ZhiosTikTokTaskEsIndex, md2.ZhiosTikTokTaskEsMapping)
  26. //es.CreateIndexIfNotExists(md2.ZhiosTikTokTaskDetailEsIndex, md2.ZhiosTikTokTaskDetailEsMapping)
  27. appidList := offical.MasterListCfgGetOneData("0", "tik_tok_task_appid")
  28. split := strings.Split(appidList, ";")
  29. for _, v := range split {
  30. endTime := time.Now().Unix()
  31. startTime := endTime - 7*86400
  32. if endTime > time.Now().Unix() {
  33. endTime = time.Now().Unix()
  34. }
  35. param := map[string]interface{}{
  36. "appid": v,
  37. "create_start_time": startTime,
  38. "create_end_time": endTime,
  39. }
  40. api, _ := tik_tok.TaskApi("query_app_task_id/", TikTokTaskToken(), zhios_third_party_utils.SerializeStr(param))
  41. taskIds := gjson.Get(api, "data.task_ids").String()
  42. fmt.Println(taskIds)
  43. if taskIds == "" || taskIds == "[]" {
  44. fmt.Println(endTime)
  45. offical.MasterListCfgSave("0", "tik_tok_task_appid_time_"+v, utils.Int64ToStr(endTime))
  46. continue
  47. }
  48. CommAddTask("tik_tok_task_"+v, taskIds)
  49. var tmp = make([]int64, 0)
  50. json.Unmarshal([]byte(taskIds), &tmp)
  51. GetTaskDetail(v, tmp)
  52. fmt.Println(endTime)
  53. offical.MasterListCfgSave("0", "tik_tok_task_appid_time_"+v, utils.Int64ToStr(endTime))
  54. }
  55. }
  56. func GetTaskDetail(appId string, tmp []int64) {
  57. data := md3.KujiangData
  58. var kujiang []md.KuJiang
  59. json.Unmarshal([]byte(data), &kujiang)
  60. kujiangMap := make(map[string]md.KuJiang)
  61. for _, v := range kujiang {
  62. kujiangMap[utils.IntToStr(v.BookId)] = v
  63. }
  64. xinghes := map[string]string{
  65. "7380190485731639322": "https://pan.baidu.com/s/1L8zOJCMdBIwdEvkLV2O4Nw?pwd=miof",
  66. "7379912213080883200": "https://pan.baidu.com/s/1NBh7T8wsKg-qUv37lZh5Vg?pwd=qi55",
  67. "7379861578981703695": "https://pan.baidu.com/s/1thjZIuLkMj2QUNEc3xLVFg?pwd=uvqo",
  68. "7379784012149112872": "https://pan.baidu.com/s/1p9mCmmkrq0pDcNTSW0xtLg?pwd=aa57",
  69. "7379784012149096488": "https://pan.baidu.com/s/1ZOINZXHrH_PnSwnEFRWN-Q?pwd=fz0g",
  70. "7379804114810634276": "https://pan.baidu.com/s/1_RMKz-qqw96mqFN5N--zoQ?pwd=s9vb",
  71. "7379461837433307173": "https://pan.baidu.com/s/1MTqjaO3oKt8KS-zTfXoG_Q?pwd=03l9",
  72. "7379413447399784498": "https://pan.baidu.com/s/1JPuFx_a-AgDUMuotdoQhMg?pwd=9tch",
  73. "7379413956869242906": "https://pan.baidu.com/s/1Z38OjOKTYaC6Eo4mePWlLg?pwd=qoo4",
  74. "7379040298610999332": "https://pan.baidu.com/s/1Wq4GKZJk49WvKNvp55xMqA?pwd=9zal",
  75. "7377925238903881754": "https://pan.baidu.com/s/1ZhHrU40YMITyRwh0_evn-g?pwd=i77m",
  76. "7377636356299898931": "https://pan.baidu.com/s/1bUN8GLg27dHkAKY8Arn98w?pwd=9lo9",
  77. "7377560679844216847": "https://pan.baidu.com/s/1wN3ZB2ElEIbS2-GvJEjy-g?pwd=kgro",
  78. "7377197073747263522": "https://pan.baidu.com/s/1MZIxhxCu8OmxxcyRGJgWZw?pwd=szb7",
  79. "7377173468921561107": "https://pan.baidu.com/s/1ln8r84Y5d-mKR6aaG-6icQ?pwd=ssdy",
  80. "7376820249691324457": "https://pan.baidu.com/s/16qnmC03QmYGxfvfHpVOPbg?pwd=ks1p",
  81. "7376445276631875647": "https://pan.baidu.com/s/1CRNqanQDrzPpkrhCDxa3rQ?pwd=p8ot",
  82. "7376060139776032818": "https://pan.baidu.com/s/1b8HMzsiQCULZW3wYXro1qw?pwd=8sdo",
  83. "7374948827419213834": "https://pan.baidu.com/s/1Tkyt0TvamMMvD1LD-Nmamg?pwd=b05e",
  84. "7374701175310221339": "https://pan.baidu.com/s/1JOzWUcJeVwu9NShnieBMXw?pwd=kqjj",
  85. "7374581090054389801": "https://pan.baidu.com/s/1PKT83xe0hMIuat0D81iumQ?pwd=1akn",
  86. "7373833654033809447": "https://pan.baidu.com/s/15cMH1ds8gT0CGymSBO1NIQ?pwd=sqfr",
  87. "7373480427329159203": "https://pan.baidu.com/s/1-OYIB1RmTXl3SeynP3Dy7Q?pwd=d2tx",
  88. "7372912752035119144": "https://pan.baidu.com/s/1ICIGA5SBCXNwugJM3IxaoA?pwd=eae0",
  89. "7372349272928403482": "https://pan.baidu.com/s/1zms9c0CG07-2kZVFKxYzVw?pwd=fie2",
  90. "7372080132082778152": "https://pan.baidu.com/s/125VKEkXRa3FkgTdR7gqhvw?pwd=wrbx",
  91. "7372009394361401344": "https://pan.baidu.com/s/1acDqOnZEfv6IIFEAUl5ffQ?pwd=1nyb",
  92. "7372013980895985701": "https://pan.baidu.com/s/1azZYwHx1jWLjtz8gc2leFA?pwd=a53c",
  93. "7371376162850750501": "https://pan.baidu.com/s/14vjCx7AKi0gIsljs-0XGuw?pwd=ib54",
  94. "7371371539645661211": "https://pan.baidu.com/s/1Xy0x6qlQDjR7LIjkX01nGA?pwd=oik9",
  95. "7371366982576308287": "https://pan.baidu.com/s/1VjwcogPOHuy25te9zEBERw?pwd=29sq",
  96. "7371001858434793526": "https://pan.baidu.com/s/1lcXNSZ9z6be83v4UehkM-w?pwd=oy0r",
  97. "7371001571926081590": "https://pan.baidu.com/s/1ETttvHJd2_fDNuJRuCaKsQ?pwd=dv28",
  98. "7370904753900945460": "https://pan.baidu.com/s/1PVM9Jpaf93V_--0d1UW9Dg?pwd=bogh",
  99. "7370911902962221119": "https://pan.baidu.com/s/1DQAvDk8zE0glH81TRvQhfg?pwd=ye4u",
  100. "7370857345389297699": "https://pan.baidu.com/s/1MhJYTpXqUgPnOrJ2mvVClQ?pwd=mo78",
  101. "7369875298587836455": "https://pan.baidu.com/s/1P5mGA0QKiRcHHgE1Bzz1cg?s4pn",
  102. "7369875429492113419": "https://pan.baidu.com/s/1ZHldm5KDXka_5arInJiDQw?pwd=avqw",
  103. "7369888148781809698": "https://pan.baidu.com/s/1ErZRBvvMOQlaZcyuDHfB_g?pwd=lo2y",
  104. "7369813564837642281": "https://pan.baidu.com/s/1-Ks0ArP_8mKIsNgDAqI7PA?pwd=d86a",
  105. "7369751707867283506": "https://pan.baidu.com/s/14qOLJey1bWEA0pqFF6xhgw?pwd=5cmc",
  106. "7369503459801956371": "https://pan.baidu.com/s/1vyXKrJeuvx5x4w-acbVa6A?pwd=qugd",
  107. "7369391591624163364": "https://pan.baidu.com/s/1eM2tbZ8yj6zIDqovSO49_A?pwd=aqg2",
  108. "7369392341066498111": "https://pan.baidu.com/s/12t76uMp_3sn8hdMDoXwppg?pwd=tpfe",
  109. "7369148051795017740": "https://pan.baidu.com/s/13_S-8fE21nqSofjgx_rWKw?pwd=uns8",
  110. "7369059651461283894": "https://pan.baidu.com/s/1Fqbpz35M8dwxX8tFhpyQhQ?pwd=uexq",
  111. "7369037096285175808": "https://pan.baidu.com/s/1_Y2LnJeAG1-QJUCNegiKuA?pwd=jcjv",
  112. "7368762632674803751": "https://pan.baidu.com/s/1bjiyXlw_sMQ9YR4YALu3ZQ?pwd=aic8",
  113. "7368679769661079564": "https://pan.baidu.com/s/1Rrqm6C_VCP9pTLIiytJFew?pwd=0w3y",
  114. "7368678622070489139": "https://pan.baidu.com/s/1ImxFZxOihIxmpKs7FQNC-A?pwd=6dgz",
  115. "7368653781052981283": "https://pan.baidu.com/s/15jtQvEYxQujqY3C_zeE_fA?pwd=mcy5",
  116. "7368329261691961371": "https://pan.baidu.com/s/171ZRDKRRU3aP7ZMBDy0vsQ?pwd=sipq",
  117. "7368324603678031882": "https://pan.baidu.com/s/1B5Qh3vs3Ivfk8rTLCc1tng?pwd=emws",
  118. "7367710375317520399": "https://pan.baidu.com/s/1aEaDUhSM-4VDTxn40wXm3A?pwd=6e8b",
  119. "7367316323904372772": "https://pan.baidu.com/s/1kf58ZCgI0BgCLQapMfrTbQ?pwd=cceg",
  120. "7366906746314555404": "https://pan.baidu.com/s/1MNfbPba3Nt2pTnHTfBUEBA?pwd=ew3v",
  121. "7366486018851209235": "https://pan.baidu.com/s/1QWF63ao80TT3BAMV0-QpRA?pwd=rcs5",
  122. "7366151010714157097": "https://pan.baidu.com/s/1055EkwtBxPM0Sw6L5gOCFw?pwd=1sq9",
  123. "7366102746245726248": "https://pan.baidu.com/s/1WzXSrkemz0Hm0DTNcmTpxA?pwd=y2j0",
  124. "7365004815451062312": "https://pan.baidu.com/s/1q2XYO3GraSEvdX2F3JcX4Q?pwd=glby",
  125. "7364352540936290358": "https://pan.baidu.com/s/11JDyHl97egRjDKxnH9D7rQ?pwd=mr0l",
  126. "7363525995279745035": "https://pan.baidu.com/s/1te89FR6rULnXV7g5BaRIPA?pwd=hx47",
  127. "7363532419464429619": "https://pan.baidu.com/s/1JBXBddSdLeZn-BOFYCjQrA?pwd=y1iu",
  128. "7363505120711098368": "https://pan.baidu.com/s/1iAP5OSU46CFz0vyOYGOBCA?pwd=ft2t",
  129. "7363505153716125731": "https://pan.baidu.com/s/1Lpuc4iUBWxndb1xTcRoicQ?pwd=390v",
  130. "7363505437439918121": "https://pan.baidu.com/s/1Y_RnixE05gaMptBrhC0DQw?pwd=n3ni",
  131. "7363157598629068819": "https://pan.baidu.com/s/1NPtnl5EBK7jRRgk7kSStPg?pwd=86p6",
  132. "7363157659111211027": "https://pan.baidu.com/s/1PO8ulobc-54is1QBikJSEQ?pwd=gfek",
  133. "7362021099053383714": "https://pan.baidu.com/s/19mqfaAt5zovNO1sb0e-bxw?pwd=qae9",
  134. "7361723753094610980": "https://pan.baidu.com/s/1oybfSKC4FUWGw81DH6wqXw?pwd=a83p",
  135. "7361713709670006810": "https://pan.baidu.com/s/1r0EAT_q6DKFatnbwXZfeTw?pwd=7h74",
  136. "7361659856501129279": "https://pan.baidu.com/s/1XtOabN5ZGsxG9x_CjF2Aig?pwd=ztet",
  137. "7361314021947015222": "https://pan.baidu.com/s/1Wq3RyPsSUw1PBXqPD7nHCA?pwd=hxip",
  138. "7360937011936510006": "https://pan.baidu.com/s/1WlN5HLmcaADy0jGdiCaGFQ?pwd=tiwb",
  139. "7359423244304269350": "https://pan.baidu.com/s/1_c4cXt25ky2yDOXm2kmL5A?pwd=bcrq",
  140. "7359058838047162368": "https://pan.baidu.com/s/1HkBnlRR27JBKsQheTJxmcQ?pwd=3kcd",
  141. "7358681447030390784": "https://pan.baidu.com/s/1oWMuF5itpF77lls_vSGqJA?pwd=p3wc",
  142. "7358322670871576616": "https://pan.baidu.com/s/13RET87iAbgZlj-jn5mUwUg?pwd=y9rd",
  143. "7357194974695391268": "https://pan.baidu.com/s/1cBU9PIXW99Y5W1XhvdPIpA?pwd=uxc6",
  144. "7356840659325583414": "https://pan.baidu.com/s/1znMbDDAnIRQ7PwtiznOvTQ?pwd=9nj7",
  145. "7355357328834658319": "https://pan.baidu.com/s/1uoDFjFm9iWt5eXGCYwx0Sg?pwd=9i8p",
  146. "7353386971026309183": "https://pan.baidu.com/s/1LCgvkFblrE43e4JtxSOR4Q?pwd=svb5",
  147. "7350898126372323369": "https://pan.baidu.com/s/1P6E4vYl-2x0s_qw1X5oviQ?pwd=84xz",
  148. "7350859162219184139": "https://pan.baidu.com/s/1mUHucK0x5af8G40hJbLzqw?pwd=0dh1",
  149. "7349282971213512754": "https://pan.baidu.com/s/18QgGyqjzW7aImhQ8a2_SJQ?pwd=aswx",
  150. "7348970835950043147": "https://pan.baidu.com/s/1JEL9kvkrvzcZUKwexlhPhw?pwd=gadt",
  151. "7348684759972724745": "https://pan.baidu.com/s/1sqnsG74rqE8vKVz4-mibgw?pwd=q7us",
  152. "7348649376765460531": "https://pan.baidu.com/s/18AIW_J7XHGZFbEsa4zbEZw?pwd=akgy",
  153. "7348320058776502322": "https://pan.baidu.com/s/1RImOhdsbwT-d58U8x9Cl7g?pwd=5oy1",
  154. "7348220904138227746": "https://pan.baidu.com/s/1WL1ZCM5w9opVJRHq2_tQkg?pwd=08gs",
  155. "7347939532555304972": "https://pan.baidu.com/s/1A3vmJaRPU9YFmNZje9ttDw?pwd=2vjp",
  156. "7347576656296443941": "https://pan.baidu.com/s/106MDSCSM7BCTx_1kex65gA?pwd=t1gm",
  157. "7346064108011257897": "https://pan.baidu.com/s/1NY7JuB-2KUlvtbKZqI7vew?pwd=kpt4",
  158. "7345229086283055156": "https://pan.baidu.com/s/1mkkF_bhOh3E7sZf6ymIv0g?pwd=zl3m",
  159. "7344970667663589410": "https://pan.baidu.com/s/17e5bb0dGQ183zHWkO49cmg?pwd=l193",
  160. "7343744932248600616": "https://pan.baidu.com/s/1vL1g1aGhgXMtNEah4TQFxw?pwd=ub0r",
  161. "7342692698744193063": "https://pan.baidu.com/s/1MOaSBkuHGzvv9n1GPc-B3Q?pwd=69fg",
  162. "7340706698497212455": "https://pan.baidu.com/s/1vB8aG2U3kserxWsm3bR1Zg?pwd=qszf",
  163. "7340019974860914715": "https://pan.baidu.com/s/1bykE9LVcNCePutJ4Rmz14A?pwd=dvrx",
  164. "7338982451538133026": "https://pan.baidu.com/s/10GqBT2oBHTdIrtLvm7C3Mg?pwd=203x",
  165. "7336393071648587816": "https://pan.baidu.com/s/1Zl0zxZg3dcTuGsge8pD-SA?pwd=este",
  166. "7335313319047315456": "https://pan.baidu.com/s/1QQZQlgy-WN9hXKjSe59smg?pwd=klno",
  167. "7334158528300482571": "https://pan.baidu.com/s/1DuWh9nZwec3uTAoqwLzIEA?pwd=qs0v",
  168. "7333417334876454949": "https://pan.baidu.com/s/1l5FvB35F9YPnwllSpYPvSA?pwd=ogdy",
  169. "7333416896286507044": "https://pan.baidu.com/s/1S2E0DXe1w6z5kU5r9fGGoQ?pwd=k0br",
  170. "7332303743809011739": "https://pan.baidu.com/s/1S4I4smzV8I3-jytmua1kLg?pwd=2zhv",
  171. "7331643707597864997": "https://pan.baidu.com/s/1WWMY8bWnNLSxCaD0x_Gv0Q?pwd=scm5",
  172. "7331637776204480575": "https://pan.baidu.com/s/1PAYJUrYhZ71XivTZFSxw5Q?pwd=v1n7",
  173. "7330834016368623657": "https://pan.baidu.com/s/1yB46HJtIjjffc0w8RmeRTQ?pwd=x1v3",
  174. "7330529933564919823": "https://pan.baidu.com/s/1PzKUtgetU8bVTILFYxSrNQ?pwd=ul4a",
  175. "7330518079224512550": "https://pan.baidu.com/s/1I1o9UV89oYCVmzJc5bCe1g?pwd=5nxe",
  176. "7327911477510209548": "https://pan.baidu.com/s/1ebMtvlMV2UCCvTOx7znFsA?pwd=d00o",
  177. "7326049857058177024": "https://pan.baidu.com/s/1WtKwzdeiPQz0AjKzieU_6w?pwd=prkh",
  178. "7324972262531153959": "https://pan.baidu.com/s/1qZCfNogUvYWWlkJ225qNQQ?pwd=l0ui",
  179. "7324518767126429734": "https://pan.baidu.com/s/1J7CJYI76-I-9APIq1pzE5A?pwd=ai6t",
  180. "7324518215852228644": "https://pan.baidu.com/s/1w7qG9kSfpZD1hCohnU8vUQ?pwd=0a3w",
  181. "7324510965024751650": "https://pan.baidu.com/s/1bzzIqBftk030n8ZRddnnRA?pwd=6k6e",
  182. "7320876050387353611": "https://pan.baidu.com/s/1Y6oe-upHqA72ivDp4MWBUA?pwd=04th",
  183. "7318971545959170058": "https://pan.baidu.com/s/1jEOgXAR7e5Oqd3KZ2e1zyg?pwd=wvb9",
  184. "7313727507914686476": "https://pan.baidu.com/s/1awg3uiLk5t1EJPGiUXhxyQ?pwd=ppwu",
  185. "7313751212422201379": "https://pan.baidu.com/s/1awg3uiLk5t1EJPGiUXhxyQ?pwd=ppwu",
  186. "7312337908660437004": "https://pan.baidu.com/s/1Q-6nsaWTmj3UWCdSdOQErw?pwd=4sl3",
  187. "7312292128947257383": "https://pan.baidu.com/s/1D71HmPOWkAeBmVk9ujU8dQ?pwd=ta3n",
  188. "7312294620745056267": "https://pan.baidu.com/s/1CI0fC50UWsxKLcQ4AIlUhQ?pwd=pi51",
  189. "7312295241607790643": "https://pan.baidu.com/s/1-8w4R1ypihnHw-djYQHXcg?pwd=p5h8",
  190. "7312292122370031670": "https://pan.baidu.com/s/1pZM-FzOQQrZjhgQ_Kn1nAQ?pwd=ryu0",
  191. "7312291614532599843": "https://pan.baidu.com/s/16794mteTYOn6nzu8k1gIBg?pwd=xdsg",
  192. "7312007303753957395": "https://pan.baidu.com/s/1hEyBrPTm0Rtkl1mP-1myxQ?pwd=di9v",
  193. }
  194. for _, v := range tmp {
  195. time.Sleep(time.Microsecond * 1000)
  196. param := map[string]interface{}{
  197. "appid": appId,
  198. "query_params_type": "1",
  199. "query_params_content": utils.Int64ToStr(v),
  200. "page_no": "1",
  201. "page_size": "10",
  202. }
  203. api, _ := tik_tok.TaskApi("query_task_info/", TikTokTaskToken(), zhios_third_party_utils.SerializeStr(param))
  204. detail := gjson.Get(api, "data.tasks").String()
  205. if detail == "" {
  206. fmt.Println("失败", v)
  207. continue
  208. }
  209. var tmpDetail = make([]md.TikTokTaskDetail, 0)
  210. json.Unmarshal([]byte(detail), &tmpDetail)
  211. for _, v1 := range tmpDetail {
  212. var tmpIn md.TikTokTaskDetailSecond
  213. err := copier.Copy(&tmpIn, &v1)
  214. fmt.Println(err)
  215. tmpIn.OrientedTalentRelList = utils.SerializeStr(v1.OrientedTalentRelList)
  216. tmpIn.ReferMaCaptures = utils.SerializeStr(v1.ReferMaCaptures)
  217. tmpIn.TaskTags = utils.SerializeStr(v1.TaskTags)
  218. tmpIn.ReferVideoCaptures = utils.SerializeStr(v1.ReferVideoCaptures)
  219. videoTmpStr := "bookId="
  220. if tmpIn.Appid == "tt38e94e54a7d70c4601" {
  221. videoTmpStr = "cid="
  222. } else if strings.Contains(tmpIn.StartPage, "novelid=") {
  223. videoTmpStr = "novelid="
  224. } else if strings.Contains(tmpIn.StartPage, "book_id=") {
  225. videoTmpStr = "book_id="
  226. } else if strings.Contains(tmpIn.StartPage, "video_id=") {
  227. videoTmpStr = "video_id="
  228. }
  229. ex := strings.Split(tmpIn.StartPage, videoTmpStr)
  230. if len(ex) > 1 {
  231. exSecond := strings.Split(ex[1], "&")
  232. tmpIn.VideoId = exSecond[0]
  233. }
  234. if tmpIn.VideoId == "" {
  235. fmt.Println("失败", tmpIn)
  236. continue
  237. }
  238. if tmpIn.Status != 2 {
  239. tmpIn.TaskEndTime = int(time.Now().Unix() - 10)
  240. }
  241. for _, v2 := range md.TaskAddList {
  242. if tmpIn.Appid == v2["name"] { //
  243. tmp2 := md.Cinema5bmsData{
  244. Description: "",
  245. ImageUrl: tmpIn.TaskIcon,
  246. Material: "",
  247. OnlineTime: time.Unix(int64(tmpIn.TaskStartTime), 0).Format("2006-01-02 15:04:05"),
  248. Type: v2["second_type"],
  249. Title: tmpIn.TaskName,
  250. UpdateTime: int(time.Now().Unix()),
  251. Time: tmpIn.TaskStartTime,
  252. Appid: v2["name"],
  253. Id: utils.StrToInt(tmpIn.VideoId),
  254. IsClose: 0,
  255. IsHot: 0,
  256. FirstCate: v2["type"],
  257. SecondCate: "",
  258. Platform: "",
  259. }
  260. if v2["second_type"] == "xinghe" {
  261. tmp2.Material = xinghes[utils.Int64ToStr(tmpIn.TaskId)]
  262. }
  263. uniqueId := php2go.Md5(tmp2.Appid + "_" + tmp2.Type + "_" + tmp2.FirstCate + "_" + utils.IntToStr(tmp2.Id))
  264. if tmp2.Appid == "ttbed9c86421e54c8501" {
  265. doc, _ := es.FirstDoc(md2.ZhiosNewVideo, uniqueId)
  266. if tmpIn.TaskEndTime > int(time.Now().Unix()) {
  267. tmp2.Platform = "tikTok"
  268. }
  269. if doc != nil && strings.Contains(gjson.Get(string(doc.Source), "platform").String(), "kuaishou") {
  270. if tmpIn.TaskEndTime > int(time.Now().Unix()) {
  271. tmp2.Platform = "tikTok,kuaishou"
  272. } else {
  273. tmp2.Platform = "kuaishou"
  274. }
  275. }
  276. jiang, ok := kujiangMap[tmpIn.VideoId]
  277. if ok {
  278. tmp2.Material = jiang.WebDiskUrl
  279. }
  280. } else {
  281. tmp2.Platform = "tikTok"
  282. if tmpIn.TaskEndTime < int(time.Now().Unix()) {
  283. tmp2.IsClose = 1
  284. }
  285. }
  286. if tmp2.Platform == "" {
  287. tmp2.IsClose = 1
  288. }
  289. fmt.Println(uniqueId)
  290. tmp2.Key = uniqueId
  291. commAddNew(uniqueId, tmp2)
  292. }
  293. }
  294. CommAddTaskDetail(utils.Int64ToStr(tmpIn.TaskId), tmpIn)
  295. }
  296. }
  297. }
  298. func CommAddTask(uniqueId string, taskIds string) {
  299. doc, _ := es.FirstDoc(md2.ZhiosTikTokTaskEsIndex, uniqueId)
  300. if doc == nil {
  301. var tmpData = map[string]string{
  302. "task_ids": taskIds,
  303. }
  304. createDocRet, err := es.CreateDoc(md2.ZhiosTikTokTaskEsIndex, uniqueId, tmpData)
  305. if err != nil {
  306. return
  307. }
  308. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  309. } else {
  310. source := doc.Source
  311. tmpData := make(map[string]string)
  312. json.Unmarshal(source, &tmpData)
  313. var tmpOld = make([]int64, 0)
  314. json.Unmarshal([]byte(tmpData["task_ids"]), &tmpOld)
  315. var tmp = make([]int64, 0)
  316. json.Unmarshal([]byte(taskIds), &tmp)
  317. tmp = utils.MergeArr(tmpOld, tmp)
  318. tmp = utils.UniqueArr(tmp)
  319. tmpData = map[string]string{
  320. "task_ids": utils.SerializeStr(tmp),
  321. }
  322. createDocRet, err := es.UpdateDoc(md2.ZhiosTikTokTaskEsIndex, uniqueId, tmpData)
  323. if err != nil {
  324. return
  325. }
  326. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  327. }
  328. }
  329. func CommAddTaskDetail(uniqueId string, tmp md.TikTokTaskDetailSecond) {
  330. doc, _ := es.FirstDoc(md2.ZhiosTikTokTaskDetailEsIndex, uniqueId)
  331. if doc == nil {
  332. createDocRet, err := es.CreateDoc(md2.ZhiosTikTokTaskDetailEsIndex, uniqueId, tmp)
  333. if err != nil {
  334. return
  335. }
  336. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  337. } else {
  338. createDocRet, err := es.UpdateDoc(md2.ZhiosTikTokTaskDetailEsIndex, uniqueId, tmp)
  339. if err != nil {
  340. return
  341. }
  342. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  343. }
  344. }
  345. func TikTokTaskToken() string {
  346. tikTokOpenAppkey := offical.MasterListCfgGetOneData("0", "tik_tok_task_open_appkey")
  347. tikTokOpenAppSecret := offical.MasterListCfgGetOneData("0", "tik_tok_task_open_app_secret")
  348. args := map[string]string{
  349. "appkey": tikTokOpenAppkey,
  350. "appSecret": tikTokOpenAppSecret,
  351. }
  352. key := "tikTok_client_" + args["appkey"]
  353. tokeStr, err := cache.GetString(key)
  354. if cfg.Prd == false {
  355. return tokeStr
  356. }
  357. if tokeStr == "" || err != nil {
  358. token := tik_tok.GetClientToken(args)
  359. if token["tik_tok_acc_token"] != "" {
  360. tokeStr = token["tik_tok_acc_token"]
  361. cache.SetEx(key, token["tik_tok_acc_token"], utils.StrToInt(token["expires_in"]))
  362. }
  363. }
  364. return tokeStr
  365. }