/// <summary> /// Handles the Click event of the btnSearch control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnSearch_Click(object sender, EventArgs e) { this.btnSearch.Enabled = false; this.txtSearch.Enabled = false; var theTvdb = new TheTvdb(); theTvdb.DoFullSearch(this.txtSearch.Text); this.UpdateDataBindings(); this.btnSearch.Enabled = true; this.txtSearch.Enabled = true; this.txtSearch.Text = string.Empty; }
/// <summary> /// Handles the Click event of the ButSearchAgain control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> private void ButSearchAgain_Click(object sender, EventArgs e) { this.butSearchAgain.Enabled = false; this.butUse.Enabled = false; this.butCancel.Enabled = false; var theTvdb = new TheTvdb(); this.searchDetails = theTvdb.SeriesSearch(this.txtSearchAgain.Text); this.Setup(this.searchDetails, this.txtSearchAgain.Text); this.butSearchAgain.Enabled = true; this.butUse.Enabled = true; this.butCancel.Enabled = true; }
/// <summary> /// Handles the DoWork event of the bgwScan control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data. /// </param> private void BgwScan_DoWork(object sender, DoWorkEventArgs e) { var tvdb = new TheTvdb(); int count = 0; foreach (UpdateTvRecords record in this.updateDatabase) { InternalApps.Logs.Log.WriteToLog( LogSeverity.Debug, 0, "UI > Dialogs > TV > FrmUpdateShows > BgwScan_DoWork", string.Format( "Checking {0} {1}x{2:00} for update", record.SeriesName, record.SeasonNumber.GetValueOrDefault(0), record.EpisodeNumber.GetValueOrDefault(0) ) ); this.bgwScan.ReportProgress(0, record); Series seriesObj = TvDBFactory.GetSeriesFromName(record.SeriesName); Series newSeries = tvdb.CheckForUpdate(seriesObj.SeriesID, seriesObj.Language, seriesObj.Lastupdated); if (newSeries != null) { InternalApps.Logs.Log.WriteToLog( LogSeverity.Debug, 0, "UI > Dialogs > TV > FrmUpdateShows > BgwScan_DoWork", string.Format( "Update found for {0} {1}x{2:00}", record.SeriesName, record.SeasonNumber.GetValueOrDefault(0), record.EpisodeNumber.GetValueOrDefault(0) ) ); record.NewTime = newSeries.Lastupdated; count++; } } e.Result = count; }
/// <summary> /// Handles the Click event of the btnSearch control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnSearch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtSearch.Text)) { XtraMessageBox.Show("Please enter a series to search for in the 'Add New Series' field.", "Empty search string"); return; } this.btnSearch.Enabled = false; this.txtSearch.Enabled = false; var theTvdb = new TheTvdb(); theTvdb.DoFullSearch(this.txtSearch.Text); this.UpdateDataBindings(); this.btnSearch.Enabled = true; this.txtSearch.Enabled = true; this.txtSearch.Text = string.Empty; }
/// <summary> /// Handles the SelectedValueChanged event of the CmbSearchResults control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> private void CmbSearchResults_SelectedValueChanged(object sender, EventArgs e) { if (this.cmbSearchResults.Items.Count == 0) { this.pictureBox1.Image = null; this.lblSearchTerm.Text = this.searchTerm; this.lblSeriesName.Text = string.Empty; this.lblFirstAired.Text = string.Empty; this.lblLanguage.Text = string.Empty; this.tbOverview.Text = string.Empty; this.butUse.Enabled = false; return; } string id = Regex.Match(this.cmbSearchResults.SelectedValue.ToString(), @"(?<id>\d*?):.*?").Groups["id"].Value; SearchDetails result = this.searchDetails.Single(s => s.ID.ToString() == id.ToString()); this.lblSearchTerm.Text = this.searchTerm; this.lblSeriesName.Text = result.SeriesName; if (result.FirstAired != null) { this.lblFirstAired.Text = result.FirstAired.Value.ToString("yyyy-MM-dd"); } this.lblLanguage.Text = result.Language; this.tbOverview.Text = result.OverView; if (!string.IsNullOrEmpty(result.Banner)) { string url = result.Banner; url = TheTvdb.ReturnBannerDownloadPath(url, true); string path = Downloader.ProcessDownload(url, DownloadType.Binary, Section.Tv); this.pictureBox1.Image = ImageHandler.LoadImage(path); } this.butUse.Enabled = true; }
/// <summary> /// Handles the DoWork event of the bgwScan control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data. /// </param> private void BgwScan_DoWork(object sender, DoWorkEventArgs e) { var tvdb = new TheTvdb(); int count = 0; foreach (UpdateTvRecords series in this.updateDatabase) { this.bgwScan.ReportProgress(0, series.SeriesName); Series seriesObj = TvDBFactory.GetSeriesFromName(series.SeriesName); Series newSeries = tvdb.CheckForUpdate(seriesObj.SeriesID, seriesObj.Language, seriesObj.Lastupdated); if (newSeries != null) { series.NewTime = newSeries.Lastupdated; count++; } } e.Result = count; }
public static async Task TvShow(TelegramBotClient botHandle, Message source, GroupCollection matches) { var replyText = Strings.TVDefault; if (!string.IsNullOrWhiteSpace(matches[2].Value)) { var shows = await TheTvdb.SearchTvShows(matches[2].Value); if (shows.Count > 0) { var firstResult = shows.First(); var show = await TheTvdb.GetShow(firstResult.Id); replyText = MessageFormatter(show); } else { replyText = Strings.TVNoResults; } } await botHandle.SendSmartTextMessageAsync(source, replyText, ParseMode.Html); }
private void BgwDoWork(object sender, DoWorkEventArgs e) { this.theTvdb = new TheTvdb(); var toAdd = new Dictionary <string, ScanSeries>(); var toRemove = new List <string>(); foreach (var s in ImportTvFactory.Scan) { if ( (from series in ImportTvFactory.SeriesNameList where series.SeriesName == s.Key && series.WaitingForScan select series).SingleOrDefault() != null) { if (!string.IsNullOrEmpty(s.Key)) { this.currentStatus = "Processing " + s.Key; var searchResults = this.theTvdb.SeriesSearch(s.Key); // open initial object and do search Series series; if (searchResults.Count > 1 || searchResults.Count == 0) { var scan = (from scanSeriesPick in ImportTvFactory.ScanSeriesPicks where scanSeriesPick.SearchString == s.Key select scanSeriesPick).SingleOrDefault(); if (scan != null) { searchResults = this.theTvdb.SeriesSearch(scan.SeriesName); var result = (from r in searchResults where r.SeriesID == scan.SeriesID select r).Single(); series = this.theTvdb.OpenNewSeries(result); } else { var resultCollection = new List <object>(4) { searchResults, s.Key, s.Value, toAdd, toRemove }; e.Result = resultCollection; return; } } else { series = this.theTvdb.OpenNewSeries(searchResults[0]); // download series details } this.Set(series, toRemove, toAdd, s.Key, s.Value); } } this.count++; this.bgw.ReportProgress(this.count); if (bgw.CancellationPending) { return; } } foreach (var s in toRemove) { ImportTvFactory.Scan.Remove(s); } foreach (var s in toAdd) { ImportTvFactory.Scan.Add(s.Key, s.Value); } this.theTvdb.ApplyScan(); }
/// <summary> /// Handles the DoWork event of the Bgw control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param> private void Bgw_DoWork(object sender, DoWorkEventArgs e) { string logCategory = "FrmImportTv > Bgw_DoWork"; this.theTvdb = new TheTvdb(); var toAdd = new Dictionary <string, ScanSeries>(); var toRemove = new List <string>(); Factories.UI.Windows7UIFactory.StartProgressState(ImportTvFactory.Scan.Count); var count = 0; InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("Starting import of tv series. {0} shows to scan.", ImportTvFactory.Scan.Count), logCategory); foreach (var s in ImportTvFactory.Scan) { InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("Starting import of show {0}", s.Key), logCategory); Factories.UI.Windows7UIFactory.SetProgressValue(count); var item = (from series in ImportTvFactory.SeriesNameList where series.SeriesName == s.Key && series.WaitingForScan select series).SingleOrDefault(); this.currentIndex = gridView1.GetRowHandle(ImportTvFactory.SeriesNameList.IndexOf(item)); if (item != null) { if (!string.IsNullOrEmpty(s.Key)) { this.currentStatus = "Processing " + s.Key; InternalApps.Logs.Log.WriteToLog(LogSeverity.Info, 0, string.Format("Processing {0}", s.Key), logCategory); var searchResults = TvDBFactory.SearchDefaultShowDatabase(s.Key); if (searchResults.Count == 0) { InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("{0} was not found in default show database. Trying TvDB", s.Key), logCategory); searchResults = this.theTvdb.SeriesSearch(Tools.Clean.Text.UrlEncode(s.Key)); // open initial object and do search } Series series; if (searchResults.Count > 1 || searchResults.Count == 0) { InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("{0} results was found", searchResults.Count), logCategory); var scan = (from scanSeriesPick in ImportTvFactory.ScanSeriesPicks where scanSeriesPick.SearchString == s.Key select scanSeriesPick).SingleOrDefault(); if (scan != null) { InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("Attempting to search for {0} based on scanSeriesPick.", scan.SeriesName), logCategory); searchResults = this.theTvdb.SeriesSearch(Tools.Clean.Text.UrlEncode(scan.SeriesName)); var result = (from r in searchResults where r.SeriesID == scan.SeriesID select r).Single(); series = this.theTvdb.OpenNewSeries(result); InternalApps.Logs.Log.WriteToLog(LogSeverity.Info, 0, string.Format("{0} was found to have ID {1} (IMDb: {2})", series.SeriesName, series.ID, series.ImdbId), logCategory); } else { InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("{0} was not found in scanSeriesPick", s.Key), logCategory); var resultCollection = new List <object>(4) { searchResults, s.Key, s.Value, toAdd, toRemove }; e.Result = resultCollection; return; } } else { series = this.theTvdb.OpenNewSeries(searchResults[0]); // download series details InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("{0} was found to have ID {1} (IMDb: {2})", series.SeriesName, series.ID, series.ImdbId), logCategory); if ((from scan in ImportTvFactory.ScanSeriesPicks where scan.SearchString == s.Key select s).Count() == 0) { ImportTvFactory.ScanSeriesPicks.Add( new ScanSeriesPick { SearchString = s.Key, SeriesID = series.SeriesID.ToString(), SeriesName = series.SeriesName }); InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("{0} was added to scanSeriesPick", series.SeriesName), logCategory); } } this.Set(series, toRemove, toAdd, s.Key, s.Value); } } this.count++; this.bgw.ReportProgress(this.count); if (this.bgw.CancellationPending) { return; } count++; } foreach (var s in toRemove) { ImportTvFactory.Scan.Remove(s); InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("Removing {0} from scan database", s), logCategory); } foreach (var s in toAdd) { ImportTvFactory.Scan.Add(s.Key, s.Value); InternalApps.Logs.Log.WriteToLog(LogSeverity.Debug, 0, string.Format("Adding {0} to scan database", s), logCategory); } this.theTvdb.ApplyScan(); Factories.UI.Windows7UIFactory.StopProgressState(); }