diff --git a/cmd/selfsync.go b/cmd/selfsync.go index 95b3226..4e46a82 100644 --- a/cmd/selfsync.go +++ b/cmd/selfsync.go @@ -27,8 +27,8 @@ var APIToken string func init() { var selfSyncCmd = &cobra.Command{ - Use: "selfsync ", - Args: cobra.RangeArgs(1, 1), + Use: "selfsync", + Args: cobra.RangeArgs(0, 0), Short: "Publish youtube channels into LBRY network automatically.", Run: selfSync, } @@ -165,7 +165,7 @@ func selfSync(cmd *cobra.Command, args []string) { util.SendErrorToSlack(err.Error()) return } - ytAPIKey := args[0] + ytAPIKey := os.Getenv("YOUTUBE_API_KEY") //authToken := args[1] if !util.InSlice(syncStatus, SyncStatuses) { @@ -303,15 +303,17 @@ func syncChannels(channelsToSync []APIYoutubeChannel, ytAPIKey string, syncCount "NotEnoughFunds", "no space left on device", } + //mark video as failed + err2 := setChannelSyncStatus(channelID, StatusFailed) + if err2 != nil { + msg := fmt.Sprintf("Failed setting failed state for channel %s.", lbryChannelName) + err2 = errors.Prefix(msg, err2) + util.SendErrorToSlack(err2.Error()) + } if util.InSliceContains(err.Error(), fatalErrors) { return true, errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err) } - //mark video as failed - err := setChannelSyncStatus(channelID, StatusFailed) - if err != nil { - msg := fmt.Sprintf("Failed setting failed state for channel %s. \n@Nikooo777 this requires manual intervention! Exiting...", lbryChannelName) - return s.IsInterrupted(), errors.Prefix(msg, err) - } + continue } if s.IsInterrupted() { diff --git a/util/slack.go b/util/slack.go index c94f6eb..66bd54d 100644 --- a/util/slack.go +++ b/util/slack.go @@ -49,14 +49,20 @@ func SendToSlack(message string) error { // SendErrorToSlack Sends an error message to the default channel and to the process log. func SendErrorToSlack(format string, a ...interface{}) error { - message := fmt.Sprintf(format, a...) + message := format + if len(a) > 0 { + message = fmt.Sprintf(format, a...) + } log.Errorln(message) return sendToSlack(defaultChannel, defaultUsername, ":sos: "+message) } // SendInfoToSlack Sends an info message to the default channel and to the process log. func SendInfoToSlack(format string, a ...interface{}) error { - message := fmt.Sprintf(format, a...) + message := format + if len(a) > 0 { + message = fmt.Sprintf(format, a...) + } log.Debugln(message) return sendToSlack(defaultChannel, defaultUsername, ":information_source: "+message) } diff --git a/ytsync/sources/youtubeVideo.go b/ytsync/sources/youtubeVideo.go index 8e2cc71..66788c6 100644 --- a/ytsync/sources/youtubeVideo.go +++ b/ytsync/sources/youtubeVideo.go @@ -214,7 +214,7 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f if fi.Size() > 2*1024*1024*1024 { //delete the video and ignore the error _ = v.delete() - return errors.Err("video is bigger than 1GB, skipping for now") + return errors.Err("video is bigger than 2GB, skipping for now") } err = v.triggerThumbnailSave() diff --git a/ytsync/ytsync.go b/ytsync/ytsync.go index fdba779..a554288 100644 --- a/ytsync/ytsync.go +++ b/ytsync/ytsync.go @@ -159,7 +159,7 @@ func (s *Sync) FullCycle() error { log.Infoln("Waiting for daemon to finish starting...") s.daemon = jsonrpc.NewClient("") - s.daemon.SetRPCTimeout(20 * time.Minute) + s.daemon.SetRPCTimeout(40 * time.Minute) WaitForDaemonStart: for { @@ -257,6 +257,7 @@ func (s *Sync) startWorker(workerNum int) { ":5279: read: connection reset by peer", "no space left on device", "NotEnoughFunds", + "Cannot publish using channel", } if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError { s.grp.Stop() @@ -271,15 +272,15 @@ 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 1GB, skipping for now", + "video is bigger than 2GB, skipping for now", } if util.InSliceContains(err.Error(), errorsNoRetry) { log.Println("This error should not be retried at all") } else if tryCount < s.MaxTries { - if strings.Contains(err.Error(), "258: txn-mempool-conflict") || + if strings.Contains(err.Error(), "txn-mempool-conflict") || strings.Contains(err.Error(), "failed: Not enough funds") || strings.Contains(err.Error(), "Error in daemon: Insufficient funds, please deposit additional LBC") || - strings.Contains(err.Error(), "64: too-long-mempool-chain") { + strings.Contains(err.Error(), "too-long-mempool-chain") { log.Println("waiting for a block and refilling addresses before retrying") err = s.walletSetup() if err != nil {