Spaces:
Running
Running
Update merged2upload.py
Browse files- merged2upload.py +21 -1
merged2upload.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import requests
|
2 |
import base64
|
3 |
import os
|
|
|
|
|
4 |
|
5 |
def fetch_and_decode_base64(url):
|
6 |
print(url)
|
@@ -33,7 +35,12 @@ def upload_to_gist(content, gist_id, github_token):
|
|
33 |
except requests.RequestException as e:
|
34 |
print(f"Error updating Gist: {e}")
|
35 |
|
36 |
-
def
|
|
|
|
|
|
|
|
|
|
|
37 |
file_path = '/app/aggregator/data/subscribes.txt'
|
38 |
|
39 |
with open(file_path, 'r') as file:
|
@@ -58,6 +65,19 @@ def main():
|
|
58 |
github_token = os.getenv('GITHUB_TOKEN')
|
59 |
gist_id = os.getenv('GITHUB_GIST_ID')
|
60 |
upload_to_gist(encoded_merged_content, gist_id, github_token)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
main()
|
|
|
1 |
import requests
|
2 |
import base64
|
3 |
import os
|
4 |
+
import time
|
5 |
+
import schedule
|
6 |
|
7 |
def fetch_and_decode_base64(url):
|
8 |
print(url)
|
|
|
35 |
except requests.RequestException as e:
|
36 |
print(f"Error updating Gist: {e}")
|
37 |
|
38 |
+
def run_task():
|
39 |
+
print("执行任务...")
|
40 |
+
|
41 |
+
# 运行 collect.py
|
42 |
+
os.system("cd /app/aggregator && python -u subscribe/collect.py -si")
|
43 |
+
|
44 |
file_path = '/app/aggregator/data/subscribes.txt'
|
45 |
|
46 |
with open(file_path, 'r') as file:
|
|
|
65 |
github_token = os.getenv('GITHUB_TOKEN')
|
66 |
gist_id = os.getenv('GITHUB_GIST_ID')
|
67 |
upload_to_gist(encoded_merged_content, gist_id, github_token)
|
68 |
+
|
69 |
+
print("任务完成")
|
70 |
+
|
71 |
+
def main():
|
72 |
+
# 立即运行一次任务
|
73 |
+
run_task()
|
74 |
+
|
75 |
+
# 设置每6小时运行一次任务
|
76 |
+
schedule.every(6).hours.do(run_task)
|
77 |
+
|
78 |
+
while True:
|
79 |
+
schedule.run_pending()
|
80 |
+
time.sleep(1)
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
main()
|