浏览代码

更新篮球, 父级玩法错误

Your Name 6 年之前
父节点
当前提交
3b9da1adfe
共有 3 个文件被更改,包括 106 次插入103 次删除
  1. 7 6
      hg3535/pipeline/jieshu.py
  2. 39 38
      hg3535/pipeline/lanqiu.py
  3. 60 59
      hg3535/spiders/lanqiu.py

+ 7 - 6
hg3535/pipeline/jieshu.py

@@ -45,18 +45,19 @@ class Jieshuqiupipeline(object):
         update = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
         data_list = []
         if status:
-            status = 1
+            ostatus = 1
         else:
-            status = 2
-        data = {'match_id': match_id, 'status': status, "is_rollball": 0, "is_today": 0, "is_morningplate": 0, "is_stringscene": 0, "is_horn": 0, 'game_code': game_code, 'update': update}
+            ostatus = 2
+        data = {'match_id': match_id, 'status': ostatus, "is_rollball": 0, "is_today": 0, "is_morningplate": 0, "is_stringscene": 0, "is_horn": 0, 'game_code': game_code, 'update': update}
         data_list.append(data)
         status_dict['data'] = data_list
         res = Helper.async_post(MATCH_STATUS, status_dict)
         if res:
             if "成功" in res:
-                # self.db.match_status35.insert(data)
-                self.db.match_status35.update({'match_id': match_id}, {'$set': data}, upsert=True)
-                self.rls.srem('hg3535.gunqiu.ids', match_id)
+                self.db.match_status35.insert(data)
+                # self.db.match_status35.update({'match_id': match_id}, {'$set': data}, upsert=True)
+                if ostatus == 2:
+                    self.rls.srem('hg3535.gunqiu.ids', match_id)
                 logger.info('{},赛事结果状态交成功, {}'.format(game_code, res))
                 logger.info(status_dict)
             else:

+ 39 - 38
hg3535/pipeline/lanqiu.py

@@ -202,54 +202,55 @@ class Lanqiupipeline(object):
                     for index, total_sizes_value in enumerate(value):
                         sole_str = 'TN' + str(key) + str(match_id) + 'hg3535'
                         sole = Helper.genearte_MD5(sole_str, pt)
-                        odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
-                            total_sizes_dict_rule[key][index]) + str(total_sizes_value)
-                        odds_only = Helper.genearte_MD5(odds_str, pt)
+                        # odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
+                        #     total_sizes_dict_rule[key][index]) + str(total_sizes_value)
                         condition = str(total_sizes_dict_rule[key][index])
+                        hash_str = "TN" + condition + '0' + '0' + str(total_sizes_value) + "hg3535" + str(match_id)
+                        odds_only = Helper.genearte_MD5(hash_str, pt)
                         total_sizes_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                            "condition", "odds_only", "sole", "source", "type", "team"]
                         total_sizes_value = [match_id, league_id, key, '0', index, 'TN', total_sizes_value, condition,
                                              odds_only, sole, 'hg3535', '0', '']
                         total_sizes_data = dict(zip(total_sizes_key, total_sizes_value))
                         data_list.append(total_sizes_data)
-                else:
-                    sole_str = 'TN' + str(key) + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str, pt)
-                    odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
-                        total_sizes_dict_rule[key]) + str(value)
-                    odds_only = Helper.genearte_MD5(odds_str, pt)
-                    condition = str(total_sizes_dict_rule[key])
-                    total_sizes_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
-                                       "condition", "odds_only", "sole", "source", "type", "team"]
-                    total_sizes_value = [match_id, league_id, key, '0', 0, 'TN', value, condition,
-                                         odds_only, sole, 'hg3535', '0', '']
-                    total_sizes_data = dict(zip(total_sizes_key, total_sizes_value))
-                    data_list.append(total_sizes_data)
+                # else:
+                #     sole_str = "TN" + str(key) + '0' + str(match_id) + "hg3535"
+                #     sole = Helper.genearte_MD5(sole_str, pt)
+                #     condition = str(total_sizes_dict_rule[key])
+                #     hash_str = "TN" + key + '0' + '0' + str(value) + "hg3535" + str(match_id)
+                #     odds_only = Helper.genearte_MD5(hash_str, pt)
+                #     total_sizes_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                #                        "condition", "odds_only", "sole", "source", "type", "team"]
+                #     total_sizes_value = [match_id, league_id, key, '0', 0, 'TN', value, condition,
+                #                          odds_only, sole, 'hg3535', '0', '']
+                #     total_sizes_data = dict(zip(total_sizes_key, total_sizes_value))
+                #     data_list.append(total_sizes_data)
         # 球队得分大小
         if team_scores_dict:
             for key, value in team_scores_dict.items():
-                sole_str = 'TB' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str, pt)
-                odds_str = 'TB' + str(key) + str(match_id) + 'hg3535' + str(
-                    team_scores_dict_rule[key]) + str(value)
-                odds_only = Helper.genearte_MD5(odds_str, pt)
-                condition = str(team_scores_dict_rule[key])
-                team_scores_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
-                                   "condition", "odds_only", "sole", "source", "type", "team"]
-                team_scores_value = [match_id, league_id, key, '0', 0, 'TB', value, condition,
-                                     odds_only, sole, 'hg3535', '0', '']
-                team_scores_data = dict(zip(team_scores_key, team_scores_value))
-                data_list.append(team_scores_data)
+                if value:
+                    for index, odd in enumerate(value):
+                        sole_str = "TB" + str(key) + '0' + str(match_id) + "hg3535"
+                        sole = Helper.genearte_MD5(sole_str, pt)
+                        condition = str(team_scores_dict_rule[key][index])
+                        hash_str = "TB" + key + str(index) + condition + str(odd) + "hg3535" + str(match_id)
+                        odds_only = Helper.genearte_MD5(hash_str, pt)
+                        team_scores_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                           "condition", "odds_only", "sole", "source", "type", "team"]
+                        team_scores_value = [match_id, league_id, key, '0', 0, 'TB', odd, condition,
+                                             odds_only, sole, 'hg3535', '0', '']
+                        team_scores_data = dict(zip(team_scores_key, team_scores_value))
+                        data_list.append(team_scores_data)
 
         # 球队得分最后一位数
         last_home_dict = {'0或5': 'lnh0', '1或6': 'lnh1', '2或7': 'lnh2', '3或8': 'lnh3', '4或9': 'lnh4'}
         last_home = last_numbers_dict['last_home']
         if last_home:
             for key, value in last_home.items():
-                sole_str = 'LN' + last_home_dict[key] + str(match_id) + 'hg3535'
+                sole_str = "LN" + last_home_dict[key] + '0' + str(match_id) + "hg3535"
                 sole = Helper.genearte_MD5(sole_str, pt)
-                odds_str = 'LN' + last_home_dict[key] + str(match_id) + 'hg3535' + '0' + str(value)
-                odds_only = Helper.genearte_MD5(odds_str, pt)
+                hash_str = "LN" + last_home_dict[key] + '0' + key + str(value) + "hg3535" + str(match_id)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
                 last_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                     "condition", "odds_only", "sole", "source", "type", "team"]
                 last_home_value = [match_id, league_id, last_home_dict[key], '0', 0, 'LN', value, key, odds_only, sole, 'hg3535', '0', '']
@@ -260,23 +261,23 @@ class Lanqiupipeline(object):
         last_guest_dict = {'0或5': 'lng0', '1或6': 'lng1', '2或7': 'lng2', '3或8': 'lng3', '4或9': 'lng4'}
         if last_guest:
             for key, value in last_guest.items():
-                sole_str = 'LN' + last_guest_dict[key] + str(match_id) + 'hg3535'
+                sole_str = "LN" + last_guest_dict[key] + '0' + str(match_id) + "hg3535"
                 sole = Helper.genearte_MD5(sole_str, pt)
-                odds_str = 'LN' + last_guest_dict[key] + str(match_id) + 'hg3535' + '0' + str(value)
-                odds_only = Helper.genearte_MD5(odds_str, pt)
+                hash_str = "LN" + last_guest_dict[key] + '0' + key + str(value) + "hg3535" + str(match_id)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
                 last_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                     "condition", "odds_only", "sole", "source", "type", "team"]
-                last_guest_value = [match_id, league_id, key, '0', 0, 'LN', value, key, odds_only, sole, 'hg3535', '0', '']
+                last_guest_value = [match_id, league_id, last_guest_dict[key], '0', 0, 'LN', value, key, odds_only, sole, 'hg3535', '0', '']
                 last_guest_data = dict(zip(last_guest_key, last_guest_value))
                 data_list.append(last_guest_data)
 
         # 独赢
         if capots_dict:
             for key, value in capots_dict.items():
-                sole_str = 'C' + str(key) + str(match_id) + 'hg3535'
+                sole_str = "C" + str(key) + '0' + str(match_id) + "hg3535"
                 sole = Helper.genearte_MD5(sole_str, pt)
-                odds_str = 'C' + str(key) + str(match_id) + 'hg3535' + str(value)
-                odds_only = Helper.genearte_MD5(odds_str, pt)
+                hash_str = "C" + str(key) + '0' + str(key) + str(value) + "hg3535" + str(match_id)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
                 capots_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                               "condition", "odds_only", "sole", "source", "type", "team"]
                 capots_value = [match_id, league_id, key, '0', 0, 'C', value, '',

+ 60 - 59
hg3535/spiders/lanqiu.py

@@ -77,14 +77,15 @@ class LanqiuSpider(scrapy.Spider):
                         up_time = str(time.time()) + '&' + 'lq'
                         self.rls.hset('hg3535.ball.ids', game_id, up_time)
                         if pt == 1:
+                            game_id = 3446985
                             url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/false".format(game_id)
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
-                        if pt == 2:
-                            url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/false".format(game_id)
-                            yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
-                        if pt == 3:
-                            url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/true".format(game_id)
-                            yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
+                        # if pt == 2:
+                        #     url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/false".format(game_id)
+                        #     yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
+                        # if pt == 3:
+                        #     url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/true".format(game_id)
+                        #     yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
 
     def parse_each(self, response):
         try:
@@ -444,8 +445,8 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["ch"] = capot_home
                         capots_dict["cg"] = capot_guest
                     except:
-                        capots_dict["ch"] = ""
-                        capots_dict["cg"] = ""
+                        capots_dict["ch"] = 0
+                        capots_dict["cg"] = 0
 
                     # 上半场独赢
                     try:
@@ -456,8 +457,8 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["ch_h"] = half_capot_home
                         capots_dict["cg_h"] = half_capot_guest
                     except:
-                        capots_dict["ch_h"] = ""
-                        capots_dict["cg_h"] = ""
+                        capots_dict["ch_h"] = 0
+                        capots_dict["cg_h"] = 0
 
                     # 第一节独赢
                     try:
@@ -468,8 +469,8 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["ch_1"] = one_capot_home
                         capots_dict["cg_1"] = one_capot_guest
                     except:
-                        capots_dict["ch_1"] = ""
-                        capots_dict["cg_1"] = ""
+                        capots_dict["ch_1"] = 0
+                        capots_dict["cg_1"] = 0
 
                     # 第二节独赢
                     try:
@@ -492,8 +493,8 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["ch_3"] = three_capot_home
                         capots_dict["cg_3"] = three_capot_guest
                     except:
-                        capots_dict["ch_3"] = ""
-                        capots_dict["cg_3"] = ""
+                        capots_dict["ch_3"] = 0
+                        capots_dict["cg_3"] = 0
 
                     # 第四节独赢
                     try:
@@ -504,8 +505,8 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["ch_4"] = four_capot_home
                         capots_dict["cg_4"] = four_capot_guest
                     except:
-                        capots_dict["ch_4"] = ""
-                        capots_dict["cg_4"] = ""
+                        capots_dict["ch_4"] = 0
+                        capots_dict["cg_4"] = 0
 
                 # ---------------------------------------------------华丽分割线列表es[1]-----------------------------------
                 # 球队得分 全场主队 home
@@ -525,10 +526,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbhs"] = score_home_small_rule
                             team_scores_dict["tbhs"] = score_home_small
                         except:
-                            team_scores_dict_rule["tbhb"] = ""
-                            team_scores_dict["tbhb"] = ""
-                            team_scores_dict_rule["tbhs"] = ""
-                            team_scores_dict["tbhs"] = ""
+                            team_scores_dict_rule["tbhb"] = 0
+                            team_scores_dict["tbhb"] = 0
+                            team_scores_dict_rule["tbhs"] = 0
+                            team_scores_dict["tbhs"] = 0
                         # 球队得分 上半场主队 home
                         try:
                             half_score_homes = score_home['o']['ou1st']['v']
@@ -540,10 +541,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbhs_h"] = half_score_home_small_rule
                             team_scores_dict["tbhs_h"] = half_score_home_small
                         except:
-                            team_scores_dict_rule["tbhb_h"] = ""
-                            team_scores_dict["tbhb_h"] = ""
-                            team_scores_dict_rule["tbhs_h"] = ""
-                            team_scores_dict["tbhs_h"] = ""
+                            team_scores_dict_rule["tbhb_h"] = 0
+                            team_scores_dict["tbhb_h"] = 0
+                            team_scores_dict_rule["tbhs_h"] = 0
+                            team_scores_dict["tbhs_h"] = 0
 
                         # 球队得分:主队-大 / 小-第一节
                         try:
@@ -555,10 +556,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbhs_1"] = one_score_home_small_rule
                             team_scores_dict["tbhs_1"] = one_score_home_small
                         except:
-                            team_scores_dict_rule["tbhb_1"] = ""
-                            team_scores_dict["tbhb_1"] = ""
-                            team_scores_dict_rule["tbhs_1"] = ""
-                            team_scores_dict["tbhs_1"] = ""
+                            team_scores_dict_rule["tbhb_1"] = 0
+                            team_scores_dict["tbhb_1"] = 0
+                            team_scores_dict_rule["tbhs_1"] = 0
+                            team_scores_dict["tbhs_1"] = 0
 
                         # 球队得分:主队-大 / 小-第一节
                         try:
@@ -570,10 +571,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbhs_2"] = two_score_home_small_rule
                             team_scores_dict["tbhs_2"] = two_score_home_small
                         except:
-                            team_scores_dict_rule["tbhb_2"] = ""
-                            team_scores_dict["tbhb_2"] = ""
-                            team_scores_dict_rule["tbhs_2"] = ""
-                            team_scores_dict["tbhs_2"] = ""
+                            team_scores_dict_rule["tbhb_2"] = 0
+                            team_scores_dict["tbhb_2"] = 0
+                            team_scores_dict_rule["tbhs_2"] = 0
+                            team_scores_dict["tbhs_2"] = 0
 
                         # 球队得分:主队-大 / 小-第一节
                         try:
@@ -585,10 +586,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbhs_3"] = three_score_home_small_rule
                             team_scores_dict["ybhs_3"] = three_score_home_small
                         except:
-                            team_scores_dict_rule["tbhb_3"] = ""
+                            team_scores_dict_rule["tbhb_3"] = 0
                             team_scores_dict["tbhb_3"] = ""
-                            team_scores_dict_rule["tbhs_3"] = ""
-                            team_scores_dict["tbhs_3"] = ""
+                            team_scores_dict_rule["tbhs_3"] = 0
+                            team_scores_dict["tbhs_3"] = 0
 
                         # 球队得分:主队-大 / 小-第四节
                         try:
@@ -623,10 +624,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbgs"] = score_guest_small_rule
                             team_scores_dict["tbgs"] = score_guest_small
                         except:
-                            team_scores_dict_rule["tbgb"] = ""
-                            team_scores_dict["tbgb"] = ""
-                            team_scores_dict_rule["tbgs"] = ""
-                            team_scores_dict["tbgs"] = ""
+                            team_scores_dict_rule["tbgb"] = 0
+                            team_scores_dict["tbgb"] = 0
+                            team_scores_dict_rule["tbgs"] = 0
+                            team_scores_dict["tbgs"] = 0
 
                         # 球队得分 上半场客队 guest
                         try:
@@ -638,10 +639,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbgs_h"] = half_score_guest_small_rule
                             team_scores_dict["tbgs_h"] = half_score_guest_small
                         except:
-                            team_scores_dict_rule["tbgb_h"] = ""
-                            team_scores_dict["tbgb_h"] = ""
-                            team_scores_dict_rule["tbgs_h"] = ""
-                            team_scores_dict["tbgs_h"] = ""
+                            team_scores_dict_rule["tbgb_h"] = 0
+                            team_scores_dict["tbgb_h"] = 0
+                            team_scores_dict_rule["tbgs_h"] = 0
+                            team_scores_dict["tbgs_h"] = 0
                         # 球队得分第一节
                         try:
                             one_score_guests = score_guest["o"]['ouq1']['v']
@@ -652,10 +653,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbgs_1"] = one_score_guest_small_rule
                             team_scores_dict["tbgs_1"] = one_score_guest_small
                         except:
-                            team_scores_dict_rule["tbgb_1"] = ""
-                            team_scores_dict["tbgb_1"] = ""
-                            team_scores_dict_rule["tbgs_1"] = ""
-                            team_scores_dict["tbgs_1"] = ""
+                            team_scores_dict_rule["tbgb_1"] = 0
+                            team_scores_dict["tbgb_1"] = 0
+                            team_scores_dict_rule["tbgs_1"] = 0
+                            team_scores_dict["tbgs_1"] = 0
 
                         # 球队得分第二节
                         try:
@@ -667,10 +668,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbgs_2"] = two_score_guest_small_rule
                             team_scores_dict["tbgs_2"] = two_score_guest_small
                         except:
-                            team_scores_dict_rule["tbgb_2"] = ""
-                            team_scores_dict["tbgb_2"] = ""
-                            team_scores_dict_rule["tbgs_2"] = ""
-                            team_scores_dict["tbgs_2"] = ""
+                            team_scores_dict_rule["tbgb_2"] = 0
+                            team_scores_dict["tbgb_2"] = 0
+                            team_scores_dict_rule["tbgs_2"] = 0
+                            team_scores_dict["tbgs_2"] = 0
                         # 球队得分第三节
                         try:
                             three_score_guests = score_guest["o"]['ouq3']['v']
@@ -681,10 +682,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbgs_3"] = three_score_guest_small_rule
                             team_scores_dict["tbgs_3"] = three_score_guest_small
                         except:
-                            team_scores_dict_rule["tbgb_3"] = ""
-                            team_scores_dict["tbgb_3"] = ""
-                            team_scores_dict_rule["tbgs_3"] = ""
-                            team_scores_dict["tbgs_3"] = ""
+                            team_scores_dict_rule["tbgb_3"] = 0
+                            team_scores_dict["tbgb_3"] = 0
+                            team_scores_dict_rule["tbgs_3"] = 0
+                            team_scores_dict["tbgs_3"] = 0
                         # 球队得分第四节
                         try:
                             four_score_guests = score_guest["o"]['ouq4']['v']
@@ -695,10 +696,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["tbgs_4"] = four_score_guest_small_rule
                             team_scores_dict["tbgs_4"] = four_score_guest_small
                         except:
-                            team_scores_dict_rule["tbgb_4"] = ""
-                            team_scores_dict["tbgb_4"] = ""
-                            team_scores_dict_rule["tbgs_4"] = ""
-                            team_scores_dict["tbgs_4"] = ""
+                            team_scores_dict_rule["tbgb_4"] = 0
+                            team_scores_dict["tbgb_4"] = 0
+                            team_scores_dict_rule["tbgs_4"] = 0
+                            team_scores_dict["tbgs_4"] = 0
 
             # 联赛id
             item['league_id'] = league_id