Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

工作流:修复HTML格式,尝试支持BBSTR #285

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 7 additions & 37 deletions ForumHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
print(f"登录名: {name}")
print(f"密码: {password}")


# tr.monika.love
# 创建会话
session = rq.Session()
Expand Down Expand Up @@ -43,11 +42,13 @@
# 修复插件列表路径
md = re.sub(r'\b[^(\[]*\/README.md\b', lambda x: "https://gitee.com/kksjsj/TShockPlugin/blob/master/" + x.group(), md)

# 编辑论坛仓库帖子
data = {
"text": md
}
html = rq.post("https://api.github.com/markdown", headers=headers, data=json.dumps(data)).text


# 编辑论坛仓库帖子
data = {
"_xfToken": data_csrf,
"prefix_id[]": 7,
Expand Down Expand Up @@ -99,23 +100,8 @@
}
session.post("https://trhub.cn/login/login",data=data,allow_redirects=True)

# 使用GithubAPI转换MD到Html
with open('README.md', 'r',encoding='utf-8') as file:
md = file.read()
headers = {
"Accept": "application/vnd.github+json",
#"Authorization": "Bearer <YOUR-TOKEN>",
"X-GitHub-Api-Version": "2022-11-28"
}

# 修复插件列表路径
md = re.sub(r'\b[^(\[]*\/README.md\b', lambda x: "https://gitee.com/kksjsj/TShockPlugin/blob/master/" + x.group(), md)

# 编辑论坛仓库帖子
data = {
"text": md
}
html = rq.post("https://api.github.com/markdown", headers=headers, data=json.dumps(data)).text
data = {
"_xfToken": data_csrf,
"prefix_id": 0,
Expand Down Expand Up @@ -147,7 +133,7 @@
name = "Cai233"
# 创建会话
session = rq.Session()
resp = session.get("https://tr.lizigo.cn/")
resp = session.get("https://www.bbstr.net/")

# 获取xf_token
soup = BeautifulSoup(resp.text, 'html.parser')
Expand All @@ -160,28 +146,12 @@
"login":name,
"password": password,
"remember": 0,
"_xfRedirect": "https://tr.lizigo.cn/",
}
session.post("https://tr.lizigo.cn/login/login",data=data,allow_redirects=True)


# 使用GithubAPI转换MD到Html
with open('README.md', 'r',encoding='utf-8') as file:
md = file.read()
headers = {
"Accept": "application/vnd.github+json",
#"Authorization": "Bearer <YOUR-TOKEN>",
"X-GitHub-Api-Version": "2022-11-28"
"_xfRedirect": "https://www.bbstr.net/",
}
session.post("https://www.bbstr.net/login/login",data=data,allow_redirects=True)

# 修复插件列表路径
md = re.sub(r'\b[^(\[]*\/README.md\b', lambda x: "https://gitee.com/kksjsj/TShockPlugin/blob/master/" + x.group(), md)

# 编辑论坛仓库帖子
data = {
"text": md
}
html = rq.post("https://api.github.com/markdown", headers=headers, data=json.dumps(data)).text
data = {
"title": "TShock插件收集仓库(自动更新版)",
"tag_line": "此帖会自动更新插件列表(BBSTR高概率同步失败)",
Expand Down Expand Up @@ -216,7 +186,7 @@


try:
resp = session.post("https://tr.lizigo.cn/resources/167/edit",data=data)
resp = session.post("https://www.bbstr.net/resources/167/edit",data=data,timeout=10)
res = resp.json()
if res['status'] == 'ok':
print(f"[BBSTR]修改成功: {res}")
Expand Down
10 changes: 5 additions & 5 deletions ForumUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



html =f'<font size="6">✅ [{result[0]["title"]}]({result[0]["html_url"]}) ({datetime.datetime.strptime(result[0]["closed_at"], "%Y-%m-%dT%H:%M:%SZ").date()})</font>'
html = f'<font size="6">✅ <a href="{result[0]["html_url"]}">{result[0]["title"]}</a> ({datetime.datetime.strptime(result[0]["closed_at"], "%Y-%m-%dT%H:%M:%SZ").date()})</font>'
# 读取用户名 密码
name = sys.argv[1]
password = sys.argv[2]
Expand Down Expand Up @@ -114,7 +114,7 @@
name = "Cai233"
# 创建会话
session = rq.Session()
resp = session.get("https://tr.lizigo.cn/")
resp = session.get("https://www.bbstr.net/",timeout=10)

# 获取xf_token
soup = BeautifulSoup(resp.text, 'html.parser')
Expand All @@ -127,9 +127,9 @@
"login":name,
"password": password,
"remember": 0,
"_xfRedirect": "https://tr.lizigo.cn/",
"_xfRedirect": "https://www.bbstr.net/",
}
session.post("https://tr.lizigo.cn/login/login",data=data,allow_redirects=True)
session.post("https://www.bbstr.net/login/login",data=data,allow_redirects=True)

# 模拟登录

Expand All @@ -150,7 +150,7 @@
"_xfResponseType": "json"
}
try:
resp = session.post("https://tr.lizigo.cn/threads/2427/add-reply",data=data)
resp = session.post("https://www.bbstr.net/threads/2427/add-reply",data=data,timeout=10)
res = resp.json()
if res['status'] == 'ok':
print(f"[BBSTR]修改成功: {res}")
Expand Down
Loading