Sfoglia il codice sorgente

Fix comparison of tracks

Toni Fadjukoff 6 anni fa
parent
commit
64d570bdf7
1 ha cambiato i file con 14 aggiunte e 1 eliminazioni
  1. 14 1
      bot.go

+ 14 - 1
bot.go Vedi File

@@ -281,6 +281,19 @@ func appendPlaylist(wikiText string, playlist *spotify.FullPlaylist) string {
281 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 297
 func (app *App) AutomateSection(title string) error {
285 298
 	wiki := app.wikiClient()
286 299
 
@@ -328,7 +341,7 @@ func (app *App) AutomateSection(title string) error {
328 341
 						log.Println("Failed to find tracks from DB", err)
329 342
 					}
330 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 346
 						if playlistID == "" {
334 347
 							log.Println("Creating new playlist")