From 5189898b6b81a0034be3173cb5c7b2f90e576c26 Mon Sep 17 00:00:00 2001 From: NFL_jiancx <1678594309@qq.com> Date: Sat, 20 Dec 2025 20:31:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(test):=20=E5=AE=9E=E7=8E=B0=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 替换 os 模块为 requests 库 - 添加音频文件 URL 和请求头配置 - 实现获取文件总长度的功能 - 移除本地音频文件路径和系统调用 - 添加网络请求相关依赖和参数设置 --- test.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 599e8f4..04e55c2 100644 --- a/test.py +++ b/test.py @@ -1,4 +1,16 @@ -import os +import requests -audio_file = "C:/Users/Administrator/Music/国风堂#哦漏 - 知我.mp3" -os.startfile(audio_file) \ No newline at end of file +url = "https://er-sycdn.kuwo.cn/5a1fdd7e1178a867af57c6b0ba576889/69468dc3/resource/30106/trackmedia/F000000bYDlc2XxKLs.flac" + +headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', + 'Accept-Language': 'en-US,en;q=0.5', + 'Accept-Encoding': 'gzip, deflate', + 'Connection': 'keep-alive', + 'Upgrade-Insecure-Requests': '1', +} + +total_length = int(requests.get(url, stream=True, headers=headers).headers.get('content-length')) + +print(total_length) \ No newline at end of file