1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
""" |
3
|
|
|
cron: 31 7 * * * |
4
|
|
|
new Env('AcFun'); |
5
|
|
|
""" |
6
|
|
|
|
7
|
|
|
import re |
8
|
|
|
|
9
|
|
|
import requests |
10
|
|
|
|
11
|
|
|
from notify_mtr import send |
12
|
|
|
from utils import get_data |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class AcFun: |
16
|
|
|
def __init__(self, check_items): |
17
|
|
|
self.check_items = check_items |
18
|
|
|
self.contentid = "27259341" |
19
|
|
|
self.st = "" |
20
|
|
|
|
21
|
|
|
@staticmethod |
22
|
|
|
def login(phone, password, session): |
23
|
|
|
url = "https://id.app.acfun.cn/rest/web/login/signin" |
24
|
|
|
body = f"username={phone}&password={password}&key=&captcha=" |
25
|
|
|
res = session.post(url=url, data=body).json() |
26
|
|
|
return (True, res) if res.get("result") == 0 else (False, res.get("err_msg")) |
27
|
|
|
|
28
|
|
|
def get_video(self, session): |
29
|
|
|
url = "https://www.acfun.cn/rest/pc-direct/rank/channel" |
30
|
|
|
res = session.get(url=url).json() |
31
|
|
|
self.contentid = res.get("rankList")[0].get("contentId") |
32
|
|
|
|
33
|
|
|
@staticmethod |
34
|
|
|
def sign(session): |
35
|
|
|
url = "https://www.acfun.cn/rest/pc-direct/user/signIn" |
36
|
|
|
res = session.post(url=url).json() |
37
|
|
|
return res.get("msg") |
38
|
|
|
|
39
|
|
|
def danmu(self, session): |
40
|
|
|
url = "https://www.acfun.cn/rest/pc-direct/new-danmaku/add" |
41
|
|
|
data = { |
42
|
|
|
"mode": "1", |
43
|
|
|
"color": "16777215", |
44
|
|
|
"size": "25", |
45
|
|
|
"body": "123321", |
46
|
|
|
"videoId": "26113662", |
47
|
|
|
"position": "2719", |
48
|
|
|
"type": "douga", |
49
|
|
|
"id": "31224739", |
50
|
|
|
"subChannelId": "1", |
51
|
|
|
"subChannelName": "动画", |
52
|
|
|
} |
53
|
|
|
response = session.get(url=f"https://www.acfun.cn/v/ac{self.contentid}") |
54
|
|
|
videoId = re.findall(r'"currentVideoId":(\d+),', response.text) |
55
|
|
|
subChannel = re.findall( |
56
|
|
|
r'{subChannelId:(\d+),subChannelName:"([\u4e00-\u9fa5]+)"}', response.text |
57
|
|
|
) |
58
|
|
|
if videoId: |
59
|
|
|
data["videoId"] = videoId[0] |
60
|
|
|
data["subChannelId"] = subChannel[0][0] |
61
|
|
|
data["subChannelName"] = subChannel[0][1] |
62
|
|
|
res = session.post(url=url, data=data).json() |
63
|
|
|
return "弹幕成功" if res.get("result") == 0 else "弹幕失败" |
64
|
|
|
|
65
|
|
|
def get_token(self, session): |
66
|
|
|
url = "https://id.app.acfun.cn/rest/web/token/get?sid=acfun.midground.api" |
67
|
|
|
res = session.post(url=url).json() |
68
|
|
|
self.st = res.get("acfun.midground.api_st") if res.get("result") == 0 else "" |
69
|
|
|
|
70
|
|
|
def like(self, session): |
71
|
|
|
like_url = "https://kuaishouzt.com/rest/zt/interact/add" |
72
|
|
|
unlike_url = "https://kuaishouzt.com/rest/zt/interact/delete" |
73
|
|
|
body = ( |
74
|
|
|
f"kpn=ACFUN_APP&kpf=PC_WEB&subBiz=mainApp&interactType=1&" |
75
|
|
|
f"objectType=2&objectId={self.contentid}&acfun.midground.api_st={self.st}&" |
76
|
|
|
f"extParams%5BisPlaying%5D=false&extParams%5BshowCount%5D=1&extParams%5B" |
77
|
|
|
f"otherBtnClickedCount%5D=10&extParams%5BplayBtnClickedCount%5D=0" |
78
|
|
|
) |
79
|
|
|
res = session.post(url=like_url, data=body).json() |
80
|
|
|
session.post(url=unlike_url, data=body) |
81
|
|
|
return "点赞成功" if res.get("result") == 1 else "点赞失败" |
82
|
|
|
|
83
|
|
|
def throwbanana(self, session): |
84
|
|
|
url = "https://www.acfun.cn/rest/pc-direct/banana/throwBanana" |
85
|
|
|
data = {"resourceId": self.contentid, "count": "1", "resourceType": "2"} |
86
|
|
|
res = session.post(url=url, data=data).json() |
87
|
|
|
return "投🍌成功" if res.get("result") == 0 else "投🍌失败" |
88
|
|
|
|
89
|
|
|
@staticmethod |
90
|
|
|
def get_info(session): |
91
|
|
|
url = "https://www.acfun.cn/rest/pc-direct/user/personalInfo" |
92
|
|
|
res = session.get(url=url).json() |
93
|
|
|
if res.get("result") != 0: |
94
|
|
|
return "查询失败" |
95
|
|
|
info = res.get("info") |
96
|
|
|
return f'当前等级: {info.get("level")}\n持有香蕉: {info.get("banana")}' |
97
|
|
|
|
98
|
|
|
def main(self): |
99
|
|
|
msg_all = "" |
100
|
|
|
for check_item in self.check_items: |
101
|
|
|
phone = check_item.get("phone") |
102
|
|
|
password = check_item.get("password") |
103
|
|
|
|
104
|
|
|
s = requests.session() |
105
|
|
|
s.headers.update( |
106
|
|
|
{ |
107
|
|
|
"accept": "*/*", |
108
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", |
109
|
|
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8", |
110
|
|
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " |
111
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) " |
112
|
|
|
"Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70", |
113
|
|
|
"Referer": "https://www.acfun.cn/", |
114
|
|
|
} |
115
|
|
|
) |
116
|
|
|
|
117
|
|
|
flag, res = self.login(phone, password, s) |
118
|
|
|
|
119
|
|
|
if flag is True: |
120
|
|
|
self.get_video(s) |
121
|
|
|
self.get_token(s) |
122
|
|
|
|
123
|
|
|
msg = ( |
124
|
|
|
f"帐号信息: *******{phone[-4:]}\n" |
125
|
|
|
f"签到状态: {self.sign(s)}\n" |
126
|
|
|
f"点赞任务: {self.like(s)}\n" |
127
|
|
|
f"弹幕任务: {self.danmu(s)}\n" |
128
|
|
|
f"香蕉任务: {self.throwbanana(s)}\n" |
129
|
|
|
f"{self.get_info(s)}" |
130
|
|
|
) |
131
|
|
|
|
132
|
|
|
else: |
133
|
|
|
msg = f"*******{phone[-4:]} {res}" |
134
|
|
|
|
135
|
|
|
msg_all += msg + "\n\n" |
136
|
|
|
return msg_all |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
if __name__ == "__main__": |
140
|
|
|
_data = get_data() |
141
|
|
|
_check_items = _data.get("ACFUN", []) |
142
|
|
|
result = AcFun(check_items=_check_items).main() |
143
|
|
|
send("AcFun", result) |
144
|
|
|
|