添加2001 b_N上传方法
This commit is contained in:
parent
30413153bd
commit
f6170eed7b
@ -1,25 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import requests
|
||||
import logging
|
||||
|
||||
from ops.ss_virtual_create import SS_Virtual_command
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Mp2shushu():
|
||||
def __init__(self, channel, gameid):
|
||||
self.mp_url = f"https://mp.kingsome.cn/api/open/promotion/co-list?channelid={channel}&gameid={gameid}"
|
||||
self.filename = "/data/git/ops_interface/ops/csv/2001_b_n.csv"
|
||||
|
||||
def get_ad_list(self):
|
||||
r = requests.get(self.mp_url)
|
||||
if r.status_code == requests.codes.ok:
|
||||
return r.json()
|
||||
return self.split_data(r.json())
|
||||
else:
|
||||
return None
|
||||
|
||||
def split_data(self, data):
|
||||
try:
|
||||
result = data['result']
|
||||
begin = "b_n,b_n_china"
|
||||
text = ""
|
||||
for line in result:
|
||||
text += ','.join(line) + '\n'
|
||||
result_new = f"{begin}\n{text}"
|
||||
except Exception:
|
||||
log.error(f"split {data} failed!", exc_info=True)
|
||||
result = None
|
||||
return result
|
||||
result_new = None
|
||||
return result_new
|
||||
|
||||
def write2csv(self, data):
|
||||
with open(self.filename, 'w') as f:
|
||||
f.write(data)
|
||||
|
||||
def upload2ss(self):
|
||||
ss = SS_Virtual_command()
|
||||
ss.upload_2001_b_n()
|
||||
|
||||
|
||||
def run(self):
|
||||
data = self.get_ad_list()
|
||||
self.write2csv(data)
|
||||
self.upload2ss()
|
||||
|
Loading…
x
Reference in New Issue
Block a user