From ccb16fd24ec659aebeb33566a0ab912be87e1717 Mon Sep 17 00:00:00 2001 From: ymm Date: Wed, 19 Feb 2025 20:41:46 +0800 Subject: [PATCH] fix: path error --- __init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index 2e2e206..d9148b2 100644 --- a/__init__.py +++ b/__init__.py @@ -375,19 +375,16 @@ class VodToLocalNode: output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "download", f"{sub_app_id}", f"{file_id}.mp4" ) return self._download_file(url=media_url, save_path=output_dir, timeout=60 * 10) - def _download_file(self, url, save_path, timeout=30): + def _download_file(self, url: str, save_path: str, timeout: int=30): """下载文件到本地""" try: - with requests.get(url, stream=True, timeout=timeout) as response: response.raise_for_status() - with open(save_path, "wb") as f: for chunk in response.iter_content(chunk_size=8192): if chunk: f.write(chunk) - - return str(save_path.resolve()) + return save_path except Exception as e: raise RuntimeError(f"Download error: {e}")