From 041c0cf056c1f3a00b6ee5d66d07fefc353111f8 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Mon, 3 Sep 2018 17:38:16 -0400 Subject: [PATCH] improve/fix duplicates detection --- ytsync/ytsync.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ytsync/ytsync.go b/ytsync/ytsync.go index e2ba666..9048a60 100644 --- a/ytsync/ytsync.go +++ b/ytsync/ytsync.go @@ -366,19 +366,21 @@ func logShutdownError(shutdownErr error) { } func hasDupes(claims []jsonrpc.Claim) (bool, error) { - videoIDs := make(map[string]interface{}) + videoIDs := make(map[string]string) for _, c := range claims { if !util.InSlice(c.Category, []string{"claim", "update"}) || c.Value.Stream == nil { continue } if c.Value.Stream.Metadata == nil || c.Value.Stream.Metadata.Thumbnail == nil { - return false, errors.Err("something is wrong with the this claim: %s", c.ClaimID) + return false, errors.Err("something is wrong with this claim: %s", c.ClaimID) } tn := *c.Value.Stream.Metadata.Thumbnail - videoID := tn[:strings.LastIndex(tn, "/")+1] - _, ok := videoIDs[videoID] - if !ok { - videoIDs[videoID] = nil + videoID := tn[strings.LastIndex(tn, "/")+1:] + + log.Infof("claimid: %s, claimName: %s, videoID: %s", c.ClaimID, c.Name, videoID) + cID, ok := videoIDs[videoID] + if !ok || cID == c.ClaimID { + videoIDs[videoID] = c.ClaimID continue } return true, nil @@ -425,6 +427,7 @@ func (s *Sync) doSync() error { } } if pubsOnWallet > pubsOnDB { + SendInfoToSlack("We're claiming to have published %d videos but in reality we published %d (%s)", pubsOnDB, pubsOnWallet, s.YoutubeChannelID) return errors.Err("not all published videos are in the database") } if pubsOnWallet < pubsOnDB {