/// <summary> /// Initializes a new instance of the <see cref="FrmScraperGroupManager"/> class. /// </summary> public FrmScraperGroupManager() { this.InitializeComponent(); MovieScraperGroupFactory.GetScraperGroupsOnDisk(this.cmbScraperGroupList); this.SetupInitialDataBindings(); this.SelectFirstScraperGroupEntry(); }
/// <summary> /// Handles the EditValueChanged event of the cmbScraperGroupList 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 CmbScraperGroupListEditValueChanged(object sender, EventArgs e) { if (this.cmbScraperGroupList.Text != string.Empty) { this.currentScraperGroup = MovieScraperGroupFactory.DeserializeXml(this.cmbScraperGroupList.Text); this.RefreshDatabindings(); } }
/// <summary> /// Handles the Click event of the btnSave 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 BtnSaveClick(object sender, EventArgs e) { MovieScraperGroupFactory.SerializeToXml(this.currentScraperGroup); this.cmbScraperGroupList.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; this.btnRefresh.Enabled = this.currentScraperDirty; this.currentScraperDirty = false; }
/// <summary> /// Handles the EditValueChanging event of the cmbScraperGroupList control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="DevExpress.XtraEditors.Controls.ChangingEventArgs"/> instance containing the event data. /// </param> private void CmbScraperGroupListEditValueChanging(object sender, ChangingEventArgs e) { if (this.currentScraperDirty) { DialogResult result = XtraMessageBox.Show( "Do you wish to save the current scraper group?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { MovieScraperGroupFactory.SerializeToXml(this.currentScraperGroup); this.currentScraperDirty = false; } } }
/// <summary> /// Handles the Click event of the btnRemove 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 BtnRemoveClick(object sender, EventArgs e) { DialogResult result = XtraMessageBox.Show( "Are you sure you wish to delete this scraper group?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { File.Delete( Get.FileSystemPaths.PathDirScraperGroupsMovies + this.currentScraperGroup.ScraperName + ".xml"); MovieScraperGroupFactory.GetScraperGroupsOnDisk(this.cmbScraperGroupList); this.SelectFirstScraperGroupEntry(); } }
/// <summary> /// Handles the Click event of the btnOk 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 BtnOkClick(object sender, EventArgs e) { if (this.currentScraperDirty) { DialogResult result = XtraMessageBox.Show( "Do you wish to save the current scraper first?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { MovieScraperGroupFactory.SerializeToXml(this.currentScraperGroup); } } this.Close(); }
/// <summary> /// Handles the BeforePopup event of the popupLoadFromWeb control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data. /// </param> private void popupLoadFromWeb_BeforePopup(object sender, CancelEventArgs e) { this.popupLoadFromWeb.ClearLinks(); var barItemLink = new BarButtonItem( this.barManager1, "Scrape using " + MovieDBFactory.GetCurrentMovie().ScraperGroup); barItemLink.Tag = MovieDBFactory.GetCurrentMovie().ScraperGroup; barItemLink.ItemClick += this.barItemLink_ItemClick; this.popupLoadFromWeb.AddItem(barItemLink); foreach (var scraper in MovieScraperGroupFactory.GetScraperGroupsOnDisk()) { barItemLink = new BarButtonItem(this.barManager1, "Use " + scraper); barItemLink.Tag = MovieDBFactory.GetCurrentMovie().ScraperGroup; barItemLink.ItemClick += this.barItemLink_ItemClick; this.popupLoadFromWeb.AddItem(barItemLink); } }
/// <summary> /// Handles the Click event of the btnAdd 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 BtnAddClick(object sender, EventArgs e) { var enterAValue = new FrmEnterAValue("Enter a scraper name"); enterAValue.ShowDialog(); if (!enterAValue.Cancelled) { var scraperGroup = new MovieScraperGroupModel { ScraperName = enterAValue.Response }; MovieScraperGroupFactory.SerializeToXml(scraperGroup); MovieScraperGroupFactory.GetScraperGroupsOnDisk(this.cmbScraperGroupList); this.currentScraperGroup = scraperGroup; this.currentScraperGroup = new MovieScraperGroupModel(); this.RefreshDatabindings(); this.cmbScraperGroupList.Text = enterAValue.Response; } }
/// <summary> /// Runs the single scrape. /// </summary> /// <param name="movie"> /// The model. /// </param> /// <param name="testmode"> /// if set to <c>true</c> [testmode]. /// </param> /// <returns> /// The run single scrape. /// </returns> public static bool RunSingleScrape(MovieModel movie, bool testmode = false) { scrapers.Clear(); scrapers = ReturnAllScrapers(); if (string.IsNullOrEmpty(movie.ScraperGroup) && string.IsNullOrEmpty(MovieDBFactory.TempScraperGroup)) { XtraMessageBox.Show( "No Scraper Group Selected", "Select a Scraper Group", MessageBoxButtons.OK, MessageBoxIcon.Hand); Log.WriteToLog( LogSeverity.Error, 0, "No Scraper Group Selected", "No scraper group selected for " + movie.Title); return(false); } MovieScraperGroupModel scraperGroup; if (testmode) { scraperGroup = new MovieScraperGroupModel { Title = "Imdb", Year = "Imdb", Cast = "Imdb", Certification = "Imdb", Country = "Imdb", Director = "Imdb", Fanart = "TheMovieDB", Genre = "Imdb", Language = "Imdb", Top250 = "Imdb", Outline = "TheMovieDB", Plot = "Imdb", Rating = "Imdb", ReleaseDate = "Imdb", Runtime = "Imdb", Studio = "Imdb", Tagline = "Imdb", Votes = "Imdb", Writers = "Imdb", Trailer = "Apple" }; } else { if (!string.IsNullOrEmpty(MovieDBFactory.TempScraperGroup)) { scraperGroup = MovieScraperGroupFactory.GetScaperGroupModel(MovieDBFactory.TempScraperGroup); } else { scraperGroup = MovieScraperGroupFactory.GetScaperGroupModel(movie.ScraperGroup); } } bool outResult = true; var noneValue = "<None>"; outResult = GetOutResult(ScrapeFields.Title, scraperGroup.Title, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.OriginalTitle, scraperGroup.OriginalTitle, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Year, scraperGroup.Year, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Top250, scraperGroup.Top250, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Cast, scraperGroup.Cast, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Certification, scraperGroup.Certification, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Mpaa, scraperGroup.Mpaa, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Country, scraperGroup.Country, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Director, scraperGroup.Director, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Fanart, scraperGroup.Fanart, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Genre, scraperGroup.Genre, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Language, scraperGroup.Language, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Outline, scraperGroup.Outline, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Plot, scraperGroup.Plot, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Rating, scraperGroup.Rating, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.ReleaseDate, scraperGroup.ReleaseDate, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Runtime, scraperGroup.Runtime, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Studio, scraperGroup.Studio, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Tagline, scraperGroup.Tagline, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Votes, scraperGroup.Votes, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Writers, scraperGroup.Writers, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Poster, scraperGroup.Poster, movie, noneValue, scraperGroup, outResult); outResult = GetOutResult(ScrapeFields.Trailer, scraperGroup.Trailer, movie, noneValue, scraperGroup, outResult); return(outResult); }
/// <summary> /// Runs the single scrape. /// </summary> /// <param name="movie"> /// The model. /// </param> /// <param name="testmode"> /// if set to <c>true</c> [testmode]. /// </param> /// <returns> /// The run single scrape. /// </returns> public bool RunSingleScrape(MovieModel movie, bool testmode = false) { if (string.IsNullOrEmpty(movie.ScraperGroup)) { XtraMessageBox.Show( "No Scraper Group Selected", "Select a Scraper Group", MessageBoxButtons.OK, MessageBoxIcon.Hand); Log.WriteToLog( LogSeverity.Error, 0, "No Scraper Group Selected", "No scraper group selected for " + movie.Title); return(false); } MovieScraperGroupModel scraperGroup; if (testmode) { scraperGroup = new MovieScraperGroupModel { Title = "Imdb", Year = "Imdb", Cast = "Imdb", Certification = "Imdb", Country = "Imdb", Director = "Imdb", Fanart = "TheMovieDB", Genre = "Imdb", Language = "Imdb", Top250 = "Imdb", Outline = "TheMovieDB", Plot = "Imdb", Rating = "Imdb", ReleaseDate = "Imdb", Runtime = "Imdb", Studio = "Imdb", Tagline = "Imdb", Votes = "Imdb", Writers = "Imdb", Trailer = "Apple" }; } else { scraperGroup = MovieScraperGroupFactory.GetScaperGroupModel(movie.ScraperGroup); } bool outResult = true; if (!string.IsNullOrEmpty(scraperGroup.Title) && scraperGroup.Title != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Title, ScrapeFields.Title, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Year) && scraperGroup.Year != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Year, ScrapeFields.Year, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Top250) && scraperGroup.Top250 != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Top250, ScrapeFields.Top250, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Cast) && scraperGroup.Cast != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Cast, ScrapeFields.Cast, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Certification) && scraperGroup.Certification != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Certification, ScrapeFields.Certification, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Mpaa) && scraperGroup.Mpaa != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Mpaa, ScrapeFields.Mpaa, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Country) && scraperGroup.Country != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Country, ScrapeFields.Country, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Director) && scraperGroup.Director != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Director, ScrapeFields.Director, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Fanart) && scraperGroup.Fanart != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Fanart, ScrapeFields.Fanart, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Genre) && scraperGroup.Genre != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Genre, ScrapeFields.Genre, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Language) && scraperGroup.Language != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Language, ScrapeFields.Language, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Outline) && scraperGroup.Outline != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Outline, ScrapeFields.Outline, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Plot) && scraperGroup.Plot != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Plot, ScrapeFields.Plot, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Rating) && scraperGroup.Rating != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Rating, ScrapeFields.Rating, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.ReleaseDate) && scraperGroup.ReleaseDate != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.ReleaseDate, ScrapeFields.ReleaseDate, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Runtime) && scraperGroup.Runtime != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Runtime, ScrapeFields.Runtime, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Studio) && scraperGroup.Studio != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Studio, ScrapeFields.Studio, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Tagline) && scraperGroup.Tagline != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Tagline, ScrapeFields.Tagline, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Votes) && scraperGroup.Votes != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Votes, ScrapeFields.Votes, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Writers) && scraperGroup.Writers != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Writers, ScrapeFields.Writers, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Poster) && scraperGroup.Poster != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Poster, ScrapeFields.Poster, out result); if (!result) { outResult = false; } } if (!string.IsNullOrEmpty(scraperGroup.Trailer) && scraperGroup.Trailer != "<None>") { bool result; this.ScrapeValues(movie, scraperGroup.Trailer, ScrapeFields.Trailer, out result); if (!result) { outResult = false; } } return(outResult); }