Skip to content

Commit 0691b9d

Browse files
committed
delete ad
1 parent 552815c commit 0691b9d

3 files changed

Lines changed: 87 additions & 28 deletions

File tree

.github/scripts/expire_sponsor.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
from __future__ import annotations
3+
4+
import os
5+
from datetime import date, datetime
6+
from pathlib import Path
7+
from zoneinfo import ZoneInfo
8+
9+
10+
README = Path("README.md")
11+
START_MARKER = "<!-- SPONSOR_START expires=2026-08-28 timezone=Asia/Shanghai -->"
12+
END_MARKER = "<!-- SPONSOR_END -->"
13+
EXPIRE_ON = date.fromisoformat(os.environ.get("SPONSOR_EXPIRE_ON", "2026-08-28"))
14+
TIMEZONE = ZoneInfo(os.environ.get("SPONSOR_TIMEZONE", "Asia/Shanghai"))
15+
16+
17+
def current_date() -> date:
18+
override = os.environ.get("SPONSOR_TODAY")
19+
if override:
20+
return date.fromisoformat(override)
21+
return datetime.now(TIMEZONE).date()
22+
23+
24+
def main() -> None:
25+
today = current_date()
26+
if today < EXPIRE_ON:
27+
print(f"Sponsor block is still active until {EXPIRE_ON}; today is {today}.")
28+
return
29+
30+
text = README.read_text(encoding="utf-8")
31+
start = text.find(START_MARKER)
32+
end = text.find(END_MARKER)
33+
34+
if start == -1 and end == -1:
35+
print("Sponsor block markers are absent; nothing to remove.")
36+
return
37+
if start == -1 or end == -1 or end < start:
38+
raise SystemExit("Sponsor block markers are incomplete or out of order.")
39+
40+
end += len(END_MARKER)
41+
updated = text[:start].rstrip() + "\n\n" + text[end:].lstrip()
42+
43+
if updated == text:
44+
print("Sponsor block is already removed.")
45+
return
46+
47+
README.write_text(updated, encoding="utf-8")
48+
print(f"Removed sponsor block on {today}.")
49+
50+
51+
if __name__ == "__main__":
52+
main()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Expire sponsor block
2+
3+
on:
4+
schedule:
5+
# 00:05 in Asia/Shanghai.
6+
- cron: "5 16 * * *"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
remove-sponsor:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out repository
17+
uses: actions/checkout@v4
18+
19+
- name: Remove expired sponsor block
20+
run: python3 .github/scripts/expire_sponsor.py
21+
22+
- name: Commit README update
23+
run: |
24+
if git diff --quiet; then
25+
echo "No README changes to commit."
26+
exit 0
27+
fi
28+
29+
git config user.name "github-actions[bot]"
30+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
31+
git add README.md
32+
git commit -m "Remove expired sponsor block"
33+
git push

README.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,35 +110,9 @@ FirstSpider|2021-02-09 14:55:14,620|air_spider.py|run|line:80|INFO| 无任务,
110110

111111
## 感谢以下代理赞助商
112112

113-
### Rapidproxy代理
113+
<!-- SPONSOR_START expires=2026-08-28 timezone=Asia/Shanghai -->
114114

115-
<!--6.7-->
116-
117-
<a href="https://www.rapidproxy.io/?ref=boris " target="_blank">
118-
119-
<img src="https://markdown-media.oss-cn-beijing.aliyuncs.com/2026/04/03/github-2.png">
120-
121-
</a>
122-
123-
### SWIFTPROXY
124-
125-
<!--5.16-->
126-
127-
<a href="https://www.swiftproxy.net/?ref=boris" target="_blank">
128-
129-
<img src="https://markdown-media.oss-cn-beijing.aliyuncs.com/2026/04/17/mmexport1776389746816.jpg">
130-
131-
</a>
132-
133-
### NovProxy
134-
135-
<!--5.24-->
136-
g
137-
<a href="https://novproxy.com?kwd=tt-git" target="_blank">
138-
139-
<img src="https://markdown-media.oss-cn-beijing.aliyuncs.com/2026/04/24/mmexport1777023699277.jpg">
140-
141-
</a>
115+
<!-- SPONSOR_END -->
142116

143117

144118
## 参与贡献

0 commit comments

Comments
 (0)