fix:批量导入图文增加图片

This commit is contained in:
cjy 2026-01-06 10:10:31 +08:00
parent 68ef35a746
commit 4c1eb8f3db

View File

@ -1347,28 +1347,32 @@ func ImportWorkBatch(ctx *gin.Context) {
}
// YouTube账号第F列row[5]
if len(row) > 5 && utils.CleanString(row[5]) != "" {
mediaInfoResp, err = service.CastProvider.MediaInfo(context.Background(), &cast.MediaInfoReq{
ArtistUuid: temp.ArtistUuid,
PlatformID: cast.PlatformIDENUM_YOUTUBE,
PlatformUserName: utils.CleanString(row[5]),
})
if err != nil || mediaInfoResp.Info.MediaAccountUuid == "" {
temp.Remark = fmt.Sprintf("YouTube账号名不存在")
zap.L().Error("CastProvider.MediaInfo", zap.Error(err))
req.ImageWorks = append(req.ImageWorks, temp)
continue
}
temp.PublishConfig1 = &cast.PublishConfig{
ForbidComment: 1,
PublicType: 1,
CanJoin: 1,
CanQuote: 1,
CanComment: 1,
IsAI: 1,
}
temp.PlatformIDs = append(temp.PlatformIDs, cast.PlatformIDENUM_YOUTUBE)
temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[5]))
temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
temp.Remark = fmt.Sprintf("Youtube不能发图文")
zap.L().Error("CastProvider.MediaInfo", zap.Error(err))
req.ImageWorks = append(req.ImageWorks, temp)
continue
// mediaInfoResp, err = service.CastProvider.MediaInfo(context.Background(), &cast.MediaInfoReq{
// ArtistUuid: temp.ArtistUuid,
// PlatformID: cast.PlatformIDENUM_YOUTUBE,
// PlatformUserName: utils.CleanString(row[5]),
// })
// if err != nil || mediaInfoResp.Info.MediaAccountUuid == "" {
// temp.Remark = fmt.Sprintf("YouTube账号名不存在")
// zap.L().Error("CastProvider.MediaInfo", zap.Error(err))
// req.ImageWorks = append(req.ImageWorks, temp)
// continue
// }
// temp.PublishConfig1 = &cast.PublishConfig{
// ForbidComment: 1,
// PublicType: 1,
// CanJoin: 1,
// CanQuote: 1,
// CanComment: 1,
// IsAI: 1,
// }
// temp.PlatformIDs = append(temp.PlatformIDs, cast.PlatformIDENUM_YOUTUBE)
// temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[5]))
// temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
}
// Bluesky账号第G列row[6]
if len(row) > 6 && utils.CleanString(row[6]) != "" {
@ -1425,6 +1429,12 @@ func ImportWorkBatch(ctx *gin.Context) {
req.ImageWorks = append(req.ImageWorks, temp)
continue
}
// 判断图片数量是否超过4
if len(temp.Images) > 4 {
temp.Remark = "Bluesky 图片数量不能超过4"
req.ImageWorks = append(req.ImageWorks, temp)
continue
}
req.ImageWorks = append(req.ImageWorks, temp)
}
if len(req.ImageWorks) == 0 {