From 8a871e2b87d81bf7182fa74cab0bec920f478cb3 Mon Sep 17 00:00:00 2001 From: byBlurr Date: Sat, 13 Feb 2021 13:21:04 +0000 Subject: [PATCH] Refactor Async methods --- SpotifyShuffle/Program.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SpotifyShuffle/Program.cs b/SpotifyShuffle/Program.cs index ad5cbdc..7d0e807 100644 --- a/SpotifyShuffle/Program.cs +++ b/SpotifyShuffle/Program.cs @@ -98,7 +98,7 @@ private async Task OnImplicitGrantReceivedAsync(object sender, ImplictGrantRespo int remainder = (int)playlists.Items[playlistId].Tracks.Total % 100; // get all the tracks from the playlist and populate the lists - await GetAllTracks(playlistUri, allTracks, loops); + await GetAllTracksAsync(playlistUri, allTracks, loops); PopulateSongLists(allTracks, songs, songsToRemove); // recalculate the loops and remainder of the playlist, some of the tracks may have been invalid @@ -111,13 +111,13 @@ private async Task OnImplicitGrantReceivedAsync(object sender, ImplictGrantRespo if (shuffled.Count != songsToRemove.Count) throw new Exception($"For some reason there are not the same amount of songs in each list... Shuffled: {shuffled.Count}, Original: {songsToRemove.Count}"); // remove the tracks from the playlist and then add the shuffled list back - await RemoveSongsFromPlaylist(playlistUri, songsToRemove, loops); + await RemoveSongsFromPlaylistAsync(playlistUri, songsToRemove, loops); await Task.Delay(100); - await AddSongsToPlaylist(playlistUri, shuffled, loops); + await AddSongsToPlaylistAsync(playlistUri, shuffled, loops); await Task.Delay(100); // shuffle local tracks - await ReorderSongs(playlistUri); + await ReorderSongsAsync(playlistUri); Log(LogType.Success, "Shuffle", "Playlist shuffle complete."); } @@ -195,7 +195,7 @@ private async Task OnImplicitGrantReceivedAsync(object sender, ImplictGrantRespo /// Playlist to retreive the songs from /// List to add the songs to /// How many loops are needed to complete the task - private async Task GetAllTracks(string playlistUri, List> allTracks, int loops) + private async Task GetAllTracksAsync(string playlistUri, List> allTracks, int loops) { Log(LogType.Info, "Shuffle", "Gathering tracks from playlist..."); for (int i = 0; i <= loops; i++) @@ -304,7 +304,7 @@ private List Shuffle(List songs) /// The playlist to remove from /// The songs to remove /// How many loops of 100 this will take - private async Task RemoveSongsFromPlaylist(string playlistUri, List songsToRemove, int loops) + private async Task RemoveSongsFromPlaylistAsync(string playlistUri, List songsToRemove, int loops) { Log(LogType.Info, "Shuffle", "Removing songs from playlist..."); for (int i = 0; i <= loops; i++) @@ -343,7 +343,7 @@ private async Task RemoveSongsFromPlaylist(string playlistUri, List songsT /// The playlist to add the songs to /// The songs to add /// How many loops of 100 this will take - private async Task AddSongsToPlaylist(string playlistUri, List songsToAdd, int loops) + private async Task AddSongsToPlaylistAsync(string playlistUri, List songsToAdd, int loops) { Log(LogType.Info, "Shuffle", "Adding songs back in shuffled order..."); for (int i = 0; i <= loops; i++) @@ -374,7 +374,7 @@ private async Task AddSongsToPlaylist(string playlistUri, List songsToAd /// Reorder the local songs, they should all be at the top of the playlist to begin with /// /// The playlist being shuffled - private async Task ReorderSongs(string playlistUri) + private async Task ReorderSongsAsync(string playlistUri) { Log(LogType.Info, "Shuffle", "Manually shuffling local songs..."); Random rnd = new Random();