private async Task LoadFilmsAsync() { string inputText = tbIn.Text.Replace(" ", string.Empty); List <string> inputLines = new List <string>(inputText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)); var lines = inputLines.Select(inputLine => new Line(inputLine)).ToList(); int filmCount = 1; OutputOptions options = new OutputOptions { Counter = cbCounter.Checked, Title = cbTitle.Checked, Date = cbDate.Checked, TMDb = cbTMDb.Checked, Link = cbInputLink.Checked, Separator = tbSeparator.Text, }; foreach (Line line in lines) { if (!going) { break; } tbOut.AppendText(await line.GetOutputAsync(options, filmCount)); lProgress.Text = filmCount + " / " + lines.Count + " (" + (filmCount * 100 / lines.Count) + "%)"; filmCount++; } Stop(); }
public async Task <string> GetOutputAsync(OutputOptions options, int filmCount) { Film f = await TMDbService.GetFilmByIdAsync(Id); List <string> elements = new List <string>(); if (options.Counter) { elements.Add(filmCount.ToString()); } if (f == null || ( f.movie_results.Count == 0 && f.tv_results.Count == 0 && f.tv_episode_results.Count == 0 && f.person_results.Count == 0 && f.tv_season_results.Count == 0)) { elements.Add("Not found on TMDb: " + Link); } else if (f.movie_results.Count > 0) { Movie_Results mr = f.movie_results[0]; if (options.Title) { elements.Add(mr.title); } if (options.Date) { elements.Add(mr.release_date); } if (options.TMDb) { elements.Add(mr.vote_average.ToString()); } if (options.Link) { elements.Add(Link); } } else if (f.tv_results.Count > 0) { Tv_Results tr = f.tv_results[0]; if (options.Title) { elements.Add(tr.name); } if (options.Date) { elements.Add(tr.first_air_date); } if (options.TMDb) { elements.Add(tr.vote_average.ToString()); } if (options.Link) { elements.Add(Link); } } else if (f.tv_episode_results.Count > 0) { Tv_Episode_Results ter = f.tv_episode_results[0]; if (options.Title) { elements.Add(ter.name); } if (options.Date) { elements.Add(ter.air_date); } if (options.TMDb) { elements.Add(ter.vote_average.ToString()); } if (options.Link) { elements.Add(Link); } } else if (f.person_results.Count > 0) { Person_Results pr = f.person_results[0]; if (options.Title) { elements.Add(pr.name); } if (options.Date) { elements.Add(pr.known_for_department); } if (options.Link) { elements.Add(Link); } } else if (f.tv_season_results.Count > 0) { if (options.Link) { elements.Add(Link); } } return(string.Join(options.Separator, elements) + Environment.NewLine); }