forked from ioutime/Aiqiyi_Sign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_action.py
142 lines (132 loc) · 4.1 KB
/
local_action.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
'''
@FILE : action.py
@DSEC : 爱奇艺会员打卡
@AUTHOR : ioutime
@DATE : 2021/07/11 00:56:17
@VERSION : 1.1
'''
import requests
import argparse
import execjs
import re
from http import cookiejar
cookie = '''cookie值'''
# 创建一个session,作用会自动保存cookie
Session = requests.session()
#推送信息
def push_info(infos,msg):
token = infos["token"]
if not token:
return
else:
try:
url = "http://www.pushplus.plus/send?token="+token+"&title=爱奇艺打卡&content="+msg+"&template=html"
requests.get(url=url)
except Exception as e:
print('推送失败')
print(e)
#参数
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("-t", dest="token", help="pushplus的token值")
args = parser.parse_args()
return {
"token" : args.token,
}
#sign
def member_sign(cookies_dict):
P00001 = cookies_dict.get('P00001')
if P00001 == None:
msg = "输入的cookie有问题(P00001),请重新获取"
return msg
login = Session.get('https://static.iqiyi.com/js/qiyiV2/20201023105821/common/common.js').text
regex1=re.compile("platform:\"(.*?)\"")
platform=regex1.findall(login)
if len(platform) == 0:
msg = "出错了,无法获取platform"
return msg
url='https://tc.vip.iqiyi.com/taskCenter/task/userSign?P00001='+P00001+'&platform='+platform[0] + '&lang=zh_CN&app_lm=cn&deviceID=pcw-pc&version=v2'
try:
sign=Session.get(url)
strr = sign.json()
try:
sign_msg = strr.get('msg')
except:
msg = "未签"
str2 = strr.get('data')
continueSignDaysSum = str2.get('continueSignDaysSum')
rewardDay = 7 if continueSignDaysSum%28<=7 else (14 if continueSignDaysSum%28<=14 else 28)
rouund_day = 28 if continueSignDaysSum%28 == 0 else continueSignDaysSum%28
growth = str2.get('acquireGiftList')[0]
msg = f"{sign_msg}\n{growth}\n连续签到:{continueSignDaysSum}天\n签到周期:{rouund_day}天/{rewardDay}天\n"
except Exception as e:
print(e)
msg = "出错了,未签到成功,可能是程序问题,也可能你不是爱奇艺会员"
return msg
#获取用户信息
def get_info(cookies_dict):
P00001 = cookies_dict.get('P00001')
if P00001 == None:
msg = "输入的cookie有问题(P00001),请重新获取"
print(msg)
return msg
url = 'http://serv.vip.iqiyi.com/vipgrowth/query.action'
params = {
"P00001": P00001,
}
res = Session.get(url, params=params)
if res.json()["code"] == "A00000":
try:
res_data = res.json()["data"]
#VIP等级
level = res_data["level"]
#升级需要成长值
distance = res_data["distance"]
#VIP到期时间
deadline = res_data["deadline"]
msg = f"VIP等级:{level}\n升级需成长值:{distance}\nVIP到期时间:{deadline}"
except:
msg = "获取个人具体信息失败"
else:
msg = "获取个人信息失败"
return msg
#转换获取的COOKIE
def transform(infos):
try:
cookies = cookie.replace(' ','')
dct = {}
lst = cookies.split(';')
for i in lst:
name = i.split('=')[0]
value = i.split('=')[1]
dct[name] = value
except:
msg0 = "输入的cookie不正确,请重新获取"
print(msg0)
push_info(infos,msg0)
return
#判断是否有要的值
P00001 = dct.get('P00001')
if P00001 == None:
msg0 = "输入的cookie有问题(P00001),请重新获取"
print(msg0)
push_info(infos,msg0)
return
#签到
msg0 = member_sign(dct)
#获取用户信息
# msg1 = get_info(dct)
# #输出信息
# msg = msg0 + msg1
print(msg0)
#推送消息
push_info(infos,msg0)
return
#主函数
def main(infos):
'''
爱奇艺会员打卡,本地代码执行
'''
transform(infos)
if __name__=="__main__":
main(get_args())