forked from OreosLab/checkinpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathck_iqiyi.py
236 lines (219 loc) · 8.16 KB
/
ck_iqiyi.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
# -*- coding: utf-8 -*-
"""
cron: 55 23 * * *
new Env('爱奇艺');
"""
import json
import re
import time
from urllib.parse import unquote
import requests
from notify_mtr import send
from utils import get_data
class IQIYI:
def __init__(self, check_items):
self.check_items = check_items
@staticmethod
def parse_cookie(cookie):
p00001 = re.findall(r"P00001=(.*?);", cookie)[0]
p00002 = (
re.findall(r"P00002=(.*?);", cookie)[0]
if re.findall(r"P00002=(.*?);", cookie)
else ""
)
p00003 = re.findall(r"P00003=(.*?);", cookie)[0]
return p00001, p00002, p00003
@staticmethod
def user_information(p00001):
"""
用户信息查询
"""
time.sleep(3)
url = "http://serv.vip.iqiyi.com/vipgrowth/query.action"
params = {"P00001": p00001}
res = requests.get(url=url, params=params).json()
if res["code"] == "A00000":
try:
res_data = res.get("data", {})
level = res_data.get("level", 0) # VIP 等级
growthvalue = res_data.get("growthvalue", 0) # 当前 VIP 成长值
distance = res_data.get("distance", 0) # 升级需要成长值
deadline = res_data.get("deadline", "非 VIP 用户") # VIP 到期时间
today_growth_value = res_data.get("todayGrowthValue", 0) # 今日成长值
msg = (
f"VIP 等级: {level}\n当前成长值: {growthvalue}\n"
f"升级需成长值: {distance}\n今日成长值: +{today_growth_value}\nVIP 到期时间: {deadline}"
)
except Exception as e:
msg = str(e)
print(msg)
else:
msg = res.get("msg")
return msg
@staticmethod
def sign(p00001):
"""
VIP 签到
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
params = {"P00001": p00001, "autoSign": "yes"}
res = requests.get(url=url, params=params).json()
if res["code"] == "A00000":
try:
growth = res["data"]["signInfo"]["data"]["rewardMap"]["growth"]
cumulate_sign_days_sum = res["data"]["signInfo"]["data"][
"cumulateSignDaysSum"
]
msg = f"+{growth}成长值\n当月签到: {cumulate_sign_days_sum}天"
except Exception as e:
print(e)
msg = res["data"]["signInfo"].get("msg")
else:
msg = res.get("msg")
return msg
@staticmethod
def query_user_task(p00001):
"""
获取 VIP 日常任务 和 taskCode(任务状态)
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
params = {"P00001": p00001}
task_list = []
res = requests.get(url=url, params=params).json()
if res["code"] == "A00000":
for item in res["data"]["tasks"]["daily"]:
task_list.append(
{
"name": item["name"],
"taskCode": item["taskCode"],
"status": item["status"],
"taskReward": item["taskReward"]["task_reward_growth"],
}
)
return task_list
@staticmethod
def join_task(p00001, task_list):
"""
遍历完成任务
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/joinTask"
params = {
"P00001": p00001,
"taskCode": "",
"platform": "bb136ff4276771f3",
"lang": "zh_CN",
}
for item in task_list:
if item["status"] == 2:
params["taskCode"] = item["taskCode"]
requests.get(url=url, params=params)
@staticmethod
def get_task_rewards(p00001, task_list):
"""
获取任务奖励
:return: 返回信息
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/getTaskRewards"
params = {
"P00001": p00001,
"taskCode": "",
"platform": "bb136ff4276771f3",
"lang": "zh_CN",
}
growth_task = 0
for item in task_list:
if item["status"] == 0:
params["taskCode"] = item.get("taskCode")
requests.get(url=url, params=params)
elif item["status"] == 4:
requests.get(
url="https://tc.vip.iqiyi.com/taskCenter/task/notify", params=params
)
params["taskCode"] = item.get("taskCode")
requests.get(url=url, params=params)
elif item["status"] == 1:
growth_task += item["taskReward"]
msg = f"+{growth_task}成长值"
return msg
@staticmethod
def draw(draw_type, p00001, p00003):
"""
查询抽奖次数(必),抽奖
:param draw_type: 类型。0 查询次数;1 抽奖
:param p00001: 关键参数
:param p00003: 关键参数
: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": p00003,
"psp_cki": p00001,
"psp_status": 3,
"secure_v": 1,
"secure_p": "GPhone",
"req_sn": round(time.time() * 1000),
}
if draw_type == 1:
del params["lottery_chance"]
res = requests.get(url=url, params=params).json()
if not res.get("code"):
chance = int(res.get("daysurpluschance"))
msg = res.get("awardName")
return {"status": True, "msg": msg, "chance": chance}
else:
try:
msg = res.get("kv", {}).get("msg")
except Exception as e:
print(e)
msg = res["errorReason"]
return {"status": False, "msg": msg, "chance": 0}
def main(self):
msg_all = ""
for check_item in self.check_items:
p00001, p00002, p00003 = self.parse_cookie(check_item.get("cookie"))
sign_msg = self.sign(p00001=p00001)
chance = self.draw(0, p00001=p00001, p00003=p00003)["chance"]
if chance:
draw_msg = ""
for _ in range(chance):
ret = self.draw(1, p00001=p00001, p00003=p00003)
draw_msg += ret["msg"] + ";" if ret["status"] else ""
else:
draw_msg = "抽奖机会不足"
task_msg = ""
for _ in range(6):
task_list = self.query_user_task(p00001=p00001)
self.join_task(p00001=p00001, task_list=task_list)
time.sleep(10)
task_msg = self.get_task_rewards(p00001=p00001, task_list=task_list)
try:
user_info = json.loads(unquote(p00002, encoding="utf-8"))
user_name = user_info.get("user_name")
user_name = user_name.replace(user_name[3:7], "****")
nickname = user_info.get("nickname")
except Exception as e:
print(f"获取用户信息失败,错误信息: {e}")
nickname = "未获取到,请检查 Cookie 中 P00002 字段"
user_name = "未获取到,请检查 Cookie 中 P00002 字段"
user_msg = self.user_information(p00001=p00001)
msg = (
f"用户账号: {user_name}\n用户昵称: {nickname}\n{user_msg}\n"
f"签到奖励: {sign_msg}\n任务奖励: {task_msg}\n抽奖奖励: {draw_msg}"
)
msg_all += msg + "\n\n"
return msg_all
def start():
data = get_data()
_check_items = data.get("IQIYI", [])
res = IQIYI(check_items=_check_items).main()
send("爱奇艺", res)
if __name__ == "__main__":
start()