add more startup parameters

This commit is contained in:
Niko Storni 2018-08-01 08:56:04 -04:00
parent f688091775
commit e5017892d8
5 changed files with 14 additions and 13 deletions

View file

@ -37,6 +37,8 @@ type SyncManager struct {
ApiURL string
ApiToken string
BlobsDir string
VideosLimit int
MaxVideoSize int
}
const (

View file

@ -50,8 +50,8 @@ func (s *Sync) walletSetup() error {
}
log.Debugf("We already published %d videos", numPublished)
if float64(numOnSource)-float64(numPublished) > maximumVideosToPublish {
numOnSource = maximumVideosToPublish
if float64(numOnSource)-float64(numPublished) > float64(s.Manager.VideosLimit) {
numOnSource = uint64(s.Manager.VideosLimit)
}
minBalance := (float64(numOnSource)-float64(numPublished))*(publishAmount+0.1) + channelClaimAmount
if numPublished > numOnSource {

View file

@ -188,7 +188,7 @@ func (v ucbVideo) publish(daemon *jsonrpc.Client, claimAddress string, amount fl
return publishAndRetryExistingNames(daemon, v.title, v.getFilename(), amount, options)
}
func (v ucbVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
func (v ucbVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string, maxVideoSize int) (*SyncSummary, error) {
//download and thumbnail can be done in parallel
err := v.download()
if err != nil {

View file

@ -203,7 +203,7 @@ func (v YoutubeVideo) publish(daemon *jsonrpc.Client, claimAddress string, amoun
return publishAndRetryExistingNames(daemon, v.title, v.getFilename(), amount, options)
}
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string, maxVideoSize int) (*SyncSummary, error) {
//download and thumbnail can be done in parallel
err := v.download()
if err != nil {
@ -215,10 +215,10 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f
if err != nil {
return nil, err
}
if fi.Size() > 2*1024*1024*1024 {
if fi.Size() > int64(maxVideoSize)*1024*1024 {
//delete the video and ignore the error
_ = v.delete()
return nil, errors.Err("video is bigger than 2GB, skipping for now")
return nil, errors.Err("the video is too big to sync, skipping for now")
}
err = v.triggerThumbnailSave()

View file

@ -30,9 +30,8 @@ import (
)
const (
channelClaimAmount = 0.01
publishAmount = 0.01
maximumVideosToPublish = 1000
channelClaimAmount = 0.01
publishAmount = 0.01
)
type video interface {
@ -40,7 +39,7 @@ type video interface {
IDAndNum() string
PlaylistPosition() int
PublishedAt() time.Time
Sync(*jsonrpc.Client, string, float64, string) (*sources.SyncSummary, error)
Sync(*jsonrpc.Client, string, float64, string, int) (*sources.SyncSummary, error)
}
// sorting videos
@ -315,7 +314,7 @@ func (s *Sync) startWorker(workerNum int) {
"Error in daemon: Cannot publish empty file",
"Error extracting sts from embedded url response",
"Client.Timeout exceeded while awaiting headers)",
"video is bigger than 2GB, skipping for now",
"the video is too big to sync, skipping for now",
}
if util.SubstringInSlice(err.Error(), errorsNoRetry) {
log.Println("This error should not be retried at all")
@ -504,11 +503,11 @@ func (s *Sync) processVideo(v video) (err error) {
return nil
}
if v.PlaylistPosition() > maximumVideosToPublish {
if v.PlaylistPosition() > s.Manager.VideosLimit {
log.Println(v.ID() + " is old: skipping")
return nil
}
summary, err := v.Sync(s.daemon, s.claimAddress, publishAmount, s.LbryChannelName)
summary, err := v.Sync(s.daemon, s.claimAddress, publishAmount, s.LbryChannelName, s.Manager.MaxVideoSize)
if err != nil {
return err
}