2022-08-27 13:51:38 +00:00
|
|
|
|
import tools
|
|
|
|
|
import config
|
2022-08-28 09:31:01 +00:00
|
|
|
|
import setting
|
|
|
|
|
from request import http
|
2022-08-27 13:51:38 +00:00
|
|
|
|
from loghelper import log
|
|
|
|
|
|
|
|
|
|
|
2022-08-28 09:31:01 +00:00
|
|
|
|
class CloudGenshin:
|
|
|
|
|
def __init__(self) -> None:
|
2022-08-27 13:51:38 +00:00
|
|
|
|
self.headers = {
|
|
|
|
|
'Host': 'api-cloudgame.mihoyo.com',
|
2022-12-13 00:35:19 +00:00
|
|
|
|
'Accept': '*/*',
|
|
|
|
|
'Referer': 'https://app.mihoyo.com',
|
|
|
|
|
'x-rpc-combo_token': config.config['cloud_games']['genshin']['token'],
|
|
|
|
|
'Accept-Encoding': 'gzip, deflate',
|
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 HBPC/12.1.1.301',
|
|
|
|
|
|
2022-08-27 13:51:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-28 10:08:36 +00:00
|
|
|
|
# 分钟转小时
|
2022-10-12 14:08:17 +00:00
|
|
|
|
def time_conversion(self, minute: int) -> str:
|
|
|
|
|
h = minute // 60
|
|
|
|
|
s = minute % 60
|
2022-08-28 10:08:36 +00:00
|
|
|
|
return f"{h}小时{s}分钟"
|
|
|
|
|
|
|
|
|
|
def sign_account(self) -> str:
|
2022-08-28 09:31:01 +00:00
|
|
|
|
ret_msg = "云原神:\r\n"
|
2022-08-28 10:41:23 +00:00
|
|
|
|
req = http.get(url=setting.cloud_genshin_sgin, headers=self.headers)
|
2022-08-28 09:31:01 +00:00
|
|
|
|
data = req.json()
|
|
|
|
|
if data['retcode'] == 0:
|
2022-08-30 00:55:37 +00:00
|
|
|
|
if int(data["data"]["free_time"]["send_freetime"]) > 0:
|
|
|
|
|
log.info(f'签到成功,已获得{data["data"]["free_time"]["send_freetime"]}分钟免费时长')
|
|
|
|
|
ret_msg += f'签到成功,已获得{data["data"]["free_time"]["send_freetime"]}分钟免费时长\n'
|
2022-08-28 09:31:01 +00:00
|
|
|
|
else:
|
2022-08-28 10:41:23 +00:00
|
|
|
|
log.info('签到失败,未获得免费时长,可能是已经签到过了或者超出免费时长上线')
|
2022-08-28 10:48:36 +00:00
|
|
|
|
ret_msg += '签到失败,未获得免费时长,可能是已经签到过了或者超出免费时长上线\n'
|
2022-08-30 01:15:12 +00:00
|
|
|
|
ret_msg += f'你当前拥有免费时长 {self.time_conversion(int(data["data"]["free_time"]["free_time"]))} ,' \
|
2022-10-12 14:08:17 +00:00
|
|
|
|
f'畅玩卡状态为 {data["data"]["play_card"]["short_msg"]},拥有米云币 {data["data"]["coin"]["coin_num"]} 枚'
|
2022-08-28 09:31:01 +00:00
|
|
|
|
log.info(ret_msg)
|
|
|
|
|
elif data['retcode'] == -100:
|
|
|
|
|
ret_msg = "云原神token失效/防沉迷"
|
|
|
|
|
log.warning(ret_msg)
|
|
|
|
|
config.clear_cookie_cloudgame()
|
|
|
|
|
else:
|
|
|
|
|
ret_msg = f'脚本签到失败,json文本:{req.text}'
|
|
|
|
|
log.warning(ret_msg)
|
|
|
|
|
return ret_msg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
pass
|