Skip to content

Commit df742a6

Browse files
committed
⬆️ 升级(dailycheckin):版本号从23.10.18更新到24.01.07
♻️ 重构(dailycheckin/bilibili):移除未使用的requests.utils导入 ✨ 功能(dailycheckin/bilibili):添加不进行硬币兑换的日志消息
1 parent 463bd0c commit df742a6

33 files changed

+2551
-1
lines changed

.flake8

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[flake8]
2+
max-line-length = 120
3+
max-complexity = 24
4+
ignore = F401, W503, E203, E501, F841, E722, C901
5+
exclude =
6+
.git,
7+
__pycache__,
8+
scripts,
9+
logs,
10+
upload,
11+
build,
12+
dist,
13+
docs,
14+
migrations,
15+
.scrapy

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-added-large-files
6+
args: [--maxkb=10000]
7+
- id: check-json
8+
exclude: .vscode
9+
- id: check-case-conflict
10+
- id: detect-private-key
11+
- id: mixed-line-ending
12+
- id: trailing-whitespace
13+
- id: fix-encoding-pragma
14+
- id: requirements-txt-fixer
15+
- id: trailing-whitespace
16+
17+
- repo: https://github.com/PyCQA/autoflake
18+
rev: v2.2.1
19+
hooks:
20+
- id: autoflake
21+
22+
- repo: https://github.com/pycqa/flake8
23+
rev: 6.1.0
24+
hooks:
25+
- id: flake8
26+
exclude: ^migrations/|^uploads/|^scripts/|^logs/|^docs/|^dist/|^build/
27+
28+
- repo: https://github.com/pycqa/isort
29+
rev: 5.12.0
30+
hooks:
31+
- id: isort
32+
33+
- repo: https://github.com/psf/black
34+
rev: 23.9.1
35+
hooks:
36+
- id: black
37+
language_version: python3
38+
exclude: ^migrations/|^uploads/|^scripts/|^logs/|^docs/|^dist/|^build/

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
.PHONY: mkdocs
1+
.PHONY: clean sdist upload pre-commit mkdocs
2+
3+
sdist: clean
4+
python3 setup.py sdist bdist_wheel --universa
5+
6+
upload: clean
7+
python3 setup.py upload
8+
9+
clean:
10+
rm -rf build dailycheckin.egg-info dist
11+
12+
pre-commit:
13+
pre-commit run --all-files
214

315
mkdocs:
416
mkdocs gh-deploy --force

dailycheckin/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
import pkgutil as _pkgutil
3+
4+
5+
class CheckIn(object):
6+
name = "Base"
7+
8+
9+
__path__ = _pkgutil.extend_path(__path__, __name__)
10+
for _, _modname, _ in _pkgutil.walk_packages(path=__path__, prefix=__name__ + "."):
11+
if _modname not in ["dailycheckin.main", "dailycheckin.configs"]:
12+
__import__(_modname)

dailycheckin/__version__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
__version__ = "24.01.07"

dailycheckin/acfun/__init__.py

Whitespace-only changes.

dailycheckin/acfun/main.py

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# -*- coding: utf-8 -*-
2+
import json
3+
import os
4+
import re
5+
6+
import requests
7+
import urllib3
8+
9+
from dailycheckin import CheckIn
10+
11+
urllib3.disable_warnings()
12+
13+
14+
class AcFun(CheckIn):
15+
name = "AcFun"
16+
17+
def __init__(self, check_item: dict):
18+
self.check_item = check_item
19+
self.contentid = "27259341"
20+
self.st = None
21+
22+
@staticmethod
23+
def login(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+
return (True, res) if res.get("result") == 0 else (False, res.get("err_msg"))
28+
29+
@staticmethod
30+
def get_cookies(session, phone, password):
31+
url = "https://id.app.acfun.cn/rest/app/login/signin"
32+
headers = {
33+
"Host": "id.app.acfun.cn",
34+
"user-agent": "AcFun/6.39.0 (iPhone; iOS 14.3; Scale/2.00)",
35+
"devicetype": "0",
36+
"accept-language": "zh-Hans-CN;q=1, en-CN;q=0.9, ja-CN;q=0.8, zh-Hant-HK;q=0.7, io-Latn-CN;q=0.6",
37+
"accept": "application/json",
38+
"content-type": "application/x-www-form-urlencoded",
39+
}
40+
data = f"password={password}&username={phone}"
41+
response = session.post(url=url, data=data, headers=headers, verify=False)
42+
acpasstoken = response.json().get("acPassToken")
43+
auth_key = str(response.json().get("auth_key"))
44+
if acpasstoken and auth_key:
45+
cookies = {"acPasstoken": acpasstoken, "auth_key": auth_key}
46+
return cookies
47+
else:
48+
return False
49+
50+
def get_token(self, session):
51+
url = "https://id.app.acfun.cn/rest/web/token/get?sid=acfun.midground.api"
52+
res = session.post(url=url).json()
53+
self.st = res.get("acfun.midground.api_st") if res.get("result") == 0 else ""
54+
return self.st
55+
56+
def get_video(self, session):
57+
url = "https://www.acfun.cn/rest/pc-direct/rank/channel"
58+
res = session.get(url=url).json()
59+
self.contentid = res.get("rankList")[0].get("contentId")
60+
return self.contentid
61+
62+
@staticmethod
63+
def sign(session):
64+
url = "https://www.acfun.cn/rest/pc-direct/user/signIn"
65+
response = session.post(url=url)
66+
return {"name": "签到信息", "value": response.json().get("msg")}
67+
68+
def danmu(self, session):
69+
url = "https://www.acfun.cn/rest/pc-direct/new-danmaku/add"
70+
data = {
71+
"mode": "1",
72+
"color": "16777215",
73+
"size": "25",
74+
"body": "123321",
75+
"videoId": "26113662",
76+
"position": "2719",
77+
"type": "douga",
78+
"id": "31224739",
79+
"subChannelId": "1",
80+
"subChannelName": "动画",
81+
}
82+
response = session.get(url=f"https://www.acfun.cn/v/ac{self.contentid}")
83+
videoId = re.findall(r'"currentVideoId":(\d+),', response.text)
84+
subChannel = re.findall(
85+
r'{subChannelId:(\d+),subChannelName:"([\u4e00-\u9fa5]+)"}', response.text
86+
)
87+
if videoId:
88+
data["videoId"] = videoId[0]
89+
data["subChannelId"] = subChannel[0][0]
90+
data["subChannelName"] = subChannel[0][1]
91+
res = session.post(url=url, data=data).json()
92+
msg = "弹幕成功" if res.get("result") == 0 else "弹幕失败"
93+
return {"name": "弹幕任务", "value": msg}
94+
95+
def throwbanana(self, session):
96+
url = "https://www.acfun.cn/rest/pc-direct/banana/throwBanana"
97+
data = {"resourceId": self.contentid, "count": "1", "resourceType": "2"}
98+
res = session.post(url=url, data=data).json()
99+
msg = "投🍌成功" if res.get("result") == 0 else "投🍌失败"
100+
return {"name": "香蕉任务", "value": msg}
101+
102+
def like(self, session):
103+
like_url = "https://kuaishouzt.com/rest/zt/interact/add"
104+
unlike_url = "https://kuaishouzt.com/rest/zt/interact/delete"
105+
body = (
106+
f"kpn=ACFUN_APP&kpf=PC_WEB&subBiz=mainApp&interactType=1&"
107+
f"objectType=2&objectId={self.contentid}&acfun.midground.api_st={self.st}&"
108+
f"extParams%5BisPlaying%5D=false&extParams%5BshowCount%5D=1&extParams%5B"
109+
f"otherBtnClickedCount%5D=10&extParams%5BplayBtnClickedCount%5D=0"
110+
)
111+
res = session.post(url=like_url, data=body).json()
112+
session.post(url=unlike_url, data=body)
113+
msg = "点赞成功" if res.get("result") == 1 else "点赞失败"
114+
return {"name": "点赞任务", "value": msg}
115+
116+
def share(self, session, cookies):
117+
url = "https://api-ipv6.acfunchina.com/rest/app/task/reportTaskAction?taskType=1&market=tencent&product=ACFUN_APP&appMode=0"
118+
headers = {
119+
"Content-Type": "application/x-www-form-urlencoded",
120+
}
121+
response = session.get(url=url, headers=headers, cookies=cookies, verify=False)
122+
if response.json().get("result") == 0:
123+
msg = "分享成功"
124+
else:
125+
msg = "分享失败"
126+
return {"name": "分享任务", "value": msg}
127+
128+
@staticmethod
129+
def get_info(session):
130+
url = "https://www.acfun.cn/rest/pc-direct/user/personalInfo"
131+
res = session.get(url=url).json()
132+
if res.get("result") != 0:
133+
return [{"name": "当前等级", "value": "查询失败"}]
134+
info = res.get("info")
135+
return [
136+
{"name": "当前等级", "value": info.get("level")},
137+
{"name": "持有香蕉", "value": info.get("banana")},
138+
]
139+
140+
def main(self):
141+
phone = self.check_item.get("phone")
142+
password = self.check_item.get("password")
143+
session = requests.session()
144+
session.headers.update(
145+
{
146+
"accept": "*/*",
147+
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
148+
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
149+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
150+
"AppleWebKit/537.36 (KHTML, like Gecko) "
151+
"Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70",
152+
"Referer": "https://www.acfun.cn/",
153+
}
154+
)
155+
flag, res = self.login(phone, password, session)
156+
if flag is True:
157+
self.get_video(session=session)
158+
self.get_token(session=session)
159+
sign_msg = self.sign(session=session)
160+
like_msg = self.like(session=session)
161+
danmu_msg = self.danmu(session=session)
162+
throwbanana_msg = self.throwbanana(session=session)
163+
info_msg = self.get_info(session=session)
164+
msg = [
165+
{"name": "帐号信息", "value": phone},
166+
sign_msg,
167+
like_msg,
168+
danmu_msg,
169+
throwbanana_msg,
170+
] + info_msg
171+
else:
172+
msg = [{"name": "帐号信息", "value": phone}, {"name": "错误信息", "value": res}]
173+
msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg])
174+
return msg
175+
176+
177+
if __name__ == "__main__":
178+
with open(
179+
os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.json"),
180+
"r",
181+
encoding="utf-8",
182+
) as f:
183+
datas = json.loads(f.read())
184+
_check_item = datas.get("ACFUN", [])[0]
185+
print(AcFun(check_item=_check_item).main())

dailycheckin/baidu/__init__.py

Whitespace-only changes.

dailycheckin/baidu/main.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# -*- coding: utf-8 -*-
2+
import json
3+
import os
4+
from urllib import parse
5+
6+
import requests
7+
8+
from dailycheckin import CheckIn
9+
10+
11+
class Baidu(CheckIn):
12+
name = "百度站点提交"
13+
14+
def __init__(self, check_item: dict):
15+
self.check_item = check_item
16+
17+
@staticmethod
18+
def url_submit(data_url: str, submit_url: str, times: int = 100) -> str:
19+
site = parse.parse_qs(parse.urlsplit(submit_url).query).get("site")[0]
20+
urls_data = requests.get(url=data_url)
21+
remian = 100000
22+
success_count = 0
23+
error_count = 0
24+
for one in range(times):
25+
try:
26+
response = requests.post(url=submit_url, data=urls_data)
27+
if response.json().get("success"):
28+
remian = response.json().get("remain")
29+
success_count += response.json().get("success")
30+
else:
31+
error_count += 1
32+
except Exception as e:
33+
print(e)
34+
error_count += 1
35+
msg = [
36+
{"name": "站点地址", "value": site},
37+
{"name": "剩余条数", "value": remian},
38+
{"name": "成功条数", "value": success_count},
39+
{"name": "成功次数", "value": times - error_count},
40+
{"name": "失败次数", "value": error_count},
41+
]
42+
return msg
43+
44+
def main(self):
45+
data_url = self.check_item.get("data_url")
46+
submit_url = self.check_item.get("submit_url")
47+
times = int(self.check_item.get("times", 100))
48+
if data_url and submit_url:
49+
msg = self.url_submit(data_url=data_url, submit_url=submit_url, times=times)
50+
else:
51+
msg = {"name": "站点配置", "value": "配置错误"}
52+
msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg])
53+
return msg
54+
55+
56+
if __name__ == "__main__":
57+
with open(
58+
os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.json"),
59+
"r",
60+
encoding="utf-8",
61+
) as f:
62+
datas = json.loads(f.read())
63+
_check_item = datas.get("BAIDU", [])[0]
64+
print(Baidu(check_item=_check_item).main())

dailycheckin/bilibili/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)