Skip to content

Commit

Permalink
多次请求以修复下载蓝牙音频信号失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
AuYang261 committed May 30, 2024
1 parent edd7a82 commit 1d6390e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ def draw_multi_select(stdscr, messages: list, center_row):
)


def multi_select(stdscr, options, title, subtitle=""):
def multi_select(stdscr, options, title, subtitle="", checked=None):
# curses.curs_set(0) # 隐藏光标
checked = [False] * len(options)
if checked is None:
checked = [False] * len(options)
else:
checked = [bool(c) for c in checked]
current_row = 0
while True:
draw_menu(stdscr, options, checked, title, subtitle, current_row)
Expand Down Expand Up @@ -157,6 +160,7 @@ def config(stdscr):
["下载蓝牙音频"],
"选择是否下载教室蓝牙话筒的音频(如果有的话):",
"若教师未使用教室蓝牙话筒则该音频无声音",
checked=[True],
)

stdscr.clear()
Expand Down
8 changes: 6 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def get_audio_url(video_id):
def download_audio(url, path, name):
token = getToken()
url = add_signature_for_url(url, token, *getSignature())
print(url)
res = requests.get(url, headers=headers)
_headers = headers.copy()
_headers["Host"] = "cvideo.yanhekt.cn"
res = requests.get(url, headers=_headers)
while res.status_code != 200:
time.sleep(0.1)
res = requests.get(url, headers=_headers)
with open(f"{path}/{name}.aac", "wb") as f:
f.write(res.content)

0 comments on commit 1d6390e

Please sign in to comment.