mirror of
https://github.com/hex-ci/smzdm_script.git
synced 2026-02-03 02:53:17 +08:00
update
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
[user.A]
|
|
||||||
USER_AGENT = ""
|
|
||||||
ANDROID_COOKIE = ""
|
|
||||||
SK = ""
|
|
||||||
TOKEN = ""
|
|
||||||
|
|
||||||
[user.B]
|
|
||||||
USER_AGENT = ""
|
|
||||||
ANDROID_COOKIE = ""
|
|
||||||
SK = ""
|
|
||||||
TOKEN = ""
|
|
||||||
@@ -1,4 +1 @@
|
|||||||
APScheduler==3.10.0
|
|
||||||
prettytable==3.6.0
|
|
||||||
requests==2.28.2
|
requests==2.28.2
|
||||||
toml==0.10.2
|
|
||||||
|
|||||||
118
smzdm_checkin.py
118
smzdm_checkin.py
@@ -1,4 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
|
什么值得买自动签到脚本
|
||||||
|
项目地址: https://github.com/hex-ci/smzdm_script
|
||||||
0 8 * * * smzdm_checkin.py
|
0 8 * * * smzdm_checkin.py
|
||||||
const $ = new Env("什么值得买签到");
|
const $ = new Env("什么值得买签到");
|
||||||
"""
|
"""
|
||||||
@@ -8,32 +10,27 @@ import os
|
|||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
import re
|
||||||
|
|
||||||
import prettytable as pt
|
|
||||||
import requests
|
import requests
|
||||||
from notify import send
|
from notify import send
|
||||||
from utils.file_helper import TomlHelper
|
|
||||||
|
|
||||||
CURRENT_PATH = Path(__file__).parent.resolve()
|
|
||||||
CONFIG_PATH = Path(CURRENT_PATH, "config")
|
|
||||||
|
|
||||||
|
|
||||||
class SmzdmBot(object):
|
class SmzdmBot(object):
|
||||||
KEY = "apr1$AwP!wRRT$gJ/q.X24poeBInlUJC"
|
KEY = "apr1$AwP!wRRT$gJ/q.X24poeBInlUJC"
|
||||||
|
DEFAULT_USER_AGENT = "smzdm_android_V10.4.25 rv:860 (Redmi Note 3;Android10;zh)smzdmapp"
|
||||||
|
|
||||||
def __init__(self, conf_kwargs: dict):
|
def __init__(self, conf_kwargs: dict, index):
|
||||||
self.conf_kwargs = conf_kwargs
|
self.conf_kwargs = conf_kwargs
|
||||||
|
self.index = index
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
self.start_timestamp = int(time.time())
|
|
||||||
self._set_header()
|
|
||||||
|
|
||||||
def _set_header(self):
|
def _set_header(self):
|
||||||
request_key = f"{random.randint(10000000, 100000000) * 10000000000 + self.start_timestamp}"
|
request_key = f"{random.randint(10000000, 100000000) * 10000000000 + self.start_timestamp}"
|
||||||
headers = {
|
headers = {
|
||||||
"user-agent": self.conf_kwargs["USER_AGENT"],
|
"user-agent": os.environ.get("SMZDM_USER_AGENT") or self.DEFAULT_USER_AGENT,
|
||||||
"request_key": request_key,
|
"request_key": request_key,
|
||||||
"cookie": self.conf_kwargs["ANDROID_COOKIE"],
|
"cookie": self.conf_kwargs["COOKIE"],
|
||||||
"content-type": "application/x-www-form-urlencoded",
|
"content-type": "application/x-www-form-urlencoded",
|
||||||
"connection": "keep-alive",
|
"connection": "keep-alive",
|
||||||
}
|
}
|
||||||
@@ -43,13 +40,13 @@ class SmzdmBot(object):
|
|||||||
time = self.start_timestamp * 1000
|
time = self.start_timestamp * 1000
|
||||||
sk = self.conf_kwargs.get("SK")
|
sk = self.conf_kwargs.get("SK")
|
||||||
token = self.conf_kwargs.get("TOKEN")
|
token = self.conf_kwargs.get("TOKEN")
|
||||||
sign_str = f"f=android&sk={sk}&time={time}&token={token}&v=10.4.20&weixin=1&key={self.KEY}"
|
sign_str = f"f=android&sk={sk}&time={time}&token={token}&v=10.4.25&weixin=1&key={self.KEY}"
|
||||||
sign = self._str_to_md5(sign_str).upper()
|
sign = self._str_to_md5(sign_str).upper()
|
||||||
data = {
|
data = {
|
||||||
"weixin": "1",
|
"weixin": "1",
|
||||||
"captcha": "",
|
"captcha": "",
|
||||||
"f": "android",
|
"f": "android",
|
||||||
"v": "10.4.20",
|
"v": "10.4.25",
|
||||||
"sk": sk,
|
"sk": sk,
|
||||||
"sign": sign,
|
"sign": sign,
|
||||||
"touchstone_event": "",
|
"touchstone_event": "",
|
||||||
@@ -63,8 +60,20 @@ class SmzdmBot(object):
|
|||||||
|
|
||||||
def checkin(self):
|
def checkin(self):
|
||||||
url = "https://user-api.smzdm.com/checkin"
|
url = "https://user-api.smzdm.com/checkin"
|
||||||
|
|
||||||
|
if self.index > 1:
|
||||||
|
print("延时 5 秒执行")
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
sep = "\n********开始账号" + str(self.index) + "********"
|
||||||
|
print(sep + "\n", end="")
|
||||||
|
|
||||||
|
self.start_timestamp = int(time.time())
|
||||||
|
self._set_header()
|
||||||
data = self._data()
|
data = self._data()
|
||||||
|
|
||||||
resp = self.session.post(url, data)
|
resp = self.session.post(url, data)
|
||||||
|
|
||||||
if resp.status_code == 200 and int(resp.json()["error_code"]) == 0:
|
if resp.status_code == 200 and int(resp.json()["error_code"]) == 0:
|
||||||
resp_data = resp.json()["data"]
|
resp_data = resp.json()["data"]
|
||||||
checkin_num = resp_data["daily_num"]
|
checkin_num = resp_data["daily_num"]
|
||||||
@@ -73,21 +82,20 @@ class SmzdmBot(object):
|
|||||||
exp = resp_data["cexperience"]
|
exp = resp_data["cexperience"]
|
||||||
rank = resp_data["rank"]
|
rank = resp_data["rank"]
|
||||||
cards = resp_data["cards"]
|
cards = resp_data["cards"]
|
||||||
tb = pt.PrettyTable()
|
|
||||||
tb.field_names = ["签到天数", "金币", "积分", "经验", "等级", "补签卡"]
|
|
||||||
tb.add_row([checkin_num, gold, point, exp, rank, cards])
|
|
||||||
print(f"\n{tb}")
|
|
||||||
msg = f"""⭐签到成功{checkin_num}天
|
msg = f"""⭐签到成功{checkin_num}天
|
||||||
🏅金币{gold}
|
🏅金币{gold}
|
||||||
🏅积分{point}
|
🏅积分{point}
|
||||||
🏅经验{exp}
|
🏅经验{exp}
|
||||||
🏅等级{rank}
|
🏅等级{rank}
|
||||||
🏅补签卡{cards}"""
|
🏅补签卡{cards}\n"""
|
||||||
return msg
|
|
||||||
|
print(msg)
|
||||||
|
return sep + "\n" + msg
|
||||||
else:
|
else:
|
||||||
print("Faile to sign in")
|
print("登录失败", resp.json())
|
||||||
msg = "Fail to login in"
|
msg += "登录失败\n"
|
||||||
return msg
|
return sep + "\n" + msg
|
||||||
|
|
||||||
def all_reward(self):
|
def all_reward(self):
|
||||||
url = "https://user-api.smzdm.com/checkin/extra_reward"
|
url = "https://user-api.smzdm.com/checkin/extra_reward"
|
||||||
@@ -107,9 +115,9 @@ class SmzdmBot(object):
|
|||||||
]["continue_checkin_reward_show"]
|
]["continue_checkin_reward_show"]
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Fail to check extra reward: {e}")
|
print(f"检查额外奖励失败: {e}")
|
||||||
if not continue_checkin_reward_show:
|
if not continue_checkin_reward_show:
|
||||||
print("No extra reward today")
|
print("今天没有额外奖励")
|
||||||
return
|
return
|
||||||
url = "https://user-api.smzdm.com/checkin/extra_reward"
|
url = "https://user-api.smzdm.com/checkin/extra_reward"
|
||||||
data = self._data()
|
data = self._data()
|
||||||
@@ -131,48 +139,44 @@ class SmzdmBot(object):
|
|||||||
|
|
||||||
|
|
||||||
def conf_kwargs():
|
def conf_kwargs():
|
||||||
conf_kwargs = {}
|
conf_kwargs = []
|
||||||
|
|
||||||
if Path.exists(Path(CONFIG_PATH, "config.toml")):
|
if os.environ["SMZDM_COOKIE"]:
|
||||||
print("Get configration from config.toml")
|
cookies = os.environ["SMZDM_COOKIE"].split("&")
|
||||||
conf_kwargs = TomlHelper(Path(CONFIG_PATH, "config.toml")).read()
|
for cookie in cookies:
|
||||||
conf_kwargs.update({"toml_conf": True})
|
try:
|
||||||
elif os.environ.get("ANDROID_COOKIE", None):
|
token = re.findall(r"sess=(.*?);", cookie)[0]
|
||||||
print("Get configration from env")
|
conf_kwargs.append({
|
||||||
conf_kwargs = {
|
"SK": "1",
|
||||||
"USER_AGENT": os.environ.get("USER_AGENT"),
|
"COOKIE": cookie,
|
||||||
"SK": os.environ.get("SK"),
|
"TOKEN": token,
|
||||||
"ANDROID_COOKIE": os.environ.get("ANDROID_COOKIE"),
|
})
|
||||||
"TOKEN": os.environ.get("TOKEN"),
|
except:
|
||||||
}
|
print("发生异常错误")
|
||||||
conf_kwargs.update({"env_conf": True})
|
|
||||||
else:
|
else:
|
||||||
print("Please set cookies first")
|
print("请先设置 SMZDM_COOKIE 环境变量")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return conf_kwargs
|
return conf_kwargs
|
||||||
|
|
||||||
|
|
||||||
def main(conf_kwargs):
|
def main(conf_kwargs):
|
||||||
msg = ""
|
msg = ""
|
||||||
if conf_kwargs.get("toml_conf"):
|
index = 0
|
||||||
for i in conf_kwargs["user"]:
|
for config in conf_kwargs:
|
||||||
try:
|
try:
|
||||||
bot = SmzdmBot(conf_kwargs["user"][i])
|
index += 1
|
||||||
msg += bot.checkin()
|
bot = SmzdmBot(config, index)
|
||||||
bot.all_reward()
|
msg += bot.checkin()
|
||||||
bot.extra_reward()
|
bot.all_reward()
|
||||||
except Exception as e:
|
bot.extra_reward()
|
||||||
print(e)
|
except Exception as e:
|
||||||
continue
|
print(e)
|
||||||
send("什么值得买签到", msg)
|
continue
|
||||||
else:
|
|
||||||
bot = SmzdmBot(conf_kwargs)
|
send("什么值得买签到", msg)
|
||||||
msg = bot.checkin()
|
|
||||||
bot.all_reward()
|
|
||||||
bot.extra_reward()
|
|
||||||
send("什么值得买签到", msg)
|
|
||||||
if msg is None or "Fail to login in" in msg:
|
if msg is None or "Fail to login in" in msg:
|
||||||
print("Fail the Github action job")
|
print("发生异常错误")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import toml
|
|
||||||
|
|
||||||
class TomlHelper:
|
|
||||||
def __init__(self, toml_filename):
|
|
||||||
self.t_dict = dict()
|
|
||||||
self.toml_file_path = toml_filename
|
|
||||||
|
|
||||||
def update(self, t_data):
|
|
||||||
self.t_dict.update(t_data)
|
|
||||||
return self.t_dict
|
|
||||||
|
|
||||||
def write(self, t_data):
|
|
||||||
with open(self.toml_file_path, "w", encoding="utf-8") as fs:
|
|
||||||
toml.dump(t_data, fs)
|
|
||||||
|
|
||||||
def read(self):
|
|
||||||
with open(self.toml_file_path, "r", encoding="utf-8") as fs:
|
|
||||||
t_data = toml.load(fs)
|
|
||||||
return t_data
|
|
||||||
|
|
||||||
def read_str(self, s_data):
|
|
||||||
t_data = toml.loads(s_data, _dict=dict)
|
|
||||||
return t_data
|
|
||||||
|
|
||||||
def read_dict(self, dict):
|
|
||||||
t_data = toml.dumps(dict)
|
|
||||||
return t_data
|
|
||||||
Reference in New Issue
Block a user