1717
1818flavors = ['release' ] # 项目只有一个标准构建版本
1919
20+ # 所有 HTTP 请求的统一请求头
21+ DEFAULT_HEADERS = {"x-cf-user" : "ankio" }
22+
2023def get_latest_tag_with_prefix (prefix ):
2124 print (f"获取最新的 tag: { prefix } " )
2225
@@ -258,6 +261,7 @@ def upload_single_attempt(filename, filename_new, channel, timeout=300):
258261 url2 = "https://cloud.ankio.net/api/fs/put"
259262 filename_new = quote ('/自动记账/自动记账/版本更新/' + channel + "/" + filename_new , 'utf-8' )
260263 headers = {
264+ ** DEFAULT_HEADERS ,
261265 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
262266 'Chrome/58.0.3029.110 Safari/537.3' ,
263267 'Authorization' : os .getenv ("ALIST_TOKEN" ),
@@ -331,6 +335,7 @@ def publish_to_github(repo, tag_name, release_name, release_body, file_path, pre
331335 # 创建 release
332336 create_release_url = f"https://api.github.com/repos/{ repo } /releases"
333337 headers = {
338+ ** DEFAULT_HEADERS ,
334339 "Authorization" : f"token { token } " ,
335340 "Accept" : "application/vnd.github.v3+json"
336341 }
@@ -360,6 +365,7 @@ def publish_to_github(repo, tag_name, release_name, release_body, file_path, pre
360365 upload_response = requests .post (
361366 upload_url + f"?name={ file_name } " ,
362367 headers = {
368+ ** DEFAULT_HEADERS ,
363369 "Authorization" : f"token { token } " ,
364370 "Accept" : "application/vnd.github.v3+json" ,
365371 "Content-Type" : "application/octet-stream" # 明确指定上传内容类型
@@ -448,7 +454,8 @@ def send_apk_with_changelog(workspace, title):
448454 "chat_id" : "@ezbook_archives" ,
449455 "caption" : "" # 空的说明文本
450456 },
451- files = {"document" : (new_name , apk_file )}
457+ files = {"document" : (new_name , apk_file )},
458+ headers = DEFAULT_HEADERS
452459 )
453460 response .raise_for_status ()
454461 file_id = response .json ()['result' ]['document' ]['file_id' ]
@@ -482,7 +489,8 @@ def send_apk_with_changelog(workspace, title):
482489 json = {
483490 "chat_id" : channel_id ,
484491 "media" : media
485- }
492+ },
493+ headers = DEFAULT_HEADERS
486494 )
487495 response .raise_for_status ()
488496 message_sent = True
@@ -502,7 +510,8 @@ def send_apk_with_changelog(workspace, title):
502510 "text" : truncate_content (content ),
503511 "parse_mode" : "MarkdownV2" ,
504512 "disable_web_page_preview" : True
505- }
513+ },
514+ headers = DEFAULT_HEADERS
506515 )
507516 response .raise_for_status ()
508517 print ("成功发送纯文本更新通知(降级方案)" )
@@ -538,7 +547,7 @@ def send_qq_bot_notification(tag, log_data, repo, commit_count):
538547 resp = requests .post (
539548 bot_url ,
540549 data = data ,
541- headers = {"Content-Type" : "application/x-www-form-urlencoded" },
550+ headers = {** DEFAULT_HEADERS , "Content-Type" : "application/x-www-form-urlencoded" },
542551 timeout = 30
543552 )
544553 if not resp .ok :
0 commit comments