dailycheckin/fmapp/fmapp.py
shitao adee1a78bc 🎨 调整多账号运行方式;
🐛 修复腾讯视频签到失败的 BUG;
🔨 添加腾讯视频已完成任务的自动领取;
🔨 修改企业微信应用推送格式。
2021-03-05 01:04:02 +08:00

93 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
import json
import os
import requests
class FMAPPCheckIn:
def __init__(self, check_item):
self.check_item = check_item
@staticmethod
def sign(headers):
try:
url = "https://fmapp.chinafamilymart.com.cn/api/app/market/member/signin/sign"
response = requests.post(url=url, headers=headers).json()
code = response.get("code")
if code == "200":
data = response.get("data", {})
msg = (
f"在坚持{data.get('nextDay')}天即可获得{data.get('nextNumber')}个发米粒\n"
f"签到{data.get('lastDay')}天可获得{data.get('lastNumber')}个发米粒"
)
else:
msg = response.get("message")
except Exception as e:
print("错误信息", str(e))
msg = "未知错误,检查日志"
return msg
@staticmethod
def user_info(headers):
try:
url = "https://fmapp.chinafamilymart.com.cn/api/app/member/info"
response = requests.post(url=url, headers=headers).json()
code = response.get("code")
if code == "200":
data = response.get("data", {})
msg = data.get("nickName")
else:
msg = response.get("message")
except Exception as e:
print("错误信息", str(e))
msg = "未知错误,检查日志"
return msg
@staticmethod
def mili_count(headers):
try:
url = "https://fmapp.chinafamilymart.com.cn/api/app/member/v1/mili/service/detail"
response = requests.post(url=url, headers=headers, data=json.dumps({"pageSize": 10, "pageNo": 1})).json()
code = response.get("code")
if code == "200":
data = response.get("data", {})
msg = data.get("miliNum")
else:
msg = response.get("message")
except Exception as e:
print("错误信息", str(e))
msg = "未知错误,检查日志"
return msg
def main(self):
fmapp_token = self.check_item.get("fmapp_token")
fmapp_cookie = self.check_item.get("fmapp_cookie")
fmapp_device_id = self.check_item.get("fmapp_device_id")
headers = {
"Host": "fmapp.chinafamilymart.com.cn",
"Content-Type": "application/json",
"Accept": "*/*",
"loginChannel": "app",
"Accept-Language": "zh-Hans-CN;q=1.0, en-CN;q=0.9, ja-CN;q=0.8, zh-Hant-HK;q=0.7, io-Latn-CN;q=0.6",
"token": fmapp_token,
"fmVersion": "2.0.0",
"deviceId": fmapp_device_id,
"User-Agent": "Fa",
"cookie": fmapp_cookie,
}
sign_msg = self.sign(headers=headers)
name_msg = self.user_info(headers=headers)
mili_msg = self.mili_count(headers=headers)
msg = f"帐号信息: {name_msg}\n签到状态: {sign_msg}\n米粒数量: {mili_msg}"
return msg
if __name__ == "__main__":
with open(
os.path.join(os.path.dirname(os.path.dirname(__file__)), "config/config.json"), "r", encoding="utf-8"
) as f:
datas = json.loads(f.read())
_check_item = datas.get("FMAPP_ACCOUNT_LIST", [])[0]
print(FMAPPCheckIn(check_item=_check_item).main())