Added some comments; Cleanup code
This commit is contained in:
10
download.go
10
download.go
@@ -76,11 +76,10 @@ func downloadVideo(destDir, url string, wg *sync.WaitGroup) {
|
||||
filenameRune := []rune(y.StreamList[0]["title"])
|
||||
shortFilename := string(filenameRune[0:20]) + "..."
|
||||
|
||||
//log.Println("Start downloading:", filename)
|
||||
go func() {
|
||||
bar := uiprogress.AddBar(100).AppendCompleted()
|
||||
|
||||
//Custom decorator
|
||||
//Custom decorator (the short name in front of the bar)
|
||||
bar.PrependFunc(func(b *uiprogress.Bar) string {
|
||||
return shortFilename
|
||||
})
|
||||
@@ -89,16 +88,13 @@ func downloadVideo(destDir, url string, wg *sync.WaitGroup) {
|
||||
for i < 100 {
|
||||
i = <-y.DownloadPercent
|
||||
bar.Set(int(i))
|
||||
if i%10 == 0 {
|
||||
//log.Println(i, "%", y.StreamList[0]["title"])
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
//start the actual download
|
||||
err := y.StartDownload(filename)
|
||||
if err != nil {
|
||||
log.Println("Failed to download", url)
|
||||
log.Println("Message:", err.Error())
|
||||
} else {
|
||||
//log.Println("Finished downloading:", filename)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user