This commit is contained in:
stefanodvx 2025-04-14 13:05:43 +02:00
parent 264c97183e
commit 3faede7b1c
74 changed files with 6228 additions and 1 deletions

7
plugins/main.go Normal file
View file

@ -0,0 +1,7 @@
package plugins
import "govd/models"
var List = []models.Plugin{
MergeAudio,
}

40
plugins/merge_audio.go Normal file
View file

@ -0,0 +1,40 @@
package plugins
import (
"context"
"fmt"
"govd/models"
"govd/util"
"govd/util/av"
"github.com/pkg/errors"
)
func MergeAudio(media *models.DownloadedMedia) error {
audioFormat := media.Media.GetDefaultAudioFormat()
if audioFormat == nil {
return errors.New("no audio format found")
}
// download the audio file
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
audioFile, err := util.DownloadFile(
ctx, audioFormat.URL,
audioFormat.GetFileName(), nil,
)
if err != nil {
return fmt.Errorf("failed to download audio file: %w", err)
}
err = av.MergeVideoWithAudio(
media.FilePath,
audioFile,
)
if err != nil {
return fmt.Errorf("failed to merge video with audio: %w", err)
}
return nil
}