diff --git a/downloader/download.go b/downloader/download.go index 8d34778..762c29c 100644 --- a/downloader/download.go +++ b/downloader/download.go @@ -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) } diff --git a/downloader/main.go b/downloader/main.go index f54b382..d13f204 100644 --- a/downloader/main.go +++ b/downloader/main.go @@ -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)