fix: 添加到导出目录
This commit is contained in:
parent
711fef9fa4
commit
919a40893e
22
__init__.py
22
__init__.py
|
|
@ -323,7 +323,7 @@ class VodToLocalNode:
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"file_id": ("STRING", {"default": ""}),
|
"file_id": ("STRING", {"default": ""}),
|
||||||
"sub_app_id": ("INT", {"default": 0}),
|
"sub_app_id": ("STRING", {"default": ""}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -342,7 +342,7 @@ class VodToLocalNode:
|
||||||
try:
|
try:
|
||||||
req = models.DescribeMediaInfosRequest()
|
req = models.DescribeMediaInfosRequest()
|
||||||
req.FileIds = [file_id]
|
req.FileIds = [file_id]
|
||||||
req.SubAppId = sub_app_id
|
req.SubAppId = int(sub_app_id)
|
||||||
|
|
||||||
resp = self.vod_client.DescribeMediaInfos(req)
|
resp = self.vod_client.DescribeMediaInfos(req)
|
||||||
if not resp.MediaInfoSet:
|
if not resp.MediaInfoSet:
|
||||||
|
|
@ -356,6 +356,14 @@ class VodToLocalNode:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError(f"Tencent API error: {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):
|
def download_vod(self, file_id, sub_app_id):
|
||||||
"""
|
"""
|
||||||
需要补充腾讯云VOD SDK调用逻辑
|
需要补充腾讯云VOD SDK调用逻辑
|
||||||
|
|
@ -363,7 +371,8 @@ class VodToLocalNode:
|
||||||
"""
|
"""
|
||||||
media_url = self._get_download_url(file_id=file_id, sub_app_id=sub_app_id)
|
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)
|
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):
|
def _download_file(self, url, output_dir, file_id, timeout=30):
|
||||||
|
|
@ -393,7 +402,8 @@ NODE_CLASS_MAPPINGS = {
|
||||||
"FaceExtract": FaceExtract,
|
"FaceExtract": FaceExtract,
|
||||||
"COSUpload": COSUpload,
|
"COSUpload": COSUpload,
|
||||||
"COSDownload": COSDownload,
|
"COSDownload": COSDownload,
|
||||||
"VideoCutCustom": VideoCut
|
"VideoCutCustom": VideoCut,
|
||||||
|
"VodToLocal": VodToLocalNode
|
||||||
}
|
}
|
||||||
|
|
||||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||||
|
|
@ -402,5 +412,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"FaceExtract": "面部提取",
|
"FaceExtract": "面部提取",
|
||||||
"COSUpload": "COS上传",
|
"COSUpload": "COS上传",
|
||||||
"COSDownload": "COS下载",
|
"COSDownload": "COS下载",
|
||||||
"VideoCutCustom": "视频剪裁"
|
"VideoCutCustom": "视频剪裁",
|
||||||
|
"VodToLocal": "腾讯云VOD下载"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue