/// <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)) { 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; 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; }
private static bool GetOutResult(ScrapeFields scrapeFields, string scrapeGroup, MovieModel movie, string noneValue, MovieScraperGroupModel scraperGroup, bool outResult) { if (!string.IsNullOrEmpty(scrapeGroup) && scrapeGroup != noneValue) { bool result; ScrapeValues(movie, scrapeGroup, scrapeFields, out result); if (!result) { outResult = false; } } return outResult; }
/// <summary> /// The create new scraper group. /// </summary> private void CreateNewScraperGroup() { this.currentScraperGroup = new MovieScraperGroupModel(); }
/// <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 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> /// The serialize to xml. /// </summary> /// <param name="movie">The movie.</param> public static void SerializeToXml(MovieScraperGroupModel movie) { string path = Get.FileSystemPaths.PathDirScraperGroupsMovies + movie.ScraperName + ".xml"; try { var serializer = new XmlSerializer(typeof(MovieScraperGroupModel)); TextWriter textWriter = new StreamWriter(path); serializer.Serialize(textWriter, movie); textWriter.Close(); } catch (Exception ex) { Log.WriteToLog( LogSeverity.Error, 0, "Could not save scraper group", path + Environment.NewLine + ex.Message); } }
/// <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; }