public async Task <IEnumerable <Term> > GetTermsAsync(string dataUrl, string asin, string tld, bool includeTopics, IProgressBar progress, CancellationToken cancellationToken = default) { try { var terms = await _roentgenClient.DownloadTermsAsync(asin, tld, cancellationToken); if (terms == null) { _logger.Log("No terms were available for this book :("); return(Enumerable.Empty <Term>()); } terms = terms.Where(term => term.Type == "character" || includeTopics).ToArray(); _logger.Log($"Successfully downloaded {terms.Length} terms from Roentgen!"); return(terms); } catch (Exception e) { _logger.Log($"Failed to download terms: {e.Message}"); return(Enumerable.Empty <Term>()); } }
private async Task DownloadTermsAsync(string asin) { try { var terms = await _roentgenClient.DownloadTermsAsync(asin, Settings.Default.roentgenRegion, CancellationToken.None); if (terms == null) { MessageBox.Show("No terms were available for this book :("); return; } _terms = terms.Where(term => term.Type == "character" || Settings.Default.includeTopics).ToList(); var trueCount = _terms.Count; ReloadTerms(); MessageBox.Show($"Successfully downloaded {trueCount} terms from Roentgen!"); } catch (Exception e) { MessageBox.Show($"Failed to download terms: {e.Message}"); } }