fix: path error
This commit is contained in:
parent
d7ff61304f
commit
ccb16fd24e
|
|
@ -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" )
|
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)
|
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:
|
try:
|
||||||
|
|
||||||
with requests.get(url, stream=True, timeout=timeout) as response:
|
with requests.get(url, stream=True, timeout=timeout) as response:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
with open(save_path, "wb") as f:
|
with open(save_path, "wb") as f:
|
||||||
for chunk in response.iter_content(chunk_size=8192):
|
for chunk in response.iter_content(chunk_size=8192):
|
||||||
if chunk:
|
if chunk:
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
|
return save_path
|
||||||
return str(save_path.resolve())
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError(f"Download error: {e}")
|
raise RuntimeError(f"Download error: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue