From 919a40893e9d5e1621868934aed8667f7d910f65 Mon Sep 17 00:00:00 2001 From: ymm Date: Wed, 19 Feb 2025 20:12:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=88=B0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index 00393fd..78b5e16 100644 --- a/__init__.py +++ b/__init__.py @@ -323,7 +323,7 @@ class VodToLocalNode: return { "required": { "file_id": ("STRING", {"default": ""}), - "sub_app_id": ("INT", {"default": 0}), + "sub_app_id": ("STRING", {"default": ""}), } } @@ -342,7 +342,7 @@ class VodToLocalNode: try: req = models.DescribeMediaInfosRequest() req.FileIds = [file_id] - req.SubAppId = sub_app_id + req.SubAppId = int(sub_app_id) resp = self.vod_client.DescribeMediaInfos(req) if not resp.MediaInfoSet: @@ -356,6 +356,14 @@ class VodToLocalNode: except Exception as e: raise RuntimeError(f"Tencent API error: {e}") + def create_directory(self, path): + p = Path(path) + if not p.exists(): + p.mkdir(parents=True, exist_ok=True) # parents=True会自动创建所有必需的父目录,exist_ok=True表示如果目录已存在则不会引发异常 + print(f"目录已创建: {path}") + else: + print(f"目录已存在: {path}") + def download_vod(self, file_id, sub_app_id): """ 需要补充腾讯云VOD SDK调用逻辑 @@ -363,7 +371,8 @@ class VodToLocalNode: """ media_url = self._get_download_url(file_id=file_id, sub_app_id=sub_app_id) # 生成一个临时目录路径名并创建该目录 - output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "download", f"{file_id}.mp4" ) + self.create_directory(os.path.join(os.path.dirname(os.path.abspath(__file__)), "download", f"{sub_app_id}")) + 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, output_dir=output_dir, file_id=file_id, timeout=60 * 10) def _download_file(self, url, output_dir, file_id, timeout=30): @@ -393,7 +402,8 @@ NODE_CLASS_MAPPINGS = { "FaceExtract": FaceExtract, "COSUpload": COSUpload, "COSDownload": COSDownload, - "VideoCutCustom": VideoCut + "VideoCutCustom": VideoCut, + "VodToLocal": VodToLocalNode } # A dictionary that contains the friendly/humanly readable titles for the nodes @@ -402,5 +412,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "FaceExtract": "面部提取", "COSUpload": "COS上传", "COSDownload": "COS下载", - "VideoCutCustom": "视频剪裁" + "VideoCutCustom": "视频剪裁", + "VodToLocal": "腾讯云VOD下载" } +