|
@@ -248,7 +248,7 @@ func handleByPublishReport(item *models.Report) {
|
|
|
|
|
|
if item.HasChapter == 1 {
|
|
|
// 生产报告章节音频
|
|
|
- _ = UpdateChaptersVideoByReportId(item.Id)
|
|
|
+ _ = UpdateChaptersVideoByReportId(item)
|
|
|
} else {
|
|
|
// 生成音频
|
|
|
if item.VideoUrl == "" {
|
|
@@ -468,9 +468,11 @@ func ClearReportSaveLog(cont context.Context) (err error) {
|
|
|
// @Description: 更新报告章节音频
|
|
|
// @author: Roc
|
|
|
// @datetime 2024-06-28 13:52:56
|
|
|
-// @param reportId int
|
|
|
+// @param reportInfo *models.Report
|
|
|
// @return err error
|
|
|
-func UpdateChaptersVideoByReportId(reportId int) (err error) {
|
|
|
+func UpdateChaptersVideoByReportId(reportInfo *models.Report) (err error) {
|
|
|
+ reportId := reportInfo.Id
|
|
|
+
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
utils.FileLog.Error("UpdateChaptersVideo, reportId:%v, Err:%s", reportId, err.Error())
|
|
@@ -481,12 +483,18 @@ func UpdateChaptersVideoByReportId(reportId int) (err error) {
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ reportContent := ""
|
|
|
+
|
|
|
// 生成video
|
|
|
nowTime := time.Now()
|
|
|
updateCols := make([]string, 0)
|
|
|
updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds")
|
|
|
for i := 0; i < len(chapterList); i++ {
|
|
|
item := chapterList[i]
|
|
|
+ reportContent += item.Title + `。`
|
|
|
+ reportContent += item.Content + `。`
|
|
|
+
|
|
|
// 忽略已有音频的章节
|
|
|
if item.VideoUrl != "" && item.VideoName != "" && item.VideoSize != "" && item.VideoPlaySeconds != "" {
|
|
|
continue
|
|
@@ -505,6 +513,22 @@ func UpdateChaptersVideoByReportId(reportId int) (err error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 生成汇总音频
|
|
|
+ {
|
|
|
+ if reportInfo.VideoUrl != "" && reportInfo.VideoName != "" && reportInfo.VideoSize != "" && reportInfo.VideoPlaySeconds != "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ videoUrl, videoName, videoSize, videoPlaySeconds, e := CreateReportVideo(reportInfo.Title, html.UnescapeString(reportContent), time.Now().Format(utils.FormatDateTime))
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改报告的音频信息
|
|
|
+ err = models.ModifyReportVideoByNoVideo(reportInfo.Id, videoUrl, videoName, videoSize, videoPlaySeconds)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|