add slack logging
reduce claim name length (fees are too high) delete videos in case of failure too reduce synced videos to 1000 most recent
This commit is contained in:
parent
07004be3b4
commit
611dcbc3bc
2 changed files with 11 additions and 16 deletions
|
@ -63,7 +63,7 @@ func (v YoutubeVideo) getFilename() string {
|
|||
}
|
||||
|
||||
func (v YoutubeVideo) getClaimName() string {
|
||||
maxLen := 40
|
||||
maxLen := 30
|
||||
reg := regexp.MustCompile(`[^a-zA-Z0-9]+`)
|
||||
|
||||
chunks := strings.Split(strings.ToLower(strings.Trim(reg.ReplaceAllString(v.title, "-"), "-")), "-")
|
||||
|
@ -209,16 +209,15 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f
|
|||
log.Debugln("Created thumbnail for " + v.id)
|
||||
|
||||
err = v.publish(daemon, claimAddress, amount, channelName)
|
||||
if err != nil {
|
||||
return errors.Prefix("publish error", err)
|
||||
}
|
||||
|
||||
err = v.delete()
|
||||
if err != nil {
|
||||
//delete the video in all cases
|
||||
if v.delete() != nil {
|
||||
// the video was published anyway so it should be marked as published
|
||||
// for that to happen, no errors should be returned any further than here
|
||||
log.Debugln(errors.Prefix("delete error", err))
|
||||
}
|
||||
if err != nil {
|
||||
return errors.Prefix("publish error", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
14
ytsync.go
14
ytsync.go
|
@ -177,11 +177,8 @@ WaitForDaemonStart:
|
|||
return nil
|
||||
}
|
||||
func logShutdownError(shutdownErr error) {
|
||||
errMsg := fmt.Sprintf("error shutting down daemon: %v", shutdownErr)
|
||||
log.Errorf(errMsg)
|
||||
util.SendToSlack(errMsg)
|
||||
log.Errorf("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
|
||||
util.SendToSlack("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
|
||||
util.SendToSlackError("error shutting down daemon: %v", shutdownErr)
|
||||
util.SendToSlackError("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
|
||||
}
|
||||
|
||||
func (s *Sync) doSync() error {
|
||||
|
@ -276,9 +273,7 @@ func (s *Sync) startWorker(workerNum int) {
|
|||
log.Println("Retrying")
|
||||
continue
|
||||
}
|
||||
logMsg = fmt.Sprintf("Video failed after %d retries, skipping. Stack: %s", s.MaxTries, logMsg)
|
||||
log.Printf(logMsg)
|
||||
util.SendToSlack(logMsg)
|
||||
util.SendToSlackInfo("Video failed after %d retries, skipping. Stack: %s", s.MaxTries, logMsg)
|
||||
}
|
||||
}
|
||||
break
|
||||
|
@ -334,6 +329,7 @@ func (s *Sync) enqueueYoutubeVideos() error {
|
|||
|
||||
for _, item := range playlistResponse.Items {
|
||||
// todo: there's thumbnail info here. why did we need lambda???
|
||||
// because when videos are taken down from youtube, the thumb is gone too
|
||||
|
||||
// normally we'd send the video into the channel here, but youtube api doesn't have sorting
|
||||
// so we have to get ALL the videos, then sort them, then send them in
|
||||
|
@ -445,7 +441,7 @@ func (s *Sync) processVideo(v video) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
if v.PlaylistPosition() > 3000 {
|
||||
if v.PlaylistPosition() > 1000 {
|
||||
log.Println(v.ID() + " is old: skipping")
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue