Init
This commit is contained in:
parent
264c97183e
commit
3faede7b1c
74 changed files with 6228 additions and 1 deletions
7
plugins/main.go
Normal file
7
plugins/main.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package plugins
|
||||
|
||||
import "govd/models"
|
||||
|
||||
var List = []models.Plugin{
|
||||
MergeAudio,
|
||||
}
|
40
plugins/merge_audio.go
Normal file
40
plugins/merge_audio.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue