Limit download speed to not kill internet
This commit is contained in:
@@ -13,12 +13,12 @@ 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").
|
||||
LimitRate("5M").
|
||||
// HTTPChunkSize("20M").
|
||||
MarkWatched().
|
||||
SponsorblockMark("all").
|
||||
RecodeVideo("mp4").
|
||||
ConcurrentFragments(4)
|
||||
ConcurrentFragments(6)
|
||||
|
||||
// func Download(event PBEvent, status chan error) {
|
||||
// _, err := dl.Run(context.TODO(), event.Record.Link)
|
||||
@@ -40,4 +40,5 @@ func DownloadURL(url string, status chan error) {
|
||||
}
|
||||
|
||||
log.Printf("Downloaded %s", url)
|
||||
close(status)
|
||||
}
|
||||
|
@@ -43,13 +43,20 @@ func main() {
|
||||
ws.url = WEBSOCKET_SERVER
|
||||
ws.Open()
|
||||
|
||||
status := make(chan error, 16)
|
||||
sem := make(chan struct{}, 4)
|
||||
for {
|
||||
select {
|
||||
case event := <-ws.ReadChan:
|
||||
eventCopy := event
|
||||
log.Printf("New event: %+v", eventCopy)
|
||||
status := make(chan error)
|
||||
sem <- struct{}{}
|
||||
|
||||
log.Printf("New event: %+v; semaphore at: %d", eventCopy, len(sem))
|
||||
go func() {
|
||||
defer func() {
|
||||
<-sem
|
||||
log.Printf("Semaphore at: %d", len(sem))
|
||||
}()
|
||||
// Download(eventCopy, status)
|
||||
DownloadURL(eventCopy, status)
|
||||
// go DownloadNative(event, status)
|
||||
|
Reference in New Issue
Block a user