diff --git a/NFLmusic.py b/NFLmusic.py index ff3523a..97ed640 100644 --- a/NFLmusic.py +++ b/NFLmusic.py @@ -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"):