|
@@ -1,17 +1,14 @@
|
|
|
import logging
|
|
import logging
|
|
|
from twisted.internet import defer, reactor
|
|
from twisted.internet import defer, reactor
|
|
|
from ..utils.helper import Helper
|
|
from ..utils.helper import Helper
|
|
|
-from ..settings import LEAGUE_URL, MATCH_URL
|
|
|
|
|
-import pymongo
|
|
|
|
|
-from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ZuqiuPipeline(object):
|
|
|
|
|
|
|
+from ..settings import LEAGUE_URL,MATCH_URL
|
|
|
|
|
+import pymongo,time
|
|
|
|
|
+from ..settings import M_HOST,M_USER,M_PASSWORD,M_POST,M_DB,ODDS_URL
|
|
|
|
|
+class LanqiuPipeline(object):
|
|
|
def open_spider(self, spider):
|
|
def open_spider(self, spider):
|
|
|
self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST,
|
|
self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST,
|
|
|
authSource=M_DB)
|
|
authSource=M_DB)
|
|
|
self.db = self.mongo[M_DB]
|
|
self.db = self.mongo[M_DB]
|
|
|
-
|
|
|
|
|
@defer.inlineCallbacks
|
|
@defer.inlineCallbacks
|
|
|
def process_item(self, item, spider):
|
|
def process_item(self, item, spider):
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
@@ -33,6 +30,45 @@ class ZuqiuPipeline(object):
|
|
|
elif type == "RB":
|
|
elif type == "RB":
|
|
|
is_rollball = 1
|
|
is_rollball = 1
|
|
|
else:
|
|
else:
|
|
|
|
|
+ is_stringscene=1
|
|
|
|
|
+ league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid","is_rollball","is_today","is_morningplate","is_stringscene"]
|
|
|
|
|
+ league_value = [league_name, "1", "1", "0", item['datetime'], item['match_id'], "hgg070", uuid,is_rollball,is_today,is_morningplate,is_stringscene]
|
|
|
|
|
+ #赛事
|
|
|
|
|
+ childer = dict(zip(league_key, league_value))
|
|
|
|
|
+ #联赛
|
|
|
|
|
+ obj = {"game_code": "lq", "title": "league", "source": "hgg070","data":[childer]}
|
|
|
|
|
+ res=Helper.async_post(LEAGUE_URL,obj)
|
|
|
|
|
+ if res:
|
|
|
|
|
+ if res.get('status')==1:
|
|
|
|
|
+ logging.warning("联赛提交成功,{}1".format(res))
|
|
|
|
|
+ #提交赛事
|
|
|
|
|
+ lres=Helper.async_post(MATCH_URL,childer)
|
|
|
|
|
+ if lres.get('status')==1:
|
|
|
|
|
+ logging.warning("赛事提交成功,{}2".format(res))
|
|
|
|
|
+ #保存赔率
|
|
|
|
|
+ # 是否串场
|
|
|
|
|
+ if item['isP'] == 'P':
|
|
|
|
|
+ ris_stringscene = 1
|
|
|
|
|
+ else:
|
|
|
|
|
+ ris_stringscene = 0
|
|
|
|
|
+ # 现在时间,时间戳
|
|
|
|
|
+ utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
|
|
+ odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
|
|
|
|
|
+ "is_stringscene", "utime", "pt", 'match_identity']
|
|
|
|
|
+ odds_value = ["lq", "odds", item['match_id'], item['league_id'], item["content"], "hgg070", [],
|
|
|
|
|
+ item['more_count'], uuid,
|
|
|
|
|
+ ris_stringscene, utime, item['isP'], item["match_identity"]]
|
|
|
|
|
+ # 赛事
|
|
|
|
|
+ odderlist = dict(zip(odds_key, odds_value))
|
|
|
|
|
+ res = Helper.async_post(ODDS_URL, odderlist)
|
|
|
|
|
+ if res:
|
|
|
|
|
+ if res.get('status') == 1:
|
|
|
|
|
+ logging.warning("赔率提交成功,{}3".format(res))
|
|
|
|
|
+ else:
|
|
|
|
|
+ logging.warning("赔率提交失败,{}4".format(res))
|
|
|
|
|
+ else:
|
|
|
|
|
+ logging.warning("赔率提交失败,{}5".format(res))
|
|
|
|
|
+
|
|
|
is_stringscene = 1
|
|
is_stringscene = 1
|
|
|
league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid",
|
|
league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid",
|
|
|
"is_rollball", "is_today", "is_morningplate", "is_stringscene"]
|
|
"is_rollball", "is_today", "is_morningplate", "is_stringscene"]
|
|
@@ -51,10 +87,12 @@ class ZuqiuPipeline(object):
|
|
|
lres = Helper.async_post(MATCH_URL, childer)
|
|
lres = Helper.async_post(MATCH_URL, childer)
|
|
|
if lres.get('status') == 1:
|
|
if lres.get('status') == 1:
|
|
|
logging.warning("联赛提交成功,{}".format(res))
|
|
logging.warning("联赛提交成功,{}".format(res))
|
|
|
|
|
+
|
|
|
else:
|
|
else:
|
|
|
- logging.warning("联赛提交失败,{}".format(res))
|
|
|
|
|
|
|
+ logging.warning("赛事提交失败,{}".format(res))
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
|
logging.warning("联赛提交失败,{}".format(res))
|
|
logging.warning("联赛提交失败,{}".format(res))
|
|
|
else:
|
|
else:
|
|
|
logging.warning("联赛提交失败,{}".format(res))
|
|
logging.warning("联赛提交失败,{}".format(res))
|
|
|
|
|
+
|