zuqiu.py 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. import asyncio
  2. import datetime
  3. import json
  4. import aiohttp
  5. import time
  6. import logging
  7. from motor.motor_asyncio import AsyncIOMotorClient
  8. from .ball_func import fuhao
  9. from ..utils.helper import Helper
  10. from .ball_func import new_time
  11. # from concurrent.futures import ThreadPoolExecutor
  12. # from requests_futures.sessions import FuturesSession
  13. class Zuqiupipeline(object):
  14. def open_spider(self, spider):
  15. self.connection = AsyncIOMotorClient("mongodb://{}:{}@{}:{}/database?authSource={}".format('kaiyou', 'kaiyou', '192.168.2.200', 27017, 'kaiyou'))
  16. self.session = aiohttp.ClientSession()
  17. self.url = 'http://admin.5gogo.com'
  18. def process_item(self, item, spider):
  19. loop = asyncio.get_event_loop()
  20. tasks = [
  21. asyncio.ensure_future(self._league(item)),
  22. asyncio.ensure_future(self._match(item)),
  23. asyncio.ensure_future(self._odds(item))
  24. ]
  25. loop.run_until_complete(asyncio.wait(tasks))
  26. async def _league(self, item):
  27. logger = logging.getLogger(__name__)
  28. # 联赛id
  29. league_id = item['league_id']
  30. # 联赛name
  31. league_name = item['league_name']
  32. # 联赛接口写入
  33. last_time = '2019-12-31 23:59:59'
  34. uuid = Helper.genearte_MD5(league_name + 'hg3535')
  35. _zq_league = await self.connection.get_database('kaiyou').zq_league35.find_one({'uuid': uuid})
  36. if not _zq_league:
  37. league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
  38. league_list = []
  39. league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
  40. league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
  41. league_data = dict(zip(league_key, league_value))
  42. league_list.append(league_data)
  43. league_dict['data'] = league_list
  44. response_data = await self.session.post(self.url + '/setLeague', data={"data": json.dumps(league_dict),
  45. "token": 'JlUo1415650051585d481566c10c9'})
  46. if response_data.status == 200:
  47. await self.connection.get_database('kaiyou').zq_league35.insert_one(league_data)
  48. logger.info(league_dict)
  49. else:
  50. logger.warning(response_data.status)
  51. logger.warning(league_dict)
  52. else:
  53. logger.info('足球联赛已存在')
  54. async def _match(self, item):
  55. logger = logging.getLogger(__name__)
  56. try:
  57. data_game = item['data_game'].split("/")
  58. month = str(data_game[1].strip())
  59. day = str(data_game[0])
  60. except Exception as e:
  61. logger.warning(e)
  62. data_game = item['data_game'].split(" ")
  63. months = str(data_game[1].strip())
  64. month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
  65. 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
  66. month = month_dict[months]
  67. day = str(data_game[0])
  68. # 比赛时间
  69. time_game = str(item['time_game'])
  70. # 比赛时间,时间戳
  71. # datetime.datetime.now().year
  72. us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
  73. # 比赛id
  74. match_id = item['game_id']
  75. # 联赛id
  76. league_id = item['league_id']
  77. # 联赛name
  78. league_name = item['league_name']
  79. # # 主队
  80. team_home = item['team_home']
  81. # 客队
  82. team_guest = item['team_guest']
  83. # number
  84. tag_number = item['number']
  85. pt = item['pt']
  86. # corner_ball = item['corner_ball']
  87. match_date, match_time, time3 = new_time(us_time)
  88. # 联赛接口写入
  89. uuid = Helper.genearte_MD5(league_name + 'hg3535')
  90. pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
  91. pt_status = pt_dict[pt]
  92. if pt == '3':
  93. is_rollball = 0
  94. is_today = 0
  95. is_morningplate = 0
  96. is_stringscene = 1
  97. elif pt == '2':
  98. is_rollball = 0
  99. is_today = 0
  100. is_morningplate = 1
  101. is_stringscene = 0
  102. else:
  103. is_today = 1
  104. is_rollball = 0
  105. is_morningplate = 0
  106. is_stringscene = 0
  107. _zq_match = await self.connection.get_database('kaiyou').zq_competition35.find_one({'match_id': match_id, pt_status: 1})
  108. if not _zq_match:
  109. match_list = []
  110. match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  111. match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  112. "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  113. "half_match_id", "is_today"]
  114. match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  115. "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
  116. match_data = dict(zip(match_kay, match_value))
  117. match_list.append(match_data)
  118. match_dict['data'] = match_list
  119. response_data = await self.session.post(self.url + '/setMatch',
  120. data={"data": json.dumps(match_data), "token": 'JlUo1415650051585d481566c10c9'})
  121. if response_data.status == 200:
  122. await self.connection.get_database('kaiyou').zq_competition35.insert_one(match_data)
  123. else:
  124. logger.warning(response_data.status)
  125. logger.warning(match_dict)
  126. else:
  127. logger.info('足球赛事已存在')
  128. async def _odds(self, item):
  129. logger = logging.getLogger(__name__)
  130. # 比赛日期
  131. try:
  132. data_game = item['data_game'].split("/")
  133. # print(data_game)
  134. month = str(data_game[1].strip())
  135. day = str(data_game[0])
  136. except Exception as e:
  137. logger.warning(e)
  138. data_game = item['data_game'].split(" ")
  139. months = str(data_game[1].strip())
  140. month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
  141. 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
  142. month = month_dict[months]
  143. day = str(data_game[0])
  144. # 比赛时间
  145. time_game = str(item['time_game'])
  146. # 比赛时间,时间戳
  147. # datetime.datetime.now().year
  148. us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
  149. # r_ctime = str(datetime.datetime.now().year) + "-" + month + "-" + day
  150. # 现在时间,时间戳
  151. utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
  152. # expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
  153. # 比赛id
  154. match_id = item['game_id']
  155. # 联赛id
  156. league_id = item['league_id']
  157. # 联赛name
  158. league_name = item['league_name']
  159. # # 主队
  160. team_home = item['team_home']
  161. # 客队
  162. team_guest = item['team_guest']
  163. # number
  164. tag_number = item['number']
  165. pt = item['pt']
  166. corner_ball = item['corner_ball']
  167. match_date, match_time, time3 = new_time(us_time)
  168. # 联赛接口写入
  169. # last_time = '2019-12-31 23:59:59'
  170. uuid = Helper.genearte_MD5(league_name + 'hg3535')
  171. # 赔率
  172. _zq_odds = await self.connection.get_database('kaiyou').zq_zodds35.find_one({'match_id': match_id})
  173. if _zq_odds:
  174. _uid_list = _zq_odds['uid']
  175. pass
  176. else:
  177. _uid_list = []
  178. # try:
  179. # result = self.db.hg3535_zq_odds.find_one({'match_id': match_id, 'pt': pt})
  180. # uuid_list = result['odds_only']
  181. # except:
  182. # uuid_list = []
  183. # result = ''
  184. # p_code, p_id = get_pcode(corner_ball, 'goal_size')
  185. # 构建唯一索引
  186. p_code = "GS"
  187. half_size_guest = item["half_size_guest"]
  188. half_size_guest_rule = item["half_size_guest_rule"]
  189. half_size_home = item["half_size_home"]
  190. half_size_home_rule = item["half_size_home_rule"]
  191. zuqiu = item['zuqiu']
  192. data_list = []
  193. odds_onlys = []
  194. # half_size_guest
  195. for index, value in enumerate(half_size_guest):
  196. hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
  197. value) + "hg3535" + str(match_id)
  198. sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
  199. odds_only = Helper.genearte_MD5(hash_str)
  200. sole = Helper.genearte_MD5(sole_str)
  201. odds_onlys.append(odds_only)
  202. half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  203. "odds_only", "sole", "source", "type", "team"]
  204. condition = fuhao(half_size_guest_rule[index])
  205. half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
  206. odds_only, sole, "hg3535", "0", ""]
  207. half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
  208. if odds_only not in _uid_list:
  209. data_list.append(half_size_guest_data)
  210. _uid_list.append(odds_only)
  211. # half_size_home
  212. for index, value in enumerate(half_size_home):
  213. hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
  214. value) + "hg3535" + str(match_id)
  215. sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
  216. odds_only = Helper.genearte_MD5(hash_str)
  217. sole = Helper.genearte_MD5(sole_str)
  218. odds_onlys.append(odds_only)
  219. half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  220. "odds_only", "sole", "source", "type", "team"]
  221. condition = fuhao(half_size_home_rule[index])
  222. half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
  223. odds_only, sole, "hg3535", "0", ""]
  224. half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
  225. # if uid_num < 1:
  226. if odds_only not in _uid_list:
  227. _uid_list.append(odds_only)
  228. data_list.append(half_size_home_data)
  229. # 全场场大小
  230. size_guest = item["size_guest"]
  231. size_guest_rule = item["size_guest_rule"]
  232. size_home = item["size_home"]
  233. size_home_rule = item["size_home_rule"]
  234. # size_home
  235. for index, value in enumerate(size_home):
  236. hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
  237. match_id)
  238. sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
  239. odds_only = Helper.genearte_MD5(hash_str)
  240. sole = Helper.genearte_MD5(sole_str)
  241. odds_onlys.append(odds_only)
  242. size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  243. "odds_only", "sole", "source", "type", "team"]
  244. condition = fuhao(size_home_rule[index])
  245. size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
  246. sole, "hg3535", "0", ""]
  247. size_home_data = dict(zip(size_home_key, size_home_value))
  248. if odds_only not in _uid_list:
  249. data_list.append(size_home_data)
  250. _uid_list.append(odds_only)
  251. # size_guest
  252. for index, value in enumerate(size_guest):
  253. hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
  254. match_id)
  255. sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
  256. odds_only = Helper.genearte_MD5(hash_str)
  257. sole = Helper.genearte_MD5(sole_str)
  258. odds_onlys.append(odds_only)
  259. size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  260. "odds_only", "sole", "source", "type", "team"]
  261. condition = fuhao(size_guest_rule[index])
  262. size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
  263. sole, "hg3535", "0", ""]
  264. size_home_data = dict(zip(size_guest_key, size_guest_value))
  265. if odds_only not in _uid_list:
  266. data_list.append(size_home_data)
  267. _uid_list.append(odds_only)
  268. # p_code, p_id = get_pcode(corner_ball, 'concede')
  269. p_code = 'CO'
  270. half_concede_home_rule = item["half_concede_home_rule"]
  271. half_concede_home = item["half_concede_home"]
  272. half_concede_guest_rule = item["half_concede_guest_rule"]
  273. half_concede_guest = item["half_concede_guest"]
  274. # half_concede_home
  275. for index, value in enumerate(half_concede_guest):
  276. hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
  277. value) + "hg3535" + str(match_id)
  278. sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
  279. odds_only = Helper.genearte_MD5(hash_str)
  280. sole = Helper.genearte_MD5(sole_str)
  281. odds_onlys.append(odds_only)
  282. half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  283. "odds_only", "sole", "source", "type", "team"]
  284. condition = fuhao(half_concede_guest_rule[index])
  285. half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
  286. odds_only, sole, "hg3535", "0", ""]
  287. half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
  288. # if uid_num < 1:
  289. if odds_only not in _uid_list:
  290. data_list.append(half_concede_guest_data)
  291. _uid_list.append(odds_only)
  292. # half_concede_home
  293. for index, value in enumerate(half_concede_home):
  294. hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
  295. value) + "hg3535" + str(match_id)
  296. sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
  297. odds_only = Helper.genearte_MD5(hash_str)
  298. sole = Helper.genearte_MD5(sole_str)
  299. odds_onlys.append(odds_only)
  300. half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  301. "odds_only", "sole", "source", "type", "team"]
  302. condition = fuhao(half_concede_home_rule[index])
  303. half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
  304. odds_only, sole, "hg3535", "0", ""]
  305. half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
  306. if odds_only not in _uid_list:
  307. data_list.append(half_concede_home_data)
  308. _uid_list.append(odds_only)
  309. concede_guest = item["concede_guest"]
  310. concede_guest_rule = item["concede_guest_rule"]
  311. concede_home = item["concede_home"]
  312. concede_home_rule = item["concede_home_rule"]
  313. # concede_guest
  314. for index, value in enumerate(concede_guest):
  315. hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
  316. value) + "hg3535" + str(match_id)
  317. sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
  318. odds_only = Helper.genearte_MD5(hash_str)
  319. sole = Helper.genearte_MD5(sole_str)
  320. odds_onlys.append(odds_only)
  321. concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  322. "odds_only", "sole", "source", "type", "team"]
  323. condition = fuhao(concede_guest[index])
  324. concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
  325. odds_only, sole, "hg3535", "0", ""]
  326. concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
  327. if odds_only not in _uid_list:
  328. data_list.append(concede_guest_data)
  329. _uid_list.append(odds_only)
  330. # concede_home
  331. for index, value in enumerate(concede_home):
  332. hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
  333. value) + "hg3535" + str(match_id)
  334. sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
  335. odds_only = Helper.genearte_MD5(hash_str)
  336. sole = Helper.genearte_MD5(sole_str)
  337. odds_onlys.append(odds_only)
  338. concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  339. "odds_only", "sole", "source", "type", "team"]
  340. condition = fuhao(concede_home_rule[index])
  341. concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
  342. sole, "hg3535", "0", ""]
  343. concede_guest_data = dict(zip(concede_home_key, concede_home_value))
  344. if odds_only not in _uid_list:
  345. data_list.append(concede_guest_data)
  346. _uid_list.append(odds_only)
  347. # 独赢----------------------------------------------------------------------------------------------------------
  348. # p_code, p_id = get_pcode(corner_ball, 'capot')
  349. p_code = 'C'
  350. half_capot_home = item["half_capot_home"]
  351. half_capot_guest = item["half_capot_guest"]
  352. half_capot_dogfall = item["half_capot_dogfall"]
  353. capot_home = item["capot_home"]
  354. capot_guest = item["capot_guest"]
  355. capot_dogfall = item["capot_dogfall"]
  356. # half_capot_home
  357. hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
  358. sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
  359. odds_only = Helper.genearte_MD5(hash_str)
  360. sole = Helper.genearte_MD5(sole_str)
  361. odds_onlys.append(odds_only)
  362. half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  363. "odds_only", "sole", "source", "type", "team"]
  364. half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
  365. odds_only, sole, "hg3535", "0", ""]
  366. half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
  367. if odds_only not in _uid_list:
  368. data_list.append(half_capot_homet_data)
  369. _uid_list.append(odds_only)
  370. # half_capot_guest
  371. hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
  372. sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
  373. odds_only = Helper.genearte_MD5(hash_str)
  374. sole = Helper.genearte_MD5(sole_str)
  375. odds_onlys.append(odds_only)
  376. half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  377. "odds_only", "sole", "source", "type", "team"]
  378. half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
  379. odds_only, sole, "hg3535", "0", ""]
  380. half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
  381. if odds_only not in _uid_list:
  382. data_list.append(half_capot_guest_data)
  383. _uid_list.append(odds_only)
  384. # half_capot_dogfall
  385. hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
  386. sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
  387. odds_only = Helper.genearte_MD5(hash_str)
  388. sole = Helper.genearte_MD5(sole_str)
  389. odds_onlys.append(odds_only)
  390. half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  391. "odds_only", "sole", "source", "type", "team"]
  392. half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
  393. odds_only, sole, "hg3535", "0", ""]
  394. half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
  395. if odds_only not in _uid_list:
  396. data_list.append(half_capot_dogfall_data)
  397. _uid_list.append(odds_only)
  398. # capot_dogfall
  399. hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
  400. sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
  401. odds_only = Helper.genearte_MD5(hash_str)
  402. sole = Helper.genearte_MD5(sole_str)
  403. odds_onlys.append(odds_only)
  404. capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  405. "odds_only", "sole", "source", "type", "team"]
  406. capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
  407. sole, "hg3535", "0", ""]
  408. capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
  409. if odds_only not in _uid_list:
  410. data_list.append(capot_dogfall_data)
  411. _uid_list.append(odds_only)
  412. # capot_home
  413. hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
  414. sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
  415. odds_only = Helper.genearte_MD5(hash_str)
  416. sole = Helper.genearte_MD5(sole_str)
  417. odds_onlys.append(odds_only)
  418. capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  419. "odds_only", "sole", "source", "type", "team"]
  420. capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
  421. odds_only, sole, "hg3535", "0", ""]
  422. capot_homet_data = dict(zip(capot_home_key, capot_home_value))
  423. if odds_only not in _uid_list:
  424. data_list.append(capot_homet_data)
  425. _uid_list.append(odds_only)
  426. # capot_guest
  427. hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
  428. sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
  429. odds_only = Helper.genearte_MD5(hash_str)
  430. sole = Helper.genearte_MD5(sole_str)
  431. odds_onlys.append(odds_only)
  432. capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  433. "odds_only", "sole", "source", "type", "team"]
  434. capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_home, '2',
  435. odds_only, sole, "hg3535", "0", ""]
  436. capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
  437. if odds_only not in _uid_list:
  438. data_list.append(capot_guest_data)
  439. _uid_list.append(odds_only)
  440. # 入球数单双-----------------------------------------------------------------------------------------------------
  441. # p_code, p_id = get_pcode(corner_ball, 'two_sides')
  442. p_code = 'TS'
  443. odd_even_odd = item["odd_even_odd"]
  444. odd_even_even = item["odd_even_even"]
  445. half_odd_even_odd = item["half_odd_even_odd"]
  446. half_odd_even_even = item["half_odd_even_even"]
  447. # odd_even_odd
  448. hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
  449. sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
  450. odds_only = Helper.genearte_MD5(hash_str)
  451. sole = Helper.genearte_MD5(sole_str)
  452. odds_onlys.append(odds_only)
  453. single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  454. "odds_only", "sole", "source", "type", "team"]
  455. single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
  456. odds_only, sole, "hg3535", "0", ""]
  457. single_data = dict(zip(single_key, single_value))
  458. if odds_only not in _uid_list:
  459. data_list.append(single_data)
  460. _uid_list.append(odds_only)
  461. # odd_even_even
  462. hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
  463. sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
  464. odds_only = Helper.genearte_MD5(hash_str)
  465. sole = Helper.genearte_MD5(sole_str)
  466. odds_onlys.append(odds_only)
  467. double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  468. "odds_only", "sole", "source", "type", "team"]
  469. double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
  470. odds_only, sole, "hg3535", "0", ""]
  471. double_data = dict(zip(double_key, double_value))
  472. if odds_only not in _uid_list:
  473. data_list.append(double_data)
  474. _uid_list.append(odds_only)
  475. # half_odd_even_even
  476. hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
  477. sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
  478. odds_only = Helper.genearte_MD5(hash_str)
  479. sole = Helper.genearte_MD5(sole_str)
  480. odds_onlys.append(odds_only)
  481. half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  482. "odds_only", "sole", "source", "type", "team"]
  483. half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
  484. odds_only, sole, "hg3535", "0", ""]
  485. half_double_data = dict(zip(half_double_key, half_double_value))
  486. if odds_only not in _uid_list:
  487. data_list.append(half_double_data)
  488. _uid_list.append(odds_only)
  489. # half_odd_even_odd
  490. hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
  491. sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
  492. odds_only = Helper.genearte_MD5(hash_str)
  493. sole = Helper.genearte_MD5(sole_str)
  494. odds_onlys.append(odds_only)
  495. half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  496. "odds_only", "sole", "source", "type", "team"]
  497. half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
  498. sole, "hg3535", "0", ""]
  499. half_single_data = dict(zip(half_single_key, half_single_value))
  500. if odds_only not in _uid_list:
  501. data_list.append(half_single_data)
  502. _uid_list.append(odds_only)
  503. # 总入球数 ------------------------------------------------------------------------------------------------------
  504. # p_code, p_id = get_pcode(corner_ball, 'total_goal')
  505. p_code = 'TG'
  506. total_goals = item['total_goal']
  507. total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6', 'tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
  508. "tg2_h": '2', "tg3_h": '3或以上'}
  509. # 全场入球数 单双
  510. # 上半场入球数 单双
  511. for key, value in total_goals.items():
  512. hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
  513. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  514. odds_only = Helper.genearte_MD5(hash_str)
  515. sole = Helper.genearte_MD5(sole_str)
  516. odds_onlys.append(odds_only)
  517. total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  518. "odds_only", "sole", "source", "type", "team"]
  519. total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
  520. sole, "hg3535", "0", ""]
  521. total_goals_data = dict(zip(total_goals_key, total_goals_value))
  522. if odds_only not in _uid_list:
  523. data_list.append(total_goals_data)
  524. _uid_list.append(odds_only)
  525. # 全场半场 ------------------------------------------------------------------------------------------------------
  526. half_fulls = item['half_full']
  527. # p_code, p_id = get_pcode(corner_ball, 'half_full')
  528. p_code = 'HF'
  529. full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
  530. "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
  531. if half_fulls:
  532. for key, value in half_fulls.items():
  533. hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
  534. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  535. odds_only = Helper.genearte_MD5(hash_str)
  536. sole = Helper.genearte_MD5(sole_str)
  537. odds_onlys.append(odds_only)
  538. half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  539. "odds_only", "sole", "source", "type", "team"]
  540. half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
  541. sole, "hg3535", "0", ""]
  542. half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
  543. if odds_only not in _uid_list:
  544. data_list.append(half_fulls_data)
  545. _uid_list.append(odds_only)
  546. # 波胆------------------------------------------------------------------------------------------------------------------
  547. bodan_datas = item['bodan_data']
  548. # p_code, p_id = get_pcode(corner_ball, 'bodan')
  549. p_code = 'B'
  550. bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
  551. "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
  552. "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
  553. "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
  554. "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
  555. "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
  556. "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
  557. "bo_h": "其他"}
  558. if bodan_datas:
  559. for key, value in bodan_datas.items():
  560. hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
  561. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  562. odds_only = Helper.genearte_MD5(hash_str)
  563. sole = Helper.genearte_MD5(sole_str)
  564. odds_onlys.append(odds_only)
  565. bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  566. "odds_only", "sole", "source", "type", "team"]
  567. bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
  568. sole, "hg3535", "0", ""]
  569. bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
  570. if odds_only not in _uid_list:
  571. data_list.append(bodan_dict_data)
  572. _uid_list.append(odds_only)
  573. # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
  574. first_last_balls = item['first_last_ball']
  575. # p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
  576. p_code = 'FLB'
  577. first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
  578. if first_last_balls:
  579. for key, value in first_last_balls.items():
  580. hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
  581. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  582. odds_only = Helper.genearte_MD5(hash_str)
  583. sole = Helper.genearte_MD5(sole_str)
  584. odds_onlys.append(odds_only)
  585. first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  586. "condition",
  587. "odds_only", "sole", "source", "type", "team"]
  588. first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key],
  589. odds_only,
  590. sole, "hg3535", "0", ""]
  591. first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
  592. if odds_only not in _uid_list:
  593. data_list.append(first_last_balls_data)
  594. _uid_list.append(odds_only)
  595. # p_code, p_id = get_pcode(corner_ball, 'tema_ball')
  596. # 球队得分大小
  597. p_code = 'TB'
  598. # 全场
  599. full_dicts = item['full_data']
  600. # 上半场
  601. half_dicts = item['half_data']
  602. full_dict_rules = item['full_data_rule']
  603. half_dict_rules = item['half_data_rule']
  604. if full_dicts:
  605. for key, value in full_dicts.items():
  606. hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  607. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  608. odds_only = Helper.genearte_MD5(hash_str)
  609. sole = Helper.genearte_MD5(sole_str)
  610. odds_onlys.append(odds_only)
  611. full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  612. "condition", "odds_only", "sole", "source", "type", "team"]
  613. full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
  614. odds_only, sole, "hg3535", "0", ""]
  615. full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
  616. if odds_only not in _uid_list:
  617. data_list.append(full_dict_rules_data)
  618. _uid_list.append(odds_only)
  619. #
  620. if half_dicts:
  621. for key, value in half_dicts.items():
  622. hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  623. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  624. odds_only = Helper.genearte_MD5(hash_str)
  625. sole = Helper.genearte_MD5(sole_str)
  626. odds_onlys.append(odds_only)
  627. half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  628. "condition", "odds_only", "sole", "source", "type", "team"]
  629. half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
  630. odds_only, sole, "hg3535", "0", ""]
  631. half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
  632. if odds_only not in _uid_list:
  633. data_list.append(half_dicts_data)
  634. _uid_list.append(odds_only)
  635. if pt == '3':
  636. ris_stringscene = 1
  637. else:
  638. ris_stringscene = 0
  639. odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
  640. "is_stringscene", "utime", "pt"]
  641. odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
  642. ris_stringscene, utime, pt]
  643. odds_dict = dict(zip(odds_key, odds_value))
  644. if data_list:
  645. # print(odds_dict)
  646. # response_data = Helper.async_post(self.url + '/setOdds', odds_dict)
  647. response_data = await self.session.post(self.url + '/setOdds',
  648. data={"data": json.dumps(odds_dict), "token": 'JlUo1415650051585d481566c10c9'})
  649. if response_data.status == 200:
  650. # self.db.hg3535_zq_odds.update({'match_id': match_id, 'pt': pt}, {
  651. # '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
  652. if _zq_odds:
  653. pass
  654. await self.connection.get_database('kaiyou').zq_odds35.update_one({'match_id': match_id}, {'$set': {'uid': odds_onlys}})
  655. else:
  656. await self.connection.get_database('kaiyou').zq_odds35.insert_one(
  657. {'match_id': match_id, 'uid': odds_onlys})
  658. else:
  659. logger.info('赔率提交失败')
  660. # async def match_all(self, item, spider):
  661. # zq_odds = []
  662. # # url = 'http://192.168.2.200:9093'
  663. # url = 'http://admin.5gogo.com'
  664. # # zq_competitions = []
  665. # logger = logging.getLogger(__name__)
  666. # # 比赛日期
  667. # try:
  668. # data_game = item['data_game'].split("/")
  669. # # print(data_game)
  670. # month = str(data_game[1].strip())
  671. # day = str(data_game[0])
  672. # except Exception as e:
  673. # logger.warning(e)
  674. # data_game = item['data_game'].split(" ")
  675. # months = str(data_game[1].strip())
  676. # month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
  677. # 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
  678. # month = month_dict[months]
  679. # day = str(data_game[0])
  680. #
  681. # # 比赛时间
  682. # time_game = str(item['time_game'])
  683. # # 比赛时间,时间戳
  684. # # datetime.datetime.now().year
  685. # us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
  686. # r_ctime = str(datetime.datetime.now().year) + "-" + month + "-" + day
  687. # # 现在时间,时间戳
  688. # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
  689. # expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
  690. # # 比赛id
  691. # match_id = item['game_id']
  692. # # 联赛id
  693. # league_id = item['league_id']
  694. # # 联赛name
  695. # league_name = item['league_name']
  696. # # # 主队
  697. # team_home = item['team_home']
  698. # # 客队
  699. # team_guest = item['team_guest']
  700. # # number
  701. # tag_number = item['number']
  702. # pt = item['pt']
  703. # corner_ball = item['corner_ball']
  704. # match_date, match_time, time3 = new_time(us_time)
  705. # # 联赛接口写入
  706. # last_time = '2019-12-31 23:59:59'
  707. # league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
  708. # league_list = []
  709. # uuid = Helper.genearte_MD5(league_name + 'hg3535')
  710. #
  711. # league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
  712. # league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
  713. # league_data = dict(zip(league_key, league_value))
  714. # league_list.append(league_data)
  715. # league_dict['data'] = league_list
  716. # if self.db.hg3535_zq_league.find({'lg_id': league_id}).count() < 1:
  717. # response_data = Helper.async_post(url + '/setLeague', league_dict)
  718. # print(response_data)
  719. # self.db.hg3535_zq_league.insert(league_list)
  720. # competition = self.db.hg3535_zq_competition.find_one({"match_id": str(match_id)})
  721. # match_list = []
  722. # if competition:
  723. # print('赛事已存在,修改赛事四状态')
  724. # is_morningplate = competition['is_morningplate']
  725. # is_rollball = competition['is_rollball']
  726. # is_stringscene = competition['is_stringscene']
  727. # is_today = competition['is_today']
  728. # lmtime = competition['match_time']
  729. # if pt == '3':
  730. # if is_stringscene != 1 or lmtime != match_time:
  731. # match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  732. # match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  733. # "tag","source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  734. # "half_match_id", "is_today"]
  735. # match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  736. # "hg3535",is_rollball, is_morningplate, 1, us_time, uuid, 0, is_today]
  737. # match_data = dict(zip(match_kay, match_value))
  738. # match_list.append(match_data)
  739. # match_dict['data'] = match_list
  740. # response_data = Helper.async_post(url + '/setMatch', match_dict)
  741. # print(response_data)
  742. # self.db.hg3535_zq_competition.update({'match_id': str(match_id)}, {"$set": {"is_stringscene": 1, "match_time": match_time}}, upsert=True)
  743. # if pt == '2':
  744. # if is_morningplate != 1 or lmtime != match_time:
  745. # match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  746. # match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  747. # "tag","source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  748. # "half_match_id", "is_today"]
  749. # match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  750. # "hg3535",is_rollball, 1, is_stringscene, us_time, uuid, 0, is_today]
  751. # match_data = dict(zip(match_kay, match_value))
  752. # match_list.append(match_data)
  753. # match_dict['data'] = match_list
  754. # response_data = Helper.async_post(url + '/setMatch', match_dict)
  755. # print(response_data)
  756. # self.db.hg3535_zq_competition.update({'match_id': str(match_id)}, {"$set": {"is_morningplate": 1, "match_time": match_time}}, upsert=True)
  757. # if pt == '1':
  758. # if is_today != 1 or lmtime != match_time:
  759. # match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  760. # match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  761. # "tag","source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  762. # "half_match_id", "is_today"]
  763. # match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  764. # "hg3535",is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, 1]
  765. # match_data = dict(zip(match_kay, match_value))
  766. # match_list.append(match_data)
  767. # match_dict['data'] = match_list
  768. # response_data = Helper.async_post(url + '/setMatch', match_dict)
  769. # print(response_data)
  770. # self.db.hg3535_zq_competition.update({'match_id': str(match_id)}, {"$set": {"is_today": 1, "match_time": match_time}}, upsert=True)
  771. #
  772. # else:
  773. # print("赛事已存在,赛事状态时间为改变,不做修改")
  774. # else:
  775. # if pt == '3':
  776. # is_rollball = 0
  777. # is_today = 0
  778. # is_morningplate = 0
  779. # is_stringscene = 1
  780. # elif pt == '2':
  781. # is_rollball = 0
  782. # is_today = 0
  783. # is_morningplate = 1
  784. # is_stringscene = 0
  785. # else:
  786. # is_today = 1
  787. # is_rollball = 0
  788. # is_morningplate = 0
  789. # is_stringscene = 0
  790. # # 赛事接口写入
  791. # match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  792. # match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time", "tag",
  793. # "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  794. # "half_match_id", "is_today"]
  795. # match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number, "hg3535",
  796. # is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
  797. # match_data = dict(zip(match_kay, match_value))
  798. # match_list.append(match_data)
  799. # match_dict['data'] = match_list
  800. # response_data = Helper.async_post(url + '/setMatch', match_dict)
  801. # self.db.hg3535_zq_competition.insert(match_list)
  802. # print(response_data)
  803. # # 赔率
  804. # try:
  805. # result = self.db.hg3535_zq_odds.find_one({'match_id': match_id, 'pt': pt})
  806. # uuid_list = result['odds_only']
  807. # except:
  808. # uuid_list = []
  809. # result = ''
  810. # # p_code, p_id = get_pcode(corner_ball, 'goal_size')
  811. # # 构建唯一索引
  812. # p_code = "GS"
  813. # half_size_guest = item["half_size_guest"]
  814. # half_size_guest_rule = item["half_size_guest_rule"]
  815. # half_size_home = item["half_size_home"]
  816. # half_size_home_rule = item["half_size_home_rule"]
  817. # zuqiu = item['zuqiu']
  818. # data_list = []
  819. # odds_onlys = []
  820. # # half_size_guest
  821. # for index, value in enumerate(half_size_guest):
  822. # hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
  823. # value) + "hg3535" + str(match_id)
  824. # sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
  825. # odds_only = Helper.genearte_MD5(hash_str)
  826. # sole = Helper.genearte_MD5(sole_str)
  827. # odds_onlys.append(odds_only)
  828. # half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  829. # "odds_only", "sole", "source", "type", "team"]
  830. # condition = fuhao(half_size_guest_rule[index])
  831. # half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
  832. # odds_only, sole, "hg3535", "0", ""]
  833. # half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
  834. # if odds_only not in uuid_list:
  835. # data_list.append(half_size_guest_data)
  836. # # half_size_home
  837. # for index, value in enumerate(half_size_home):
  838. # hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
  839. # value) + "hg3535" + str(match_id)
  840. # sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
  841. # odds_only = Helper.genearte_MD5(hash_str)
  842. # sole = Helper.genearte_MD5(sole_str)
  843. # odds_onlys.append(odds_only)
  844. # half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  845. # "odds_only", "sole", "source", "type", "team"]
  846. # condition = fuhao(half_size_home_rule[index])
  847. # half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
  848. # odds_only, sole, "hg3535", "0", ""]
  849. # half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
  850. # # if uid_num < 1:
  851. # if odds_only not in uuid_list:
  852. # data_list.append(half_size_home_data)
  853. #
  854. # # 全场场大小
  855. # size_guest = item["size_guest"]
  856. # size_guest_rule = item["size_guest_rule"]
  857. # size_home = item["size_home"]
  858. # size_home_rule = item["size_home_rule"]
  859. # # size_home
  860. # for index, value in enumerate(size_home):
  861. # hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
  862. # match_id)
  863. # sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
  864. # odds_only = Helper.genearte_MD5(hash_str)
  865. # sole = Helper.genearte_MD5(sole_str)
  866. # odds_onlys.append(odds_only)
  867. # size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  868. # "odds_only", "sole", "source", "type", "team"]
  869. # condition = fuhao(size_home_rule[index])
  870. # size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
  871. # sole, "hg3535", "0", ""]
  872. # size_home_data = dict(zip(size_home_key, size_home_value))
  873. # if odds_only not in uuid_list:
  874. # data_list.append(size_home_data)
  875. # # size_guest
  876. # for index, value in enumerate(size_guest):
  877. # hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
  878. # match_id)
  879. # sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
  880. # odds_only = Helper.genearte_MD5(hash_str)
  881. # sole = Helper.genearte_MD5(sole_str)
  882. # odds_onlys.append(odds_only)
  883. # size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  884. # "odds_only", "sole", "source", "type", "team"]
  885. # condition = fuhao(size_guest_rule[index])
  886. # size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
  887. # sole, "hg3535", "0", ""]
  888. # size_home_data = dict(zip(size_guest_key, size_guest_value))
  889. # if odds_only not in uuid_list:
  890. # data_list.append(size_home_data)
  891. #
  892. # # p_code, p_id = get_pcode(corner_ball, 'concede')
  893. # p_code = 'CO'
  894. # half_concede_home_rule = item["half_concede_home_rule"]
  895. # half_concede_home = item["half_concede_home"]
  896. # half_concede_guest_rule = item["half_concede_guest_rule"]
  897. # half_concede_guest = item["half_concede_guest"]
  898. # # half_concede_home
  899. # for index, value in enumerate(half_concede_guest):
  900. # hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
  901. # value) + "hg3535" + str(match_id)
  902. # sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
  903. # odds_only = Helper.genearte_MD5(hash_str)
  904. # sole = Helper.genearte_MD5(sole_str)
  905. # odds_onlys.append(odds_only)
  906. # half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  907. # "odds_only", "sole", "source", "type", "team"]
  908. # condition = fuhao(half_concede_guest_rule[index])
  909. # half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
  910. # odds_only, sole, "hg3535", "0", ""]
  911. # half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
  912. # # if uid_num < 1:
  913. # if odds_only not in uuid_list:
  914. # data_list.append(half_concede_guest_data)
  915. # # half_concede_home
  916. # for index, value in enumerate(half_concede_home):
  917. # hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
  918. # value) + "hg3535" + str(match_id)
  919. # sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
  920. # odds_only = Helper.genearte_MD5(hash_str)
  921. # sole = Helper.genearte_MD5(sole_str)
  922. # odds_onlys.append(odds_only)
  923. # half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  924. # "odds_only", "sole", "source", "type", "team"]
  925. # condition = fuhao(half_concede_home_rule[index])
  926. # half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
  927. # odds_only, sole, "hg3535", "0", ""]
  928. # half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
  929. # if odds_only not in uuid_list:
  930. # data_list.append(half_concede_home_data)
  931. #
  932. # concede_guest = item["concede_guest"]
  933. # concede_guest_rule = item["concede_guest_rule"]
  934. # concede_home = item["concede_home"]
  935. # concede_home_rule = item["concede_home_rule"]
  936. # # concede_guest
  937. # for index, value in enumerate(concede_guest):
  938. # hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
  939. # value) + "hg3535" + str(match_id)
  940. # sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
  941. # odds_only = Helper.genearte_MD5(hash_str)
  942. # sole = Helper.genearte_MD5(sole_str)
  943. # odds_onlys.append(odds_only)
  944. # concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  945. # "odds_only", "sole", "source", "type", "team"]
  946. # condition = fuhao(concede_guest[index])
  947. # concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
  948. # odds_only, sole, "hg3535", "0", ""]
  949. # concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
  950. # if odds_only not in uuid_list:
  951. # data_list.append(concede_guest_data)
  952. # # concede_home
  953. # for index, value in enumerate(concede_home):
  954. # hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
  955. # value) + "hg3535" + str(match_id)
  956. # sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
  957. # odds_only = Helper.genearte_MD5(hash_str)
  958. # sole = Helper.genearte_MD5(sole_str)
  959. # odds_onlys.append(odds_only)
  960. # concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  961. # "odds_only", "sole", "source", "type", "team"]
  962. # condition = fuhao(concede_home_rule[index])
  963. # concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
  964. # sole, "hg3535", "0", ""]
  965. # concede_guest_data = dict(zip(concede_home_key, concede_home_value))
  966. # if odds_only not in uuid_list:
  967. # data_list.append(concede_guest_data)
  968. #
  969. # # 独赢----------------------------------------------------------------------------------------------------------
  970. # # p_code, p_id = get_pcode(corner_ball, 'capot')
  971. # p_code = 'C'
  972. # half_capot_home = item["half_capot_home"]
  973. # half_capot_guest = item["half_capot_guest"]
  974. # half_capot_dogfall = item["half_capot_dogfall"]
  975. # capot_home = item["capot_home"]
  976. # capot_guest = item["capot_guest"]
  977. # capot_dogfall = item["capot_dogfall"]
  978. #
  979. # # half_capot_home
  980. # hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
  981. # sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
  982. # odds_only = Helper.genearte_MD5(hash_str)
  983. # sole = Helper.genearte_MD5(sole_str)
  984. # odds_onlys.append(odds_only)
  985. # half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  986. # "odds_only", "sole", "source", "type", "team"]
  987. # half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
  988. # odds_only, sole, "hg3535", "0", ""]
  989. # half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
  990. # if odds_only not in uuid_list:
  991. # data_list.append(half_capot_homet_data)
  992. #
  993. # # half_capot_guest
  994. # hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
  995. # sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
  996. # odds_only = Helper.genearte_MD5(hash_str)
  997. # sole = Helper.genearte_MD5(sole_str)
  998. # odds_onlys.append(odds_only)
  999. # half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1000. # "odds_only", "sole", "source", "type", "team"]
  1001. # half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
  1002. # odds_only, sole, "hg3535", "0", ""]
  1003. # half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
  1004. # if odds_only not in uuid_list:
  1005. # data_list.append(half_capot_guest_data)
  1006. #
  1007. # # half_capot_dogfall
  1008. # hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
  1009. # sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
  1010. # odds_only = Helper.genearte_MD5(hash_str)
  1011. # sole = Helper.genearte_MD5(sole_str)
  1012. # odds_onlys.append(odds_only)
  1013. # half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1014. # "odds_only", "sole", "source", "type", "team"]
  1015. # half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
  1016. # odds_only, sole, "hg3535", "0", ""]
  1017. # half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
  1018. # if odds_only not in uuid_list:
  1019. # data_list.append(half_capot_dogfall_data)
  1020. #
  1021. # # capot_dogfall
  1022. # hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
  1023. # sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
  1024. # odds_only = Helper.genearte_MD5(hash_str)
  1025. # sole = Helper.genearte_MD5(sole_str)
  1026. # odds_onlys.append(odds_only)
  1027. # capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1028. # "odds_only", "sole", "source", "type", "team"]
  1029. # capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
  1030. # sole, "hg3535", "0", ""]
  1031. # capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
  1032. # if odds_only not in uuid_list:
  1033. # data_list.append(capot_dogfall_data)
  1034. #
  1035. # # capot_home
  1036. # hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
  1037. # sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
  1038. # odds_only = Helper.genearte_MD5(hash_str)
  1039. # sole = Helper.genearte_MD5(sole_str)
  1040. # odds_onlys.append(odds_only)
  1041. # capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1042. # "odds_only", "sole", "source", "type", "team"]
  1043. # capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
  1044. # odds_only, sole, "hg3535", "0", ""]
  1045. # capot_homet_data = dict(zip(capot_home_key, capot_home_value))
  1046. # if odds_only not in uuid_list:
  1047. # data_list.append(capot_homet_data)
  1048. #
  1049. # # capot_guest
  1050. # hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
  1051. # sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
  1052. # odds_only = Helper.genearte_MD5(hash_str)
  1053. # sole = Helper.genearte_MD5(sole_str)
  1054. # odds_onlys.append(odds_only)
  1055. # capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1056. # "odds_only", "sole", "source", "type", "team"]
  1057. # capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_home, '2',
  1058. # odds_only, sole, "hg3535", "0", ""]
  1059. # capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
  1060. # if odds_only not in uuid_list:
  1061. # data_list.append(capot_guest_data)
  1062. #
  1063. # # 入球数单双-----------------------------------------------------------------------------------------------------
  1064. # # p_code, p_id = get_pcode(corner_ball, 'two_sides')
  1065. # p_code = 'TS'
  1066. # odd_even_odd = item["odd_even_odd"]
  1067. # odd_even_even = item["odd_even_even"]
  1068. # half_odd_even_odd = item["half_odd_even_odd"]
  1069. # half_odd_even_even = item["half_odd_even_even"]
  1070. #
  1071. # # odd_even_odd
  1072. # hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
  1073. # sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
  1074. # odds_only = Helper.genearte_MD5(hash_str)
  1075. # sole = Helper.genearte_MD5(sole_str)
  1076. # odds_onlys.append(odds_only)
  1077. # single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1078. # "odds_only", "sole", "source", "type", "team"]
  1079. # single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
  1080. # odds_only, sole, "hg3535", "0", ""]
  1081. # single_data = dict(zip(single_key, single_value))
  1082. # if odds_only not in uuid_list:
  1083. # data_list.append(single_data)
  1084. #
  1085. # # odd_even_even
  1086. # hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
  1087. # sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
  1088. # odds_only = Helper.genearte_MD5(hash_str)
  1089. # sole = Helper.genearte_MD5(sole_str)
  1090. # odds_onlys.append(odds_only)
  1091. # double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1092. # "odds_only", "sole", "source", "type", "team"]
  1093. # double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
  1094. # odds_only, sole, "hg3535", "0", ""]
  1095. # double_data = dict(zip(double_key, double_value))
  1096. # if odds_only not in uuid_list:
  1097. # data_list.append(double_data)
  1098. #
  1099. # # half_odd_even_even
  1100. # hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
  1101. # sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
  1102. # odds_only = Helper.genearte_MD5(hash_str)
  1103. # sole = Helper.genearte_MD5(sole_str)
  1104. # odds_onlys.append(odds_only)
  1105. # half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1106. # "odds_only", "sole", "source", "type", "team"]
  1107. # half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
  1108. # odds_only, sole, "hg3535", "0", ""]
  1109. # half_double_data = dict(zip(half_double_key, half_double_value))
  1110. # if odds_only not in uuid_list:
  1111. # data_list.append(half_double_data)
  1112. #
  1113. # # half_odd_even_odd
  1114. # hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
  1115. # sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
  1116. # odds_only = Helper.genearte_MD5(hash_str)
  1117. # sole = Helper.genearte_MD5(sole_str)
  1118. # odds_onlys.append(odds_only)
  1119. # half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1120. # "odds_only", "sole", "source", "type", "team"]
  1121. # half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
  1122. # sole, "hg3535", "0", ""]
  1123. # half_single_data = dict(zip(half_single_key, half_single_value))
  1124. # if odds_only not in uuid_list:
  1125. # data_list.append(half_single_data)
  1126. #
  1127. # # 总入球数 ------------------------------------------------------------------------------------------------------
  1128. # # p_code, p_id = get_pcode(corner_ball, 'total_goal')
  1129. # p_code = 'TG'
  1130. # total_goals = item['total_goal']
  1131. # total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6','tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
  1132. # "tg2_h": '2', "tg3_h": '3或以上'}
  1133. # # 全场入球数 单双
  1134. # # 上半场入球数 单双
  1135. # for key, value in total_goals.items():
  1136. # hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
  1137. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  1138. # odds_only = Helper.genearte_MD5(hash_str)
  1139. # sole = Helper.genearte_MD5(sole_str)
  1140. # odds_onlys.append(odds_only)
  1141. # total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1142. # "odds_only", "sole", "source", "type", "team"]
  1143. # total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
  1144. # sole, "hg3535", "0", ""]
  1145. # total_goals_data = dict(zip(total_goals_key, total_goals_value))
  1146. # if odds_only not in uuid_list:
  1147. # data_list.append(total_goals_data)
  1148. #
  1149. # # 全场半场 ------------------------------------------------------------------------------------------------------
  1150. # half_fulls = item['half_full']
  1151. # # p_code, p_id = get_pcode(corner_ball, 'half_full')
  1152. # p_code = 'HF'
  1153. # full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
  1154. # "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
  1155. # if half_fulls:
  1156. # for key, value in half_fulls.items():
  1157. # hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
  1158. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  1159. # odds_only = Helper.genearte_MD5(hash_str)
  1160. # sole = Helper.genearte_MD5(sole_str)
  1161. # odds_onlys.append(odds_only)
  1162. # half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1163. # "odds_only", "sole", "source", "type", "team"]
  1164. # half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
  1165. # sole, "hg3535", "0", ""]
  1166. # half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
  1167. # if odds_only not in uuid_list:
  1168. # data_list.append(half_fulls_data)
  1169. #
  1170. # # 波胆------------------------------------------------------------------------------------------------------------------
  1171. # bodan_datas = item['bodan_data']
  1172. # # p_code, p_id = get_pcode(corner_ball, 'bodan')
  1173. # p_code = 'B'
  1174. # bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
  1175. # "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
  1176. # "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
  1177. # "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
  1178. # "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
  1179. # "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
  1180. # "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
  1181. # "bo_h": "其他"}
  1182. # if bodan_datas:
  1183. # for key, value in bodan_datas.items():
  1184. # hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
  1185. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  1186. # odds_only = Helper.genearte_MD5(hash_str)
  1187. # sole = Helper.genearte_MD5(sole_str)
  1188. # odds_onlys.append(odds_only)
  1189. # bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1190. # "odds_only", "sole", "source", "type", "team"]
  1191. # bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
  1192. # sole, "hg3535", "0", ""]
  1193. # bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
  1194. # if odds_only not in uuid_list:
  1195. # data_list.append(bodan_dict_data)
  1196. #
  1197. # # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
  1198. # first_last_balls = item['first_last_ball']
  1199. # # p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
  1200. # p_code = 'FLB'
  1201. # first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
  1202. # if first_last_balls:
  1203. # for key, value in first_last_balls.items():
  1204. # hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
  1205. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  1206. # odds_only = Helper.genearte_MD5(hash_str)
  1207. # sole = Helper.genearte_MD5(sole_str)
  1208. # odds_onlys.append(odds_only)
  1209. # first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  1210. # "odds_only", "sole", "source", "type", "team"]
  1211. # first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key], odds_only,
  1212. # sole, "hg3535", "0", ""]
  1213. # first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
  1214. # if odds_only not in uuid_list:
  1215. # data_list.append(first_last_balls_data)
  1216. #
  1217. # # p_code, p_id = get_pcode(corner_ball, 'tema_ball')
  1218. # # 球队得分大小
  1219. # p_code = 'TB'
  1220. # # 全场
  1221. # full_dicts = item['full_data']
  1222. # # 上半场
  1223. # half_dicts = item['half_data']
  1224. # full_dict_rules = item['full_data_rule']
  1225. # half_dict_rules = item['half_data_rule']
  1226. # if full_dicts:
  1227. # for key, value in full_dicts.items():
  1228. # hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  1229. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  1230. # odds_only = Helper.genearte_MD5(hash_str)
  1231. # sole = Helper.genearte_MD5(sole_str)
  1232. # odds_onlys.append(odds_only)
  1233. # full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  1234. # "condition", "odds_only", "sole", "source", "type", "team"]
  1235. # full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
  1236. # odds_only,sole, "hg3535", "0", ""]
  1237. # full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
  1238. # if odds_only not in uuid_list:
  1239. # data_list.append(full_dict_rules_data)
  1240. # #
  1241. # if half_dicts:
  1242. # for key, value in half_dicts.items():
  1243. # hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  1244. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  1245. # odds_only = Helper.genearte_MD5(hash_str)
  1246. # sole = Helper.genearte_MD5(sole_str)
  1247. # odds_onlys.append(odds_only)
  1248. # half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  1249. # "condition","odds_only", "sole", "source", "type", "team"]
  1250. # half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
  1251. # odds_only, sole, "hg3535", "0", ""]
  1252. # half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
  1253. # if odds_only not in uuid_list:
  1254. # data_list.append(half_dicts_data)
  1255. # if pt == '3':
  1256. # ris_stringscene = 1
  1257. # else:
  1258. # ris_stringscene = 0
  1259. # odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid", "is_stringscene", "utime", "pt"]
  1260. # odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid, ris_stringscene, utime, pt]
  1261. # odds_dict = dict(zip(odds_key, odds_value))
  1262. # if data_list:
  1263. # # print(odds_dict)
  1264. # response_data = Helper.async_post(url + '/setOdds', odds_dict)
  1265. # print(response_data)
  1266. # if "成功" in response_data:
  1267. # if result:
  1268. # self.db.hg3535_zq_odds.update({'match_id': match_id, 'pt': pt}, {'$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
  1269. # else:
  1270. # self.db.hg3535_zq_odds.insert(odds_dict)