private void lbTvShows_SelectedValueChanged(object sender, EventArgs e) { tvShow selectedShow = (tvShow)lbTvShows.SelectedItem; tbTvdbId.Text = selectedShow.tvdbID.ToString(); tvhelper.GetTvShowData(FileList, selectedShow.tvdbID); tvhelper.TvShows.FindIndex(a => a.tvdbID.Equals(tvhelper.actualTvDbID)); }
private void popListBox(tvShows show, int selIndex) { if (tvhelper.TvShows != null && tvhelper.TvShows.Count > 0) { lbTvShows.SelectedValueChanged -= new System.EventHandler(lbTvShows_SelectedValueChanged); lbTvShows.DataSource = show; lbTvShows.DisplayMember = "name"; //lbTvShows.SelectedIndex = selIndex; lbTvShows.SelectedValueChanged += new System.EventHandler(lbTvShows_SelectedValueChanged); tvShow selectedShow = (tvShow)lbTvShows.SelectedItem; //tbTvdbId.Text = selectedShow.tvdbID.ToString(); var test = tvhelper.TvShows; MessageBox.Show("Finish"); } }
private async void GetEpisodes() { if (TvShows != null) { //Load Episode Data from TvShows and write back to TvShows; var client = new TvDbClient(); await client.Authentication.AuthenticateAsync(Data.ApiKey, Data.UserName, Data.UserKey); client.AcceptedLanguage = Data.prefLang; var tasks = new List <Task <TvDbResponse <TvDbSharper.Dto.EpisodeRecord[]> > >(); var response = new TvDbResponse <EpisodeRecord[]>(); tvShow show = TvShows.Find(i => i.tvdbID == actualTvDbID); if (show.Count > 1) { foreach (showEpisode ep in TvShows.Where(i => i.tvdbID == actualTvDbID)) { response = await client.Series.GetEpisodesAsync(ep.tvdbID, 1); for (int i = 2; i <= response.Links.Last; i++) { tasks.Add(client.Series.GetEpisodesAsync(ep.tvdbID, i)); } } } else { EpisodeQuery q = new EpisodeQuery(); q.AiredSeason = TvShows[0][0].seasonNr; q.AiredEpisode = TvShows[0][0].episodeNr; response = await client.Series.GetEpisodesAsync(show.tvdbID, 1, q); } var results = await Task.WhenAll(tasks); //var eps = response.Data.Concat(results.SelectMany(x => x.Data)); foreach (EpisodeRecord er in response.Data.Concat(results.SelectMany(x => x.Data))) { foreach (showEpisode ep in TvShows.Where(i => i.tvdbID == actualTvDbID)) { if (er.AiredSeason == ep.seasonNr && er.AiredEpisodeNumber == ep.episodeNr) { //DateTime dt = DateTime.Parse(ep.FirstAired); if (er.EpisodeName == null) //Backup if no German { client.AcceptedLanguage = "en"; TvDbResponse <EpisodeRecord> er1 = await client.Episodes.GetAsync(er.Id); ep.episodeName = er1.Data.EpisodeName; ep.description = er1.Data.Overview; } else { ep.episodeName = er.EpisodeName; ep.description = er.Overview; } ep.tvDbEpisodeId = er.Id; if (helper.isDateTime(er.FirstAired)) { ep.episodeAirDate = DateTime.Parse(er.FirstAired); } if (ep.episodeName != null && ep.episodeNumbering != null) { ep.newFilename = GetCorrectedFileName(ep.episodeName, ep.episodeNumbering); } } } } //Episode not found in Episode List } }