|
@@ -78,9 +78,11 @@ func CreateVideo(report *models.Report) (err error) {
|
|
|
|
|
|
saveName := utils.GetRandStringNoSpecialChar(16) + ".mp3"
|
|
saveName := utils.GetRandStringNoSpecialChar(16) + ".mp3"
|
|
savePath := "./" + saveName
|
|
savePath := "./" + saveName
|
|
-
|
|
+ defer func() {
|
|
-
|
|
+ if utils.FileIsExist(savePath) {
|
|
-
|
|
+ os.Remove(savePath)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
|
|
|
|
|
|
videoContent = strings.TrimSpace(videoContent)
|
|
videoContent = strings.TrimSpace(videoContent)
|
|
@@ -106,20 +108,6 @@ func CreateVideo(report *models.Report) (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
uploadUrl := ``
|
|
uploadUrl := ``
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
ossClient := NewOssClient()
|
|
ossClient := NewOssClient()
|
|
if ossClient == nil {
|
|
if ossClient == nil {
|
|
err = fmt.Errorf("初始化OSS服务失败")
|
|
err = fmt.Errorf("初始化OSS服务失败")
|
|
@@ -145,12 +133,9 @@ func CreateVideo(report *models.Report) (err error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if playSeconds > 0 {
|
|
+
|
|
- if utils.FileIsExist(savePath) {
|
|
|
|
- os.Remove(savePath)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
err = models.ModifyReportVideo(report.Id, uploadUrl, videoName, sizeStr, playSeconds)
|
|
err = models.ModifyReportVideo(report.Id, uploadUrl, videoName, sizeStr, playSeconds)
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -242,6 +227,7 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
|
|
|
|
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
+
|
|
|
|
|
|
reportContent = strings.TrimSpace(reportContent)
|
|
reportContent = strings.TrimSpace(reportContent)
|
|
if reportContent == `` {
|
|
if reportContent == `` {
|
|
@@ -297,11 +283,19 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
|
|
param.Data.Status = 2
|
|
param.Data.Status = 2
|
|
videoContent := doc.Text()
|
|
videoContent := doc.Text()
|
|
|
|
|
|
|
|
+
|
|
|
|
+ videoContent = strings.TrimSpace(videoContent)
|
|
|
|
+ if videoContent == `` {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
saveName := utils.GetRandStringNoSpecialChar(16) + ".mp3"
|
|
saveName := utils.GetRandStringNoSpecialChar(16) + ".mp3"
|
|
savePath := "./" + saveName
|
|
savePath := "./" + saveName
|
|
-
|
|
+ defer func() {
|
|
-
|
|
+ if utils.FileIsExist(savePath) {
|
|
-
|
|
+ os.Remove(savePath)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
contentArr := GetChineseCount(videoContent)
|
|
contentArr := GetChineseCount(videoContent)
|
|
for _, v := range contentArr {
|
|
for _, v := range contentArr {
|
|
newText := v
|
|
newText := v
|
|
@@ -358,11 +352,5 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if playSeconds > 0 {
|
|
|
|
- if utils.FileIsExist(savePath) {
|
|
|
|
- os.Remove(savePath)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|