fix progressbar
fix videos with leading dash
This commit is contained in:
parent
519e1e4648
commit
a0fb4e579e
3 changed files with 15 additions and 11 deletions
|
@ -50,7 +50,7 @@ func GetVideoInformation(config *sdk.APIConfig, videoID string, stopChan stop.Ch
|
|||
args := []string{
|
||||
"--skip-download",
|
||||
"--write-info-json",
|
||||
videoID,
|
||||
fmt.Sprintf("https://www.youtube.com/watch?v=%s", videoID),
|
||||
"--cookies",
|
||||
"cookies.txt",
|
||||
"-o",
|
||||
|
|
|
@ -55,6 +55,9 @@ type Sync struct {
|
|||
queue chan ytapi.Video
|
||||
defaultAccountID string
|
||||
hardVideoFailure hardVideoFailure
|
||||
|
||||
progressBarWg *sync.WaitGroup
|
||||
progressBar *mpb.Progress
|
||||
}
|
||||
|
||||
type hardVideoFailure struct {
|
||||
|
@ -177,7 +180,12 @@ func (s *Sync) FullCycle() (e error) {
|
|||
return err
|
||||
}
|
||||
|
||||
s.progressBarWg = &sync.WaitGroup{}
|
||||
s.progressBar = mpb.New(mpb.WithWaitGroup(s.progressBarWg))
|
||||
|
||||
err = s.doSync()
|
||||
// Waiting for passed &wg and for all bars to complete and flush
|
||||
s.progressBar.Wait()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -814,6 +822,7 @@ func (s *Sync) startWorker(workerNum int) {
|
|||
default:
|
||||
}
|
||||
tryCount++
|
||||
|
||||
err := s.processVideo(v)
|
||||
if err != nil {
|
||||
logUtils.SendErrorToSlack("error processing video %s: %s", v.ID(), err.Error())
|
||||
|
@ -986,13 +995,8 @@ func (s *Sync) processVideo(v ytapi.Video) (err error) {
|
|||
Fee: s.DbChannelData.Fee,
|
||||
DefaultAccount: da,
|
||||
}
|
||||
var pbWg sync.WaitGroup
|
||||
// passed &wg will be accounted at p.Wait() call
|
||||
p := mpb.New(mpb.WithWaitGroup(&pbWg))
|
||||
|
||||
summary, err := v.Sync(s.daemon, sp, &sv, videoRequiresUpgrade, s.walletMux, &pbWg, p)
|
||||
// Waiting for passed &wg and for all bars to complete and flush
|
||||
p.Wait()
|
||||
summary, err := v.Sync(s.daemon, sp, &sv, videoRequiresUpgrade, s.walletMux, s.progressBarWg, s.progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ func (v *YoutubeVideo) download() error {
|
|||
ytdlArgs = append(ytdlArgs,
|
||||
"--source-address",
|
||||
sourceAddress,
|
||||
v.ID(),
|
||||
fmt.Sprintf("https://www.youtube.com/watch?v=%s", v.id),
|
||||
)
|
||||
|
||||
for i := 0; i < len(qualities); i++ {
|
||||
|
@ -382,9 +382,6 @@ func (v *YoutubeVideo) download() error {
|
|||
audioSize = f.Filesize
|
||||
}
|
||||
}
|
||||
if audioSize+videoSize == 0 {
|
||||
videoSize = 50 * 1024 * 1024
|
||||
}
|
||||
log.Debugf("(%s) - videoSize: %d (%s), audiosize: %d (%s)", v.id, videoSize, videoFormat, audioSize, audioFormat)
|
||||
bar := v.progressBars.AddBar(int64(videoSize+audioSize),
|
||||
mpb.PrependDecorators(
|
||||
|
@ -414,6 +411,9 @@ func (v *YoutubeVideo) download() error {
|
|||
return
|
||||
}
|
||||
bar.SetCurrent(size)
|
||||
if size > int64(videoSize+audioSize) {
|
||||
bar.SetTotal(size+2048, false)
|
||||
}
|
||||
bar.DecoratorEwmaUpdate(400 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue