Skip to content

Commit

Permalink
fix nilptr
Browse files Browse the repository at this point in the history
  • Loading branch information
nikooo777 committed Jun 17, 2021
1 parent 768743a commit f17110a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions manager/ytsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ func (s *Sync) startWorker(workerNum int) {
"Missing inputs",
}
errorsNoRetry := []string{
"Requested format is not available",
"non 200 status code received",
"This video contains content from",
"dont know which claim to update",
Expand Down
22 changes: 13 additions & 9 deletions sources/youtubeVideo.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,17 @@ func (v *YoutubeVideo) download() error {

videoSize := 0
audioSize := 0
for _, f := range metadata.Formats {
if f.FormatID == videoFormat {
videoSize = f.Filesize
}
if f.FormatID == audioFormat {
audioSize = f.Filesize
if metadata != nil {
for _, f := range metadata.Formats {
if f.FormatID == videoFormat {
videoSize = f.Filesize
}
if f.FormatID == audioFormat {
audioSize = f.Filesize
}
}
}

log.Debugf("(%s) - videoSize: %d (%s), audiosize: %d (%s)", v.id, videoSize, videoFormat, audioSize, audioFormat)
bar := v.progressBars.AddBar(int64(videoSize+audioSize),
mpb.PrependDecorators(
Expand All @@ -402,12 +405,13 @@ func (v *YoutubeVideo) download() error {
),
mpb.BarRemoveOnComplete(),
)

defer func() {
bar.Completed()
bar.Abort(true)
}()
for {
select {
case <-done:
bar.Completed()
bar.Abort(true)
return
case <-ticker.C:
size, err := logUtils.DirSize(v.videoDir())
Expand Down

0 comments on commit f17110a

Please sign in to comment.