feat: update

This commit is contained in:
yanghao05
2025-04-22 14:45:04 +08:00
parent fb8c9a68a4
commit b1f090918d
19 changed files with 43 additions and 35 deletions

View File

@@ -23,7 +23,7 @@ import (
var _ contracts.JobArgs = (*VideoExtractHeadImage)(nil)
type VideoExtractHeadImage struct {
MediaID int64 `json:"media_id"`
MediaHash string `json:"media_hash"`
}
func (s VideoExtractHeadImage) InsertOpts() InsertOpts {
@@ -57,7 +57,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
log.Infof("[Start] Working on job with strings: %+v", job.Args)
defer log.Infof("[End] Finished %s", job.Args.Kind())
media, err := models.Medias.GetByID(ctx, job.Args.MediaID)
media, err := models.Medias.GetByHash(ctx, job.Args.MediaHash)
if err != nil {
log.Errorf("Error getting media by ID: %v", err)
return JobCancel(err)
@@ -90,6 +90,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
log.Errorf("Error getting file MD5: %v", err)
return JobCancel(err)
}
filename := fileMd5 + filepath.Ext(output)
// create a new media record for the image
imageMedia := &model.Medias{
@@ -97,7 +98,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
Name: "[展示图]" + media.Name,
MimeType: "image/jpeg",
Size: fileSize,
Path: w.oss.GetSavePath(filepath.Base(output)),
Path: w.oss.GetSavePath(filename),
Hash: fileMd5,
Metas: fields.Json[fields.MediaMetas]{},
}