-
Notifications
You must be signed in to change notification settings - Fork 100
/
qqreadCookie.py
86 lines (65 loc) · 2.67 KB
/
qqreadCookie.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
import requests
import json
import time
import os
import re
import notification
"""
需要推送通知的,修改notification.py
"""
###############################
# 方案1 本地执行、云服务器、云函数等等 下载到本地,填写参数,执行
# qqreadheaders参数填写,填写完注意不要上传
# 如果有其它账号,还需要将qqreadheaders2填写进下面的qqreadheadersLists
qqreadheaders1 = {}
qqreadheaders2 = {}
# qqreadheaders参数填写,填写完注意不要上传
# 如果有其它账号,还需要将qqreadtimeheaders2填写进下面的qqreadheadersLists
qqreadtimeheaders1 = {}
qqreadtimeheaders2 = {}
# qqreadheaders参数填写,填写完注意不要上传
# 如果有其它账号,还需要将qqreadheaders2填写进下面的qqreadheadersLists
qqreadtimeurl1 = ""
qqreadtimeurl2 = ""
# 如为多账号,请修改下面参数
qqreadheadersLists = [qqreadheaders1, qqreadheaders2]
qqreadtimeheadersLists = [qqreadtimeheaders1, qqreadtimeheaders2]
qqreadtimeurlLists = [qqreadtimeurl1, qqreadtimeurl2]
qqreadLists = list(
zip(qqreadheadersLists, qqreadtimeheadersLists, qqreadtimeurlLists))
####################################
# 方案2 GitHub action 自动运行 各参数读取自secrets
def github_secrets():
qqreadheaders = os.environ["QQREADHEADERS"].split('\n')
qqreadtimeheaders = os.environ["QQREADTIMEHEADERS"].split('\n')
qqreadtimeurl = os.environ["QQREADTIMEURL"].split('\n')
qqreadLists = []
if len(qqreadheaders) == len(qqreadtimeheaders) and len(qqreadtimeheaders) == len(qqreadtimeurl):
qqreadLists = list(
zip(qqreadheaders, qqreadtimeheaders, qqreadtimeurl))
return qqreadLists
else:
print("各项Secrets数量不符,请修改!")
return
#######################################
def valid(qqheaders):
headers = eval(qqheaders[0])
response = requests.get(
'https://mqqapi.reader.qq.com/mqq/user/init', headers=headers)
if response.json()["data"]['isLogin'] == False:
QQNUM = re.findall(r'ywguid=(.*?);ywkey', headers['Cookie'])[0]
print(f"""## {QQNUM}: headers过期""")
notification.notify(
f"""## QQ账号【{QQNUM}】 headers过期""", f"""## 账号【{QQNUM}】 headers过期 ,及时修改""")
return False
return True
def get_cookies():
if "QQREADHEADERS" and "QQREADTIMEHEADERS" and "QQREADTIMEURL" in os.environ:
qqreadLists = github_secrets()
return [i for i in qqreadLists if valid(i)]
print("***"*20)
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
if __name__ == "__main__":
print(">>>检查有效性")
for i in get_cookies():
print(i)