private async void SyncScrobblesClick(object sender, RoutedEventArgs e) { var progress = await this.ShowProgressAsync("Syncing...", "Scrobbling selected tracks..."); var scrobbles = leftListView.SelectedItems.Cast <LastTrack>().ToList(); var newScrobbles = scrobbles.Where(o => o.TimePlayed != null && !GinaScrobbles.Any(p => p.TimePlayed == o.TimePlayed)); var list = newScrobbles.Select(o => new Scrobble(o.ArtistName, o.AlbumName, o.Name, o.TimePlayed.Value) { ChosenByUser = true, Duration = o.Duration }).ToList(); var scrobbler = new Scrobbler(client.Auth); var res = await scrobbler.ScrobbleAsync(list); await progress.CloseAsync(); await this.ShowMessageAsync("Syncing finished!", $"Synced {list.Count} scrobbles."); ReloadScrobbles(); }
public async Task <bool> Sync(LastTrack[] scrobbles) { var progress = new ProgressAlert("Syncing scrobbles", "Please wait...", Context); progress.Show(); if (!client.Auth.Authenticated) { progress.Hide(); return(false); } var newScrobbles = scrobbles.Where(o => o.TimePlayed != null && !GinaScrobbles.Any(p => p.TimePlayed == o.TimePlayed)); var list = newScrobbles.Select(o => new Scrobble(o.ArtistName, o.AlbumName, o.Name, o.TimePlayed.Value) { ChosenByUser = true, Duration = o.Duration }).ToList(); var scrobbler = new MemoryScrobbler(client.Auth); var res = await scrobbler.ScrobbleAsync(list); progress.Hide(); await Reload(); Toast.MakeText(Context, $"Synced {list.Count} scrobbles!", ToastLength.Long).Show(); return(true); }