文生视频和图生视频功能完成

This commit is contained in:
GeekMaster
2025-07-23 19:11:30 +08:00
parent 54fe49de5d
commit a3f6a641aa
20 changed files with 640 additions and 610 deletions

View File

@@ -20,7 +20,7 @@ import (
)
// GenUploadPath 生成上传文件路径
func GenUploadPath(basePath, filename string, isImg bool) (string, error) {
func GenUploadPath(basePath, filename string, ext string) (string, error) {
now := time.Now()
dir := fmt.Sprintf("%s/%d/%d", basePath, now.Year(), now.Month())
_, err := os.Stat(dir)
@@ -30,13 +30,11 @@ func GenUploadPath(basePath, filename string, isImg bool) (string, error) {
return "", fmt.Errorf("error with create upload dir%v", err)
}
}
var fileExt string
if isImg {
fileExt = GetImgExt(filename)
} else {
fileExt = filepath.Ext(filename)
if ext == "" {
ext = filepath.Ext(filename)
}
return fmt.Sprintf("%s/%d%s", dir, now.UnixMicro(), fileExt), nil
return fmt.Sprintf("%s/%d%s", dir, now.UnixMicro(), ext), nil
}
// GenUploadUrl 生成上传文件 URL
@@ -80,14 +78,6 @@ func DownloadFile(fileURL string, filepath string, proxy string) error {
return nil
}
func GetImgExt(filename string) string {
ext := filepath.Ext(filename)
if ext == "" {
return ".png"
}
return ext
}
func ExtractImgURLs(text string) []string {
re := regexp.MustCompile(`(http[s]?:\/\/.*?\.(?:png|jpg|jpeg|gif))`)
matches := re.FindAllStringSubmatch(text, 10)