fix nilptr

This commit is contained in:
Niko Storni 2021-06-18 01:23:25 +02:00
parent 768743a200
commit f17110ab7f
2 changed files with 14 additions and 9 deletions

View file

@ -755,6 +755,7 @@ func (s *Sync) startWorker(workerNum int) {
"Missing inputs", "Missing inputs",
} }
errorsNoRetry := []string{ errorsNoRetry := []string{
"Requested format is not available",
"non 200 status code received", "non 200 status code received",
"This video contains content from", "This video contains content from",
"dont know which claim to update", "dont know which claim to update",

View file

@ -374,6 +374,7 @@ func (v *YoutubeVideo) download() error {
videoSize := 0 videoSize := 0
audioSize := 0 audioSize := 0
if metadata != nil {
for _, f := range metadata.Formats { for _, f := range metadata.Formats {
if f.FormatID == videoFormat { if f.FormatID == videoFormat {
videoSize = f.Filesize videoSize = f.Filesize
@ -382,6 +383,8 @@ func (v *YoutubeVideo) download() error {
audioSize = f.Filesize audioSize = f.Filesize
} }
} }
}
log.Debugf("(%s) - videoSize: %d (%s), audiosize: %d (%s)", v.id, videoSize, videoFormat, audioSize, audioFormat) log.Debugf("(%s) - videoSize: %d (%s), audiosize: %d (%s)", v.id, videoSize, videoFormat, audioSize, audioFormat)
bar := v.progressBars.AddBar(int64(videoSize+audioSize), bar := v.progressBars.AddBar(int64(videoSize+audioSize),
mpb.PrependDecorators( mpb.PrependDecorators(
@ -402,12 +405,13 @@ func (v *YoutubeVideo) download() error {
), ),
mpb.BarRemoveOnComplete(), mpb.BarRemoveOnComplete(),
) )
defer func() {
bar.Completed()
bar.Abort(true)
}()
for { for {
select { select {
case <-done: case <-done:
bar.Completed()
bar.Abort(true)
return return
case <-ticker.C: case <-ticker.C:
size, err := logUtils.DirSize(v.videoDir()) size, err := logUtils.DirSize(v.videoDir())