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:
Niko Storni 2018-05-05 07:22:33 -04:00
parent 07004be3b4
commit 611dcbc3bc
2 changed files with 11 additions and 16 deletions

View file

@ -63,7 +63,7 @@ func (v YoutubeVideo) getFilename() string {
} }
func (v YoutubeVideo) getClaimName() string { func (v YoutubeVideo) getClaimName() string {
maxLen := 40 maxLen := 30
reg := regexp.MustCompile(`[^a-zA-Z0-9]+`) reg := regexp.MustCompile(`[^a-zA-Z0-9]+`)
chunks := strings.Split(strings.ToLower(strings.Trim(reg.ReplaceAllString(v.title, "-"), "-")), "-") 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) log.Debugln("Created thumbnail for " + v.id)
err = v.publish(daemon, claimAddress, amount, channelName) err = v.publish(daemon, claimAddress, amount, channelName)
if err != nil { //delete the video in all cases
return errors.Prefix("publish error", err) if v.delete() != nil {
}
err = v.delete()
if err != nil {
// the video was published anyway so it should be marked as published // 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 // for that to happen, no errors should be returned any further than here
log.Debugln(errors.Prefix("delete error", err)) log.Debugln(errors.Prefix("delete error", err))
} }
if err != nil {
return errors.Prefix("publish error", err)
}
return nil return nil
} }

View file

@ -177,11 +177,8 @@ WaitForDaemonStart:
return nil return nil
} }
func logShutdownError(shutdownErr error) { func logShutdownError(shutdownErr error) {
errMsg := fmt.Sprintf("error shutting down daemon: %v", shutdownErr) util.SendToSlackError("error shutting down daemon: %v", shutdownErr)
log.Errorf(errMsg) util.SendToSlackError("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
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")
} }
func (s *Sync) doSync() error { func (s *Sync) doSync() error {
@ -276,9 +273,7 @@ func (s *Sync) startWorker(workerNum int) {
log.Println("Retrying") log.Println("Retrying")
continue continue
} }
logMsg = fmt.Sprintf("Video failed after %d retries, skipping. Stack: %s", s.MaxTries, logMsg) util.SendToSlackInfo("Video failed after %d retries, skipping. Stack: %s", s.MaxTries, logMsg)
log.Printf(logMsg)
util.SendToSlack(logMsg)
} }
} }
break break
@ -334,6 +329,7 @@ func (s *Sync) enqueueYoutubeVideos() error {
for _, item := range playlistResponse.Items { for _, item := range playlistResponse.Items {
// todo: there's thumbnail info here. why did we need lambda??? // 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 // 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 // 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 return nil
} }
if v.PlaylistPosition() > 3000 { if v.PlaylistPosition() > 1000 {
log.Println(v.ID() + " is old: skipping") log.Println(v.ID() + " is old: skipping")
return nil return nil
} }