forked from xllxll/cool_push_iqy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
243 lines (222 loc) · 7.78 KB
/
main.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# -*- coding: utf8 -*-
# 爱奇艺(IQIYI)官网,加载主页面,
# 开发者工具搜索获取P00001,P00003参数
# skey 为酷推 密钥,绑定发送qq
# 修改200、201、202行代码,其中202行的skey是酷推的skey。200和201行是获取Cookie中的P0001和P0003
import time
import requests
class IQY:
'''
爱奇艺签到、抽奖、做日常任务(签到、任务仅限VIP)
*奖励:签7天奖1天,14天奖2天,28天奖7天;日常任务;随机成长值
'''
def __init__(self, P00001, psp_uid):
'''
:param P00001: 签到,任务,抽奖必要参数
:param psp_uid: 抽奖必要参数
'''
self.P00001 = P00001
self.psp_uid = psp_uid
self.taskList = []
self.growthTask = 0
def userInformation(self):
'''
用户信息查询
'''
time.sleep(3)
url = "http://serv.vip.iqiyi.com/vipgrowth/query.action"
params = {
"P00001": self.P00001,
}
res = requests.get(url, params=params)
if res.json()["code"] == "A00000":
try:
res_data = res.json()["data"]
# VIP等级
level = res_data["level"]
# 当前VIP成长值
growthvalue = res_data["growthvalue"]
# 升级需要成长值
distance = res_data["distance"]
# VIP到期时间
deadline = res_data["deadline"]
# 今日成长值
todayGrowthValue = res_data["todayGrowthValue"]
msg = f"VIP等级:{level}\n当前成长值:{growthvalue}\n升级需成长值:{distance}\n今日成长值: +{todayGrowthValue}\nVIP到期时间:{deadline}"
except:
msg = res.json()
else:
# print("(iqy)签到错误", res.content.decode())
msg = res.json()
print(msg)
return msg
def sign(self):
'''
VIP签到
'''
url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
params = {
"P00001": self.P00001,
"autoSign": "yes"
}
res = requests.get(url, params=params)
if res.json()["code"] == "A00000":
try:
growth = res.json()[
"data"]["signInfo"]["data"]["rewardMap"]["growth"]
continueSignDaysSum = res.json(
)["data"]["signInfo"]["data"]["continueSignDaysSum"]
#vipStatus = res.json()["data"]["userInfo"]["vipStatus"]
rewardDay = 7 if continueSignDaysSum % 28 <= 7 else (
14 if continueSignDaysSum % 28 <= 14 else 28)
rouund_day = 28 if continueSignDaysSum % 28 == 0 else continueSignDaysSum % 28
# VIP等级:{vipStatus}\n签到:
msg = f"+{growth}成长值\n连续签到:{continueSignDaysSum}天\n签到周期:{rouund_day}天/{rewardDay}天"
except:
msg = res.json()["data"]["signInfo"]["msg"]
else:
# print("(iqy)签到错误", res.content.decode())
msg = res.json()["msg"]
print(msg)
return msg
def queryTask(self):
'''
获取VIP日常任务 和 taskCode(任务状态)
'''
url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
params = {
"P00001": self.P00001
}
res = requests.get(url, params=params)
if res.json()["code"] == "A00000":
for item in res.json()["data"]["tasks"]["daily"]:
self.taskList.append({
"name": item["name"],
"taskCode": item["taskCode"],
"status": item["status"],
"taskReward": item["taskReward"]["task_reward_growth"]
})
else:
# print("(iqy)获取任务失败")
pass
return self
def joinTask(self):
"""
遍历完成任务
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/joinTask"
params = {
"P00001": self.P00001,
"taskCode": "",
"platform": "bb136ff4276771f3",
"lang": "zh_CN"
}
# 遍历任务,仅做一次
for item in self.taskList:
if item["status"] == 2:
params["taskCode"] = item["taskCode"]
res = requests.get(url, params=params)
print(res.text)
def getReward(self):
"""
获取任务奖励
:return: 返回信息
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/getTaskRewards"
params = {
"P00001": self.P00001,
"taskCode": "",
"platform": "bb136ff4276771f3",
"lang": "zh_CN"
}
# 遍历任务,领取奖励
for item in self.taskList:
if item["status"] == 0:
params["taskCode"] = item["taskCode"]
res = requests.get(url, params=params)
if res.json()["code"] == "A00000":
self.growthTask += item["taskReward"]
msg = f"+{self.growthTask}成长值"
print(msg)
return msg
def draw(self, type):
'''
查询抽奖次数(必),抽奖
:param type: 类型。0查询次数;1抽奖
:return: {status, msg, chance}
'''
url = "https://iface2.iqiyi.com/aggregate/3.0/lottery_activity"
params = {
"lottery_chance": 1,
"app_k": "b398b8ccbaeacca840073a7ee9b7e7e6",
"app_v": "11.6.5",
"platform_id": 10,
"dev_os": "8.0.0",
"dev_ua": "FRD-AL10",
"net_sts": 1,
"qyid": "2655b332a116d2247fac3dd66a5285011102",
"psp_uid": self.psp_uid,
"psp_cki": self.P00001,
"psp_status": 3,
"secure_v": 1,
"secure_p": "GPhone",
"req_sn": round(time.time()*1000)
}
# 抽奖删除lottery_chance参数
if type == 1:
del params["lottery_chance"]
res = requests.get(url, params=params)
# print("(iqy)抽奖信息", res.json())
if not res.json().get('code'):
chance = int(res.json().get('daysurpluschance'))
msg = res.json().get("awardName")
return {"status": True, "msg": msg, "chance": chance}
else:
try:
msg = res.json().get("kv", {}).get("msg")
except:
msg = res.json()["errorReason"]
print(msg)
return {"status": False, "msg": msg, "chance": 0}
def sendMsg(key, content):
'''
通过酷推(https://cp.xuthus.cc/)向QQ发送信息
:param key: 酷推密钥
:param content: 发送内容
'''
url = f"https://push.xuthus.cc/send/{key}"
params = {
"c": content
}
res = requests.get(url, params=params)
def main():
import os
# P00001 = ""
P00001 = os.environ['P00001']
# P00003 = ""
P00003 = os.environ['P00003']
# skey = ""
skey = os.environ['SKEY']
# 签到
obj = IQY(P00001, P00003)
msg1 = obj.sign()
# 抽奖
chance = obj.draw(0)["chance"]
if chance:
msg2 = ""
for i in range(chance):
ret = obj.draw(1)
msg2 += ret["msg"]+";" if ret["status"] else ""
else:
msg2 = "抽奖机会不足"
# 日常任务
obj.queryTask().joinTask()
msg3 = obj.queryTask().getReward()
# 查询用户信息
msg_user = obj.userInformation()
msg = f"【爱奇艺等级】\n{msg_user}\n----------------------\n【爱奇艺签到】\n签到:{msg1}\n任务:{msg3}\n抽奖:{msg2}"
sendMsg(skey, msg)
return msg
# 入口
if __name__ == "__main__":
main()