肌肉男功能
This commit is contained in:
@@ -46,6 +46,14 @@ class BotVideoMan:
|
||||
return
|
||||
|
||||
def download_video(self, api_url, save_dir):
|
||||
# 确保 save_dir 是一个目录
|
||||
if os.path.isfile(save_dir):
|
||||
print(f"错误: {save_dir} 是一个文件,不能作为目录使用。")
|
||||
return None
|
||||
|
||||
os.makedirs(save_dir, exist_ok=True)
|
||||
save_path = os.path.join(save_dir, "video.mp4")
|
||||
|
||||
response = requests.get(api_url)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
@@ -53,8 +61,6 @@ class BotVideoMan:
|
||||
if video_url:
|
||||
video_response = requests.get(video_url, stream=True)
|
||||
if video_response.status_code == 200:
|
||||
os.makedirs(save_dir, exist_ok=True)
|
||||
save_path = os.path.join(save_dir, "video.mp4")
|
||||
with open(save_path, "wb") as file:
|
||||
for chunk in video_response.iter_content(chunk_size=1024):
|
||||
file.write(chunk)
|
||||
|
||||
Reference in New Issue
Block a user