forked from Asdrt852/WYY_Action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkin.py
160 lines (145 loc) · 5.98 KB
/
checkin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import requests, base64, json, hashlib
from Crypto.Cipher import AES
def push_server_chan(logs):
if sckey is None or sckey == "":
print("跳过推送")
return
params = {
'text': "网易云音乐自动脚本",
'desp': logs
}
serverURL = "https://sc.ftqq.com/" + sckey + ".send"
response = requests.session().post(serverURL, data=params)
if response.status_code == 200:
print("推送成功")
def encrypt(key, text):
cryptor = AES.new(key.encode('utf8'), AES.MODE_CBC, b'0102030405060708')
length = 16
count = len(text.encode('utf-8'))
if (count % length != 0):
add = length - (count % length)
else:
add = 16
pad = chr(add)
text1 = text + (pad * add)
ciphertext = cryptor.encrypt(text1.encode('utf8'))
cryptedStr = str(base64.b64encode(ciphertext), encoding='utf-8')
return cryptedStr
def md5(str):
hl = hashlib.md5()
hl.update(str.encode(encoding='utf-8'))
return hl.hexdigest()
def protect(text):
return {"params": encrypt('TA3YiYCfY2dDJQgg', encrypt('0CoJUm6Qyw8W8jud', text)),
"encSecKey": "84ca47bca10bad09a6b04c5c927ef077d9b9f1e37098aa3eac6ea70eb59df0aa28b691b7e75e4f1f9831754919ea784c8f74fbfadf2898b0be17849fd656060162857830e241aba44991601f137624094c114ea8d17bce815b0cd4e5b8e2fbaba978c6d1d14dc3d1faf852bdd28818031ccdaaa13a6018e1024e2aae98844210"}
def do_checkin(user, pwd, logs):
s = requests.Session()
header = {}
url = "https://music.163.com/weapi/login/cellphone"
url2 = "https://music.163.com/weapi/point/dailyTask"
url3 = "https://music.163.com/weapi/v1/discovery/recommend/resource"
logindata = {
"phone": user,
"countrycode": "86",
"password": md5(pwd),
"rememberLogin": "true",
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36',
"Referer": "http://music.163.com/",
"Accept-Encoding": "gzip, deflate",
}
headers2 = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36',
"Referer": "http://music.163.com/",
"Accept-Encoding": "gzip, deflate",
"Cookie": "os=pc; osver=Microsoft-Windows-10-Professional-build-10586-64bit; appver=2.0.3.131777; channel=netease; __remember_me=true;"
}
res = s.post(url=url, data=protect(json.dumps(logindata)), headers=headers2)
tempcookie = res.cookies
object = json.loads(res.text)
if object['code'] == 200:
print("登录成功!")
logs += "账号" + logindata["phone"] + "登录成功!\n\n"
else:
print("登录失败!请检查密码是否正确!" + str(object['code']))
logs += "账号" + logindata["phone"] + "登录失败!请检查密码是否正确!\n\n"
return logs + str(object['code'])
res = s.post(url=url2, data=protect('{"type":0}'), headers=headers)
object = json.loads(res.text)
if object['code'] != 200 and object['code'] != -2:
print("签到时发生错误:" + object['msg'])
else:
if object['code'] == 200:
print("签到成功,经验+" + str(object['point']))
logs += "签到成功,经验+" + str(object['point']) + "\n\n"
else:
print("重复签到")
logs += "重复签到\n\n"
res = s.post(url=url3,
data=protect('{"csrf_token":"' + requests.utils.dict_from_cookiejar(tempcookie)['__csrf'] + '"}'),
headers=headers)
object = json.loads(res.text, strict=False)
for x in object['recommend']:
url = 'https://music.163.com/weapi/v3/playlist/detail?csrf_token=' + \
requests.utils.dict_from_cookiejar(tempcookie)[
'__csrf']
data = {
'id': x['id'],
'n': 1000,
'csrf_token': requests.utils.dict_from_cookiejar(tempcookie)['__csrf'],
}
res = s.post(url, protect(json.dumps(data)), headers=headers)
object = json.loads(res.text, strict=False)
buffer = []
count = 0
for j in object['playlist']['trackIds']:
data2 = {}
data2["action"] = "play"
data2["json"] = {}
data2["json"]["download"] = 0
data2["json"]["end"] = "playend"
data2["json"]["id"] = j["id"]
data2["json"]["sourceId"] = ""
data2["json"]["time"] = "240"
data2["json"]["type"] = "song"
data2["json"]["wifi"] = 0
buffer.append(data2)
count += 1
if count >= 310:
break
if count >= 310:
break
url = "http://music.163.com/weapi/feedback/weblog"
postdata = {
"logs": json.dumps(buffer)
}
res = s.post(url, protect(json.dumps(postdata)))
object = json.loads(res.text, strict=False)
if object['code'] == 200:
print("刷单成功!共" + str(count) + "首")
logs += "刷单成功!共" + str(count) + "首\n\n"
return logs
else:
print("发生错误:" + str(object['code']) + object['message'])
logs += "发生错误:" + str(object['code']) + object['message'] + "\n\n"
return logs + str(object['code'])
if __name__ == '__main__':
logs = ""
user_list = input().split("#")
pwd_list = input().split("#")
sckey = input()
if len(user_list) != len(pwd_list):
print("账号和密码个数不对应")
logs += "账号和密码个数不对应\n\n"
else:
print("共有" + str(len(user_list)) + "个账号,即将开始签到")
logs += "共有" + str(len(user_list)) + "个账号,即将开始签到\n\n"
for user, pwd in zip(user_list, pwd_list):
try:
logs = do_checkin(user, pwd, logs)
except BaseException as e:
logs += "程序出现异常"+e
logs += "执行完成"
push_server_chan(logs)
exit()