Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
768743a200 | ||
|
|
7c652b22a1 | ||
|
|
a0fb4e579e |
No files matched your search
@@ -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",
|
||||
|
||||
+10
-7
@@ -55,6 +55,9 @@ type Sync struct {
|
||||
queue chan ytapi.Video
|
||||
defaultAccountID string
|
||||
hardVideoFailure hardVideoFailure
|
||||
|
||||
progressBarWg *sync.WaitGroup
|
||||
progressBar *mpb.Progress
|
||||
}
|
||||
|
||||
type hardVideoFailure struct {
|
||||
@@ -129,7 +132,6 @@ func (s *Sync) FullCycle() (e error) {
|
||||
log.Println("Got interrupt signal, shutting down (if publishing, will shut down after current publish)")
|
||||
s.grp.Stop()
|
||||
time.Sleep(5 * time.Second)
|
||||
debug.PrintStack() // so we can figure out what's not stopping
|
||||
}()
|
||||
err := s.setStatusSyncing()
|
||||
if err != nil {
|
||||
@@ -177,7 +179,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 +821,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 +994,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
|
||||
}
|
||||
|
||||
+11
-6
@@ -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++ {
|
||||
@@ -339,7 +339,7 @@ func (v *YoutubeVideo) download() error {
|
||||
return errors.Err(err)
|
||||
}
|
||||
ticker := time.NewTicker(400 * time.Millisecond)
|
||||
done := make(chan bool)
|
||||
done := make(chan bool, 1)
|
||||
v.progressBarWg.Add(1)
|
||||
go func() {
|
||||
defer v.progressBarWg.Done()
|
||||
@@ -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(
|
||||
@@ -398,7 +395,12 @@ func (v *YoutubeVideo) download() error {
|
||||
decor.EwmaETA(decor.ET_STYLE_GO, 90),
|
||||
decor.Name(" ] "),
|
||||
decor.EwmaSpeed(decor.UnitKiB, "% .2f ", 60),
|
||||
decor.OnComplete(
|
||||
// ETA decorator with ewma age of 60
|
||||
decor.EwmaETA(decor.ET_STYLE_GO, 60), "done",
|
||||
),
|
||||
),
|
||||
mpb.BarRemoveOnComplete(),
|
||||
)
|
||||
|
||||
for {
|
||||
@@ -414,6 +416,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)
|
||||
}
|
||||
}
|
||||
@@ -737,7 +742,7 @@ func (v *YoutubeVideo) downloadAndPublish(daemon *jsonrpc.Client, params SyncPar
|
||||
break
|
||||
}
|
||||
|
||||
log.Debugln("Downloaded " + v.id)
|
||||
//log.Debugln("Downloaded " + v.id)
|
||||
ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancelFn()
|
||||
|
||||
|
||||
Reference in new issue
Block a user