Browse Source

Fix comparison of tracks

Toni Fadjukoff 6 years ago
parent
commit
64d570bdf7
1 changed files with 14 additions and 1 deletions
  1. 14 1
      bot.go

+ 14 - 1
bot.go View File

281
 	return changedText
281
 	return changedText
282
 }
282
 }
283
 
283
 
284
+func tracksEqual(tracks1 []spotify.ID, tracks2 []string) bool {
285
+	if len(tracks1) != len(tracks2) {
286
+		return false
287
+	}
288
+	for i, track1 := range tracks1 {
289
+		track2 := tracks2[i]
290
+		if string(track1) != track2 {
291
+			return false
292
+		}
293
+	}
294
+	return true
295
+}
296
+
284
 func (app *App) AutomateSection(title string) error {
297
 func (app *App) AutomateSection(title string) error {
285
 	wiki := app.wikiClient()
298
 	wiki := app.wikiClient()
286
 
299
 
328
 						log.Println("Failed to find tracks from DB", err)
341
 						log.Println("Failed to find tracks from DB", err)
329
 					}
342
 					}
330
 					log.Println("Checking if playlist needs updating", currentTracks, tracks, err)
343
 					log.Println("Checking if playlist needs updating", currentTracks, tracks, err)
331
-					if len(tracks) > 0 && (err != nil || !reflect.DeepEqual(currentTracks, tracks)) {
344
+					if len(tracks) > 0 && (err != nil || !tracksEqual(currentTracks, tracks)) {
332
 
345
 
333
 						if playlistID == "" {
346
 						if playlistID == "" {
334
 							log.Println("Creating new playlist")
347
 							log.Println("Creating new playlist")