fix(download): 修复音乐下载功能并更新版本号

- 移除未使用的total_ordering导入
- 添加全局headers变量声明
- 在requests.get中添加headers参数
- 更新应用版本号从4.3.4到4.3.5
- 添加HTTP请求头信息以改善兼容性
This commit is contained in:
2025-12-20 20:31:13 +08:00
parent 64bba311ae
commit 76392863ad

View File

@ -1,5 +1,4 @@
import time
from functools import total_ordering
from tkinter import *
import threading
import pygame
@ -126,7 +125,7 @@ def download_check(*value):
def download_music(song_name, choose):
global progressbar, downloading
global progressbar, downloading, headers
def update_progressbar():
while True:
@ -228,7 +227,7 @@ def download_music(song_name, choose):
lrc = ""
lrc = lrc.replace("\\n", "\n")
print("请求api:", url)
response = requests.get(music_url, stream=True)
response = requests.get(music_url, stream=True, headers=headers)
print("下载直链:", music_url)
formated = music_url.split("?")[0].rsplit(".", 1)[1]
if formated not in ["m4a", "mp3", "ogg", "flac"]:
@ -1328,7 +1327,7 @@ def search_local_song():
time.sleep(1)
version = "4.3.4"
version = "4.3.5"
poem = ""
appdata = os.getenv("APPDATA")
make_resource()
@ -1433,6 +1432,14 @@ playingmode_dict = {
1: "rand",
2: "sequ"
}
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',
}
if path == "./music":
if os.path.exists("./music"):