xjf6b commited on
Commit
5a06a76
1 Parent(s): 9b03d07

Update merged2upload.py

Browse files
Files changed (1) hide show
  1. merged2upload.py +7 -7
merged2upload.py CHANGED
@@ -3,14 +3,14 @@ import base64
3
  import os
4
 
5
  def fetch_and_decode_base64(url):
6
- print(url)
7
  try:
8
  response = requests.get(url, verify=False)
9
  response.raise_for_status()
10
  decoded_content = base64.b64decode(response.text)
11
  return decoded_content.decode('utf-8')
12
  except requests.RequestException as e:
13
- print(f"Error fetching {url}: {e}")
14
  return None
15
 
16
  def upload_to_gist(content, gist_id, github_token):
@@ -29,9 +29,9 @@ def upload_to_gist(content, gist_id, github_token):
29
  try:
30
  response = requests.patch(url, headers=headers, json=data)
31
  response.raise_for_status()
32
- print(f"Successfully updated Gist: {gist_id}")
33
  except requests.RequestException as e:
34
- print(f"Error updating Gist: {e}")
35
 
36
  def main():
37
  file_path = '/app/aggregator/data/subscribes.txt'
@@ -49,12 +49,12 @@ def main():
49
  merged_content = "\n".join(all_decoded_texts)
50
  encoded_merged_content = base64.b64encode(merged_content.encode('utf-8')).decode('utf-8')
51
 
52
- merged_file_path = '/app/aggregator/data/merged.txt'
53
  with open(merged_file_path, 'w') as file:
54
  file.write(encoded_merged_content)
55
- print(f"Encoded merged content written to {merged_file_path}")
56
 
57
- # Upload the merged content to the Gist
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)
 
3
  import os
4
 
5
  def fetch_and_decode_base64(url):
6
+ print(f"正在获取 {url}")
7
  try:
8
  response = requests.get(url, verify=False)
9
  response.raise_for_status()
10
  decoded_content = base64.b64decode(response.text)
11
  return decoded_content.decode('utf-8')
12
  except requests.RequestException as e:
13
+ print(f"获取 {url} 时出错: {e}")
14
  return None
15
 
16
  def upload_to_gist(content, gist_id, github_token):
 
29
  try:
30
  response = requests.patch(url, headers=headers, json=data)
31
  response.raise_for_status()
32
+ print(f"成功更新 Gist: {gist_id}")
33
  except requests.RequestException as e:
34
+ print(f"更新 Gist 时出错: {e}")
35
 
36
  def main():
37
  file_path = '/app/aggregator/data/subscribes.txt'
 
49
  merged_content = "\n".join(all_decoded_texts)
50
  encoded_merged_content = base64.b64encode(merged_content.encode('utf-8')).decode('utf-8')
51
 
52
+ merged_file_path = '/app/merged.txt'
53
  with open(merged_file_path, 'w') as file:
54
  file.write(encoded_merged_content)
55
+ print(f"已将编码后的合并内容写入 {merged_file_path}")
56
 
57
+ # 上传合并内容到 Gist
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)