44 lines
978 B
Go
44 lines
978 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/lrstanley/go-ytdlp"
|
|
)
|
|
|
|
const OUTPUT_DIR = "C:/Users/Administrator/ytdlpVideos"
|
|
|
|
var dl = ytdlp.New().
|
|
// FormatSort("bestvideo[ext=mp4]+bestaudio[ext=m4a]").
|
|
FormatSort("res,ext:mp4:m4a").
|
|
Output("C:/Users/Administrator/ytdlpVideos/%(uploader)s/%(title)s.%(ext)s").
|
|
LimitRate("50M").
|
|
// HTTPChunkSize("20M").
|
|
MarkWatched().
|
|
SponsorblockMark("all").
|
|
RecodeVideo("mp4").
|
|
ConcurrentFragments(4)
|
|
|
|
// func Download(event PBEvent, status chan error) {
|
|
// _, err := dl.Run(context.TODO(), event.Record.Link)
|
|
// if err != nil {
|
|
// status <- err
|
|
// return
|
|
// }
|
|
|
|
// log.Printf("Downloaded %s (%s)", event.Record.Id, event.Record.Link)
|
|
// SetDownloaded(event)
|
|
// }
|
|
|
|
func DownloadURL(url string, status chan error) {
|
|
log.Printf("Downloading %s", url)
|
|
_, err := dl.Run(context.TODO(), url)
|
|
if err != nil {
|
|
status <- err
|
|
return
|
|
}
|
|
|
|
log.Printf("Downloaded %s", url)
|
|
}
|