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