feat: update
This commit is contained in:
@@ -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]{},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user