Browse Source

Fix bot updating tracks when not equal

Toni Fadjukoff 6 years ago
parent
commit
fecdefaa73
1 changed files with 5 additions and 5 deletions
  1. 5 5
      bot.go

+ 5 - 5
bot.go View File

322
 				} else if token.Expiry.Before(time.Now()) {
322
 				} else if token.Expiry.Before(time.Now()) {
323
 					log.Println("Token has expired")
323
 					log.Println("Token has expired")
324
 				} else {
324
 				} else {
325
-					playlistId, tracks := findPlaylist(changedWikiText)
325
+					playlistID, tracks := findPlaylist(changedWikiText)
326
 					currentTracks, err := app.db.FindPlaylistBySection(section.title)
326
 					currentTracks, err := app.db.FindPlaylistBySection(section.title)
327
 					if err != nil {
327
 					if err != nil {
328
 						log.Println("Failed to find tracks from DB", err)
328
 						log.Println("Failed to find tracks from DB", err)
329
 					}
329
 					}
330
 					log.Println("Checking if playlist needs updating", currentTracks, tracks)
330
 					log.Println("Checking if playlist needs updating", currentTracks, tracks)
331
-					if len(tracks) > 0 && (err != nil || reflect.DeepEqual(currentTracks, tracks)) {
331
+					if len(tracks) > 0 && (err != nil || !reflect.DeepEqual(currentTracks, tracks)) {
332
 
332
 
333
-						if playlistId == "" {
333
+						if playlistID == "" {
334
 
334
 
335
 							info, err := app.spotify.client.CreatePlaylistForUser(app.credentials.SpotifyUser, title+" "+section.title, true)
335
 							info, err := app.spotify.client.CreatePlaylistForUser(app.credentials.SpotifyUser, title+" "+section.title, true)
336
 							if err != nil {
336
 							if err != nil {
337
 								log.Println("Error creating playlist to Spotify")
337
 								log.Println("Error creating playlist to Spotify")
338
 								return err
338
 								return err
339
 							}
339
 							}
340
-							playlistId = info.ID
340
+							playlistID = info.ID
341
 							changedWikiText = appendPlaylist(changedWikiText, info)
341
 							changedWikiText = appendPlaylist(changedWikiText, info)
342
 							message = message + fmt.Sprintf("Added link to Spotify playlist for week %d.", weekNumber)
342
 							message = message + fmt.Sprintf("Added link to Spotify playlist for week %d.", weekNumber)
343
 						}
343
 						}
344
-						err := app.spotify.client.ReplacePlaylistTracks(app.credentials.SpotifyUser, playlistId, tracks...)
344
+						err := app.spotify.client.ReplacePlaylistTracks(app.credentials.SpotifyUser, playlistID, tracks...)
345
 						if err != nil {
345
 						if err != nil {
346
 							log.Println("Error updating playlist to Spotify")
346
 							log.Println("Error updating playlist to Spotify")
347
 							return err
347
 							return err