| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 |
- # import datetime
- import pymongo
- import time
- import logging
- from ball_func import fuhao
- from ..utils.helper import Helper
- from .ball_func import get_pcode
- # 滚球足球 插入
- class Roll_Zuqiupipeline(object):
- def open_spider(self, spider):
- self.mongo = pymongo.MongoClient(host="192.168.2.200", username="kaiyou", password="kaiyou", port=27017)
- self.db = self.mongo['kaiyou']
- def process_item(self, item, spider):
- logger = logging.getLogger(__name__)
- url = 'http://admin.5gogo.com'
- pt = 4
- roll_zq = []
- # 比赛日期
- try:
- data_game = item['data_game'].split("/")
- month = str(data_game[1].strip())
- day = str(data_game[0])
- except Exception as e:
- logger.warning(e)
- data_game = item['data_game'].split(" ")
- months = str(data_game[1].strip())
- month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
- month = month_dict[months]
- day = str(data_game[0])
- # 比赛时间
- time_game = str(item['time_game'])
- # print(time_game)
- # 比赛时间,时间戳
- ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
- r_ctime = "2019" + "-" + month + "-" + day
- # 现在时间,时间戳
- utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
- expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
- # 比赛id
- match_id = item['game_id']
- # 联赛id
- league_id = item['league_id']
- # 联赛name
- league_name = item['league_name']
- # 主队
- team_home = item['team_home']
- # 客队
- team_guest = item['team_guest']
- # number
- number = item['number']
- score_home = item['score_home']
- score_guest = item['score_guest']
- all_goal = int(score_home) + int(score_guest)
- half_way = item['half_way']
- # pt = item['pt']
- match_score = "{}:{}".format(score_home,score_guest)
- corner_ball = item['corner_ball']
- last_time = '2019-12-31 23:59:59'
- league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
- league_list = []
- uuid = Helper.genearte_MD5(league_name + 'hg3535')
- league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
- league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
- league_data = dict(zip(league_key, league_value))
- league_list.append(league_data)
- league_dict['data'] = league_list
- if self.db.hg3535_zq_league.find({'league_id': league_id}).count() < 1:
- response_data = Helper.async_post(url + '/setLeague', league_dict)
- print('足球联赛请求成功', response_data)
- if "成功" in response_data:
- self.db.hg3535_zq_league.insert(league_list)
- competition = self.db.hg3535_zq_competition.find_one({"match_id": match_id})
- match_list = []
- if competition:
- print('赛事已存在,修改赛事四状态')
- is_morningplate = competition['is_morningplate']
- is_rollball = competition['is_rollball']
- is_stringscene = competition['is_stringscene']
- is_today = competition['is_today']
- status = competition['status']
- match_date = competition['match_date']
- match_time = competition['match_time']
- us_time = competition['us_time']
- # if pt == '3':
- if is_rollball != 1 or status != 1:
- match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
- match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
- "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
- "half_match_id", "is_today"]
- match_value = [team_home, team_guest, league_id, 1, match_id, match_date, match_time, number,
- "hg3535", 1, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
- match_data = dict(zip(match_kay, match_value))
- match_list.append(match_data)
- match_dict['data'] = match_list
- print(match_dict)
- response_data = Helper.async_post(url + '/setMatch', match_dict)
- print('足球赛事请求成功', response_data)
- if "成功" in response_data:
- self.db.hg3535_zq_competition.update({'match_id': match_id}, {"$set": {"is_rollball": 1, "status": 1}},
- upsert=True)
- else:
- print("赛事已存在,赛事状态时间为改变,不做修改")
- else:
- is_rollball = 1
- is_today = 0
- is_morningplate = 0
- is_stringscene = 0
- # 赛事接口写入
- match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
- match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time", "tag",
- "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
- "half_match_id", "is_today"]
- match_value = [team_home, team_guest, league_id, 1, match_id, r_ctime, "00:00", number, "hg3535",
- is_rollball, is_morningplate, is_stringscene, utime, uuid, 0, is_today]
- match_data = dict(zip(match_kay, match_value))
- match_list.append(match_data)
- match_dict['data'] = match_list
- response_data = Helper.async_post(url + '/setMatch', match_dict)
- print(match_dict)
- print('足球赛事请求成功', response_data)
- if "成功" in response_data:
- self.db.hg3535_zq_competition.insert(match_list)
- # print(response_data)
- # 赔率
- try:
- result = self.db.hg3535_zq_odds.find_one({'match_id': match_id, 'pt': pt})
- uuid_list = result['odds_only']
- except:
- uuid_list = []
- result = ''
- p_code, p_id = get_pcode(corner_ball, 'goal_size')
- # 构建唯一索引
- half_size_guest = item["half_size_guest"]
- half_size_guest_rule = item["half_size_guest_rule"]
- half_size_home = item["half_size_home"]
- half_size_home_rule = item["half_size_home_rule"]
- # zuqiu = item['zuqiu']
- data_list = []
- odds_onlys = []
- # half_size_guest
- for index, value in enumerate(half_size_guest):
- hash_str = p_code + "half_size_guest" + str(index) + str(half_size_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "half_size_guest" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(half_size_guest_rule[index])
- half_size_guest_value = [match_id, league_id, "half_size_guest", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
- if odds_only not in uuid_list:
- data_list.append(half_size_guest_data)
- # half_size_home
- for index, value in enumerate(half_size_home):
- hash_str = p_code + "half_size_home" + str(index) + str(half_size_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "half_size_home" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(half_size_home_rule[index])
- half_size_home_value = [match_id, league_id, "half_size_guest", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
- if odds_only not in uuid_list:
- data_list.append(half_size_home_data)
- # 全场场大小
- size_guest = item["size_guest"]
- size_guest_rule = item["size_guest_rule"]
- size_home = item["size_home"]
- size_home_rule = item["size_home_rule"]
- # size_home
- for index, value in enumerate(size_home):
- hash_str = p_code + "size_home" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
- match_id)
- sole_str = p_code + "size_home" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(size_home_rule[index])
- size_home_value = [match_id, league_id, "size_home", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- size_home_data = dict(zip(size_home_key, size_home_value))
- if odds_only not in uuid_list:
- data_list.append(size_home_data)
- # size_guest
- for index, value in enumerate(size_guest):
- hash_str = p_code + "size_guest" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
- match_id)
- sole_str = p_code + "size_guest" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(size_guest_rule[index])
- size_guest_value = [match_id, league_id, "size_guest", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- size_home_data = dict(zip(size_guest_key, size_guest_value))
- if odds_only not in uuid_list:
- data_list.append(size_home_data)
- p_code, p_id = get_pcode(corner_ball, 'concede')
- half_concede_home_rule = item["half_concede_home_rule"]
- half_concede_home = item["half_concede_home"]
- half_concede_guest_rule = item["half_concede_guest_rule"]
- half_concede_guest = item["half_concede_guest"]
- # half_concede_home
- for index, value in enumerate(half_concede_guest):
- hash_str = p_code + "half_concede_guest" + str(index) + str(half_concede_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "half_concede_guest" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(half_concede_guest_rule[index])
- half_concede_guest_value = [match_id, league_id, "half_concede_guest", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
- if odds_only not in uuid_list:
- data_list.append(half_concede_guest_data)
- # half_concede_home
- for index, value in enumerate(half_concede_home):
- hash_str = p_code + "half_concede_home" + str(index) + str(half_concede_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "half_concede_home" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(half_concede_home_rule[index])
- half_concede_home_value = [match_id, league_id, "half_concede_home", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
- if odds_only not in uuid_list:
- data_list.append(half_concede_home_data)
- concede_guest = item["concede_guest"]
- concede_guest_rule = item["concede_guest_rule"]
- concede_home = item["concede_home"]
- concede_home_rule = item["concede_home_rule"]
- # concede_guest
- for index, value in enumerate(concede_guest):
- hash_str = p_code + "concede_guest" + str(index) + str(concede_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "concede_guest" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(concede_guest[index])
- concede_guest_value = [match_id, league_id, "concede_guest", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
- if odds_only not in uuid_list:
- data_list.append(concede_guest_data)
- # concede_home
- for index, value in enumerate(concede_home):
- hash_str = p_code + "concede_home" + str(index) + str(concede_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "concede_home" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = fuhao(concede_home_rule[index])
- concede_home_value = [match_id, league_id, "concede_home", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- concede_guest_data = dict(zip(concede_home_key, concede_home_value))
- if odds_only not in uuid_list:
- data_list.append(concede_guest_data)
- # 独赢----------------------------------------------------------------------------------------------------------
- p_code, p_id = get_pcode(corner_ball, 'capot')
- half_capot_home = item["half_capot_home"]
- half_capot_guest = item["half_capot_guest"]
- half_capot_dogfall = item["half_capot_dogfall"]
- capot_home = item["capot_home"]
- capot_guest = item["capot_guest"]
- capot_dogfall = item["capot_dogfall"]
- # half_capot_home
- hash_str = p_code + "half_capot_home" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
- sole_str = p_code + "half_capot_home" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_home_value = [match_id, league_id, "half_capot_home", "0", 0, p_code, half_capot_home, '1',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
- if odds_only not in uuid_list:
- data_list.append(half_capot_homet_data)
- # half_capot_guest
- hash_str = p_code + "half_capot_guest" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
- sole_str = p_code + "half_capot_guest" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_guest_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, half_capot_guest, '2',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
- if odds_only not in uuid_list:
- data_list.append(half_capot_guest_data)
- # half_capot_dogfall
- hash_str = p_code + "half_capot_dogfall" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
- sole_str = p_code + "half_capot_dogfall" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_dogfall_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, half_capot_dogfall, 'X',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
- if odds_only not in uuid_list:
- data_list.append(half_capot_dogfall_data)
- # capot_dogfall
- hash_str = p_code + "capot_dogfall" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
- sole_str = p_code + "capot_dogfall" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_dogfall_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, capot_dogfall, 'X', odds_only,
- sole, "hg3535", "0", ""]
- capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
- if odds_only not in uuid_list:
- data_list.append(capot_dogfall_data)
- # capot_home
- hash_str = p_code + "capot_home" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
- sole_str = p_code + "capot_home" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_home_value = [match_id, league_id, "half_capot_home", "0", 0, p_code, capot_home, '1',
- odds_only, sole, "hg3535", "0", ""]
- capot_homet_data = dict(zip(capot_home_key, capot_home_value))
- if odds_only not in uuid_list:
- data_list.append(capot_homet_data)
- # capot_guest
- hash_str = p_code + "capot_guest" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
- sole_str = p_code + "capot_guest" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_guest_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, capot_home, '2',
- odds_only, sole, "hg3535", "0", ""]
- capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
- if odds_only not in uuid_list:
- data_list.append(capot_guest_data)
- # 入球数单双-----------------------------------------------------------------------------------------------------
- p_code, p_id = get_pcode(corner_ball, 'two_sides')
- odd_even_odd = item["odd_even_odd"]
- odd_even_even = item["odd_even_even"]
- half_odd_even_odd = item["half_odd_even_odd"]
- half_odd_even_even = item["half_odd_even_even"]
- # odd_even_odd
- hash_str = p_code + "two_sides_single" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
- sole_str = p_code + "two_sides_single" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- single_value = [match_id, league_id, "two_sides_single", "0", 0, p_code, odd_even_odd, '单',
- odds_only, sole, "hg3535", "0", ""]
- single_data = dict(zip(single_key, single_value))
- if odds_only not in uuid_list:
- data_list.append(single_data)
- # odd_even_even
- hash_str = p_code + "two_sides_double" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
- sole_str = p_code + "two_sides_double" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- double_value = [match_id, league_id, "two_sides_double", "0", 0, p_code, odd_even_even, '双',
- odds_only, sole, "hg3535", "0", ""]
- double_data = dict(zip(double_key, double_value))
- if odds_only not in uuid_list:
- data_list.append(double_data)
- # half_odd_even_even
- hash_str = p_code + "two_sides_double" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
- sole_str = p_code + "two_sides_double" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_double_value = [match_id, league_id, "two_sides_double", "0", 0, p_code, half_odd_even_even, '双',
- odds_only, sole, "hg3535", "0", ""]
- half_double_data = dict(zip(half_double_key, half_double_value))
- if odds_only not in uuid_list:
- data_list.append(half_double_data)
- # half_odd_even_odd
- hash_str = p_code + "two_sides_single" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
- sole_str = p_code + "two_sides_single" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_single_value = [match_id, league_id, "two_sides_single", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
- sole, "hg3535", "0", ""]
- half_single_data = dict(zip(half_single_key, half_single_value))
- if odds_only not in uuid_list:
- data_list.append(half_single_data)
- # 总入球数 ------------------------------------------------------------------------------------------------------
- p_code, p_id = get_pcode(corner_ball, 'total_goal')
- total_goals = item['total_goal']
- total_dict = {'total_goal_zero': '0-1', 'total_goal_two': '2-3', 'total_goal_four': '4-6',
- 'total_goal_seven': '7或以上', 'half_total_goal_zero': '0', "half_total_goal_one": '1',
- "half_total_goal_two": '2', "half_total_goal_three": '3或以上'}
- # 全场入球数 单双
- # 上半场入球数 单双
- for key, value in total_goals.items():
- hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- total_goals_data = dict(zip(total_goals_key, total_goals_value))
- if odds_only not in uuid_list:
- data_list.append(total_goals_data)
- # 全场半场 ------------------------------------------------------------------------------------------------------
- half_fulls = item['half_full']
- p_code, p_id = get_pcode(corner_ball, 'half_full')
- full_dict = {"half_full_home_home": "主主", "half_full_home_dogfall": "主和",
- "half_full_home_guest": "主客", "half_full_dogfall_home": "和主",
- "half_full_dogfall_dogfall": "和和", "half_full_dogfall_guest": "和客",
- "half_full_guest_home": "客主", "half_full_guest_dogfall": "客和",
- "half_full_guest_guest": "客客"}
- if half_fulls:
- for key, value in half_fulls.items():
- hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
- if odds_only not in uuid_list:
- data_list.append(half_fulls_data)
- # 波胆------------------------------------------------------------------------------------------------------------------
- bodan_datas = item['bodan_data']
- p_code, p_id = get_pcode(corner_ball, 'bodan')
- bodan_dict = {"bodanhome_one_zero": "1-0", "bodanhome_two_zero": "2-0",
- "bodanhome_two_one": "2-1", "bodanhome_three_zero": "3-0",
- "bodanhome_three_one": "3-1", "bodanhome_three_two": "3-2",
- "bodanhome_four_zero": "4-0", "bodanhome_four_one": "4-1",
- "bodanhome_four_two": "4-2", "bodanhome_four_three": "4-3",
- "bodanguest_one_zero": "0-1", "bodanguest_two_zero": "0-2",
- "bodanguest_two_one": "1-2", "bodanguest_three_zero": "0-3",
- "bodanguest_three_one": "1-3", "bodanguest_three_two": "2-3",
- "bodanguest_four_zero": "0-4", "bodanguest_four_one": "1-4",
- "bodanguest_four_two": "2-4", "bodanguest_four_three": "3-4",
- "bodandogfall_zero_zero": "0-0", "bodandogfall_one_one": "1-1",
- "bodandogfall_two_two": "2-2", "bodandogfall_three_three": "3-3",
- "bodandogfall_four_four": "4-4", "bodanother": "其他",
- "halfbodanhome_one_zero": "1-0", "halfbodanhome_two_zero": "2-0",
- "halfbodanhome_two_one": "2-1", "halfbodanhome_three_zero": "3-0",
- "halfbodanhome_three_one": "3-1", "halfbodanhome_three_two": "3-2",
- "halfbodanguest_one_zero": "0-1", "halfbodanguest_two_zero": "0-2",
- "halfbodanguest_two_one": "1-2", "halfbodanguest_three_zero": "0-3",
- "halfbodanguest_three_one": "1-3", "halfbodanguest_three_two": "2-3",
- "halfbodandogfall_zero_zero": "0-0", "halfbodandogfall_one_one": "1-1",
- "halfbodandogfall_two_two": "2-2", "halfbodandogfall_three_three": "3-3",
- "halfbodanother": "其他"}
- if bodan_datas:
- for key, value in bodan_datas.items():
- hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
- if odds_only not in uuid_list:
- data_list.append(bodan_dict_data)
- # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
- first_last_balls = item['first_last_ball']
- p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
- first_last_dict = {"first_last_ball": "最先进球", "first_ball_home": "最先进球", "first_ball_guest": "最先进球",
- "last_ball_home": "最后进球", "last_ball_guest": "最后进球", "not_ball": "没有进球"}
- if first_last_balls:
- for key, value in first_last_balls.items():
- hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition",
- "odds_only", "sole", "source", "type", "team"]
- first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key],
- odds_only,
- sole, "hg3535", "0", ""]
- first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
- if odds_only not in uuid_list:
- data_list.append(first_last_balls_data)
- p_code, p_id = get_pcode(corner_ball, 'tema_ball')
- full_dicts = item['full_data']
- half_dicts = item['half_data']
- full_dict_rules = item['full_data_rule']
- half_dict_rules = item['half_data_rule']
- if full_dicts:
- for key, value in full_dicts.items():
- hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
- odds_only, sole, "hg3535", "0", ""]
- full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
- if odds_only not in uuid_list:
- data_list.append(full_dict_rules_data)
- if half_dicts:
- for key, value in half_dicts.items():
- hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str)
- sole = Helper.genearte_MD5(sole_str)
- odds_onlys.append(odds_only)
- half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
- odds_only, sole, "hg3535", "0", ""]
- half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
- if odds_only not in uuid_list:
- data_list.append(half_dicts_data)
- odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
- "is_stringscene", "utime", "pt"]
- odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, number, uuid,
- 0, utime, pt]
- odds_dict = dict(zip(odds_key, odds_value))
- if data_list:
- # print(odds_dict)
- response_data = Helper.async_post(url + '/setOdds', odds_dict)
- # print(response_data)
- print('足球赔率请求成功', response_data)
- if "成功" in response_data:
- if result:
- self.db.hg3535_zq_odds.update({'match_id': match_id, 'pt': pt}, {
- '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
- else:
- self.db.hg3535_zq_odds.insert(odds_dict)
- data_list = []
- zq_rball = {"home_team": team_home, "guest_team": team_guest,
- "lg_id": league_id, "home_rate": 0,
- "guest_rate": 0, "home_score": score_home,
- "guest_score": score_guest, "all_goal": all_goal, "status": 1,
- "first_score": "", "last_score": "", "match_score": match_score, "uuid": uuid,
- "match_winer": "", "match_time": time_game,
- "match_process": half_way, "tag": number,
- "match_id": match_id, "p_code": ""}
- data_list.append(zq_rball)
- r_data_dict = {
- "game_code": "zq",
- "title": "match_result_r",
- "source": "hg3535",
- "data": data_list
- }
- if data_list:
- try:
- response_data = Helper.async_post(url + '/setMatchResult', r_data_dict)
- print(r_data_dict)
- print("滚球赛事结果post提交", response_data)
- except Exception as e:
- logger.warning('滚球数据接口异常,提交失败')
- logger.warning(e)
|