调整日报规则 添加一些gameid

This commit is contained in:
pengtao 2019-12-11 14:57:59 +08:00
parent 2bb40a31d9
commit 9d857e2c1c
3 changed files with 76 additions and 6 deletions

38
1.py Normal file
View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
import requests
class MpGameList:
def __init__(self):
self.mp_games_url = "https://mp.kingsome.cn/api/open/games/list"
def get_gameid(self):
r = requests.get(self.mp_games_url)
all = []
if r.status_code == requests.codes.ok:
try:
data = r.json().get("gameList")
except Exception:
print(f"get data failed!")
try:
for line in data: # {"game":"一起织娃娃","game_id":8002,"game_name":"knitting","platform":"weixin","platform_id":6001,"platform_name":"微信"}
if line.get("platform") == "test":
continue
else:
temp = {}
temp['name_cn'] = line.get("game", "")
temp['game_id'] = line.get("game_id", 0)
temp['platform_name'] = line.get("platform_name", "")
temp['platform_id'] = line.get("platform_id", 0)
all.append(temp)
except Exception:
print(f"split data with{r.json()} failed")
return all
else:
return None
if __name__ == "__main__":
mm = MpGameList()
data = mm.get_gameid()
print(data)

View File

@ -34,13 +34,13 @@ app.config['MAIL_PASSWORD'] = 'bX8cfBAyj9MBqH22'
mail = Mail(app)
# recipients_mini = ["pengtao@kingsome.cn", "tangwenjing@kingsome.cn"]
recipients_mini = ["pengtao@kingsome.cn", "tangwenjing@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
# recipients_2001 = ["pengtao@kingsome.cn", "chenliang@kingsome.cn"]
recipients_mini = ["pengtao@kingsome.cn", "tangwenjing@kingsome.cn"]
#recipients_mini = ["pengtao@kingsome.cn", "tangwenjing@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
recipients_2001 = ["pengtao@kingsome.cn", "chenliang@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
#recipients_2001 = ["pengtao@kingsome.cn"]
#recipients_2001 = ["pengtao@kingsome.cn", "chenliang@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
recipients_2001 = ["pengtao@kingsome.cn"]
# FROMAPPID_CN = {"wxdb103a128e118619": "拯救熊猫泡泡", "wxc137c93eedeab6f2": "爆冰达人"}
@ -441,7 +441,8 @@ class Report:
def run(self):
if self.project == 'mini_games':
parms = [(1004, 6001), (1011, 6001), (1001, 6001), (1013, 6001)]
parms = [(1004, 6001), (1011, 6001), (1001, 6001), (1013, 6001), (1016, 6001), (2020, 6001), (2021, 6001),
(2022, 6001)]
elif self.project == '2001':
parms = [(2001, 6001), (2002, 6001),(2003, 6001)]
else:
@ -475,6 +476,7 @@ class Report:
args['tga'] = tga
temp['all'] = self.get_all_data(**args)
pdb.set_trace()
if temp['all']:
ss_input_fromappids = self.get_ss_input_fromappid(args)
ss_output_fromappids = self.get_ss_output_fromappid(args)

View File

@ -18,3 +18,33 @@ class MpInterface:
key = "fromappid_cn"
url = f"{self.base_url}channelid={channelid}&gameid={gameid}&key={key}"
return self.get_data(url)
class MpGameList:
def __init__(self):
self.mp_games_url = "https://mp.kingsome.cn/api/open/games/list"
def get_gameid(self):
r = requests.get(self.mp_games_url)
all = []
if r.status_code == requests.codes.ok:
try:
data = r.json().get("gameList")
except Exception:
print(f"get data failed!")
try:
for line in data: # {"game":"一起织娃娃","game_id":8002,"game_name":"knitting","platform":"weixin","platform_id":6001,"platform_name":"微信"}
if line.get("platform") == "test":
continue
else:
temp = {}
temp['name_cn'] = line.get("game", "")
temp['game_id'] = line.get("game_id", 0)
temp['platform_name'] = line.get("platform_name", "")
temp['platform_id'] = line.get("platform_id", 0)
all.append(temp)
except Exception:
print(f"split data with{r.json()} failed")
return all
else:
return None