slight dl-only PoC
This commit is contained in:
29
app/ytdlp.go
Normal file
29
app/ytdlp.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
"fmt"
|
||||
"context"
|
||||
"github.com/lrstanley/go-ytdlp"
|
||||
)
|
||||
func downloadVideo(out_dir, url string) {
|
||||
dl := ytdlp.New().
|
||||
SetWorkDir(out_dir).
|
||||
FormatSort("res,ext:mp4:m4a").
|
||||
RecodeVideo("mp4").
|
||||
ProgressFunc(100*time.Millisecond, func(prog ytdlp.ProgressUpdate) {
|
||||
fmt.Printf(
|
||||
"%s @ %s [eta: %s] :: %s\n",
|
||||
prog.Status,
|
||||
prog.PercentString(),
|
||||
prog.ETA(),
|
||||
prog.Filename,
|
||||
)
|
||||
}).
|
||||
Output("%(extractor)s - %(title)s.%(ext)s")
|
||||
|
||||
_, err := dl.Run(context.TODO(), url)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user