feat: getTitle concurrntly

This commit is contained in:
HeshamTB 2023-09-22 02:08:35 +03:00
parent 937108dba8
commit 8b9cebe45b

View File

@ -89,6 +89,8 @@ func createDownloadCtx(link string) *DownloadCtx {
func startJob(ctx *DownloadCtx, downloadCtxs chan *DownloadCtx) {
c := make(chan int)
go func(c chan int) {
getTitle(ctx)
if ctx.err != nil {
@ -96,9 +98,12 @@ func startJob(ctx *DownloadCtx, downloadCtxs chan *DownloadCtx) {
return
}
ctx.tracker.UpdateMessage(ctx.title)
c <- 0
}(c)
ytdlpDownload(ctx, downloadCtxs)
<- c // Ensure to return only after
downloadCtxs <- ctx
}