/// <summary> /// Handles the DoWork event of the SavingTVDB 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 static void SavingTVDB_DoWork(object sender, DoWorkEventArgs e) { var series = e.Argument as Series; string path = Get.FileSystemPaths.PathDatabases + OutputName.TvDb + Path.DirectorySeparatorChar; string title = FileNaming.RemoveIllegalChars(series.SeriesName); string writePath = path + title + ".Series"; string json = JsonConvert.SerializeObject(series); Gzip.CompressString(json, writePath + ".gz"); if (series.SmallBanner != null) { var smallBanner = new Bitmap(series.SmallBanner); smallBanner.Save(path + title + ".banner.jpg"); } if (series.SmallFanart != null) { var smallFanart = new Bitmap(series.SmallFanart); smallFanart.Save(path + title + ".fanner.jpg"); } if (series.SmallPoster != null) { var smallPoster = new Bitmap(series.SmallPoster); smallPoster.Save(path + title + ".poster.jpg"); } }
private static void SaveTvDB() { SavingCount++; var path = Get.FileSystemPaths.PathDatabases + OutputName.TvDb + Path.DirectorySeparatorChar; Directory.CreateDirectory(path); Folders.DeleteFilesInFolder(path); string writePath = path + "hidden.hiddenSeries"; string json = JsonConvert.SerializeObject(TvDBFactory.HiddenTvDatabase); Gzip.CompressString(json, writePath + ".gz"); var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 6 }; SavingTVDBMax = TvDBFactory.TvDatabase.Count; SavingTVDBValue = 0; Parallel.ForEach( TvDBFactory.TvDatabase, parallelOptions, series => { var title = FileNaming.RemoveIllegalChars(series.Value.SeriesName); var seriesPath = string.Concat(Get.FileSystemPaths.PathDatabases, OutputName.TvDb, Path.DirectorySeparatorChar, title, ".Series.gz"); json = JsonConvert.SerializeObject(series.Value); Gzip.CompressString(json, seriesPath); if (series.Value.SmallBanner != null) { var smallBanner = new Bitmap(series.Value.SmallBanner); smallBanner.Save(path + title + ".banner.jpg"); } if (series.Value.SmallFanart != null) { var smallFanart = new Bitmap(series.Value.SmallFanart); smallFanart.Save(path + title + ".fanner.jpg"); } if (series.Value.SmallPoster != null) { var smallPoster = new Bitmap(series.Value.SmallPoster); smallPoster.Save(path + title + ".poster.jpg"); } SavingTVDBValue++; Application.DoEvents(); }); SavingCount--; frmSavingDB.TvDBFinished(); }
/// <summary> /// Handles the DoWork event of the bgwSaveScanSeriesPick 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 static void bgwSaveScanSeriesPick_DoWork(object sender, DoWorkEventArgs e) { string path = Get.FileSystemPaths.PathDatabases + OutputName.ScanSeriesPick + Path.DirectorySeparatorChar; Directory.CreateDirectory(path); const string WritePath = "SeriesPick"; string json = JsonConvert.SerializeObject(ImportTvFactory.ScanSeriesPicks); Gzip.CompressString(json, path + WritePath + "SeriesPick.gz"); }
/// <summary> /// Handles the DoWork event of the bgwSaveMovieSets 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 static void bgwSaveMovieSets_DoWork(object sender, DoWorkEventArgs e) { string path = Get.FileSystemPaths.PathDatabases + OutputName.MovieSets + Path.DirectorySeparatorChar; Directory.CreateDirectory(path); foreach (MovieSetModel set in MovieSetManager.CurrentDatabase) { string json = JsonConvert.SerializeObject(set); Gzip.CompressString(json, path + FileNaming.RemoveIllegalChars(set.SetName) + ".MovieSet.gz"); } }
/// <summary> /// Handles the DoWork event of the bgwSaveMediaPathDb 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 static void bgwSaveMediaPathDb_DoWork(object sender, DoWorkEventArgs e) { string path = Get.FileSystemPaths.PathDatabases + OutputName.MediaPathDb + Path.DirectorySeparatorChar; Directory.CreateDirectory(path); Folders.RemoveAllFilesInFolder(path); int count = 0; foreach (MediaPathModel mediaPath in MediaPathDBFactory.MediaPathDB) { string json = JsonConvert.SerializeObject(mediaPath); Gzip.CompressString(json, path + count + ".MediaPath.gz"); count++; } }
/// <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 static void bgwSaveMovieDBWork_DoWork(object sender, DoWorkEventArgs e) { string path = Get.FileSystemPaths.PathDatabases + OutputName.MovieDb + Path.DirectorySeparatorChar; var movieModel = e.Argument as MovieModel; string title = FileNaming.RemoveIllegalChars(movieModel.Title); string writePath = path + title + ".movie"; bool writeText = false; bool writeImages = false; if (!movieModel.DatabaseSaved) { writeImages = true; } if (!movieModel.DatabaseSaved || movieModel.ChangedText) { writeText = true; } if (writeText) { movieModel.DatabaseSaved = true; string json = JsonConvert.SerializeObject(movieModel); Gzip.CompressString(json, writePath + ".gz"); } var posterPath = path + title + ".poster.jpg"; var fanartPath = path + title + ".fanart.jpg"; if (movieModel.SmallPoster != null && (movieModel.ChangedPoster || writeImages)) { movieModel.SmallPoster.Save(posterPath); } if (movieModel.SmallFanart != null && (movieModel.ChangedFanart || writeImages)) { movieModel.SmallFanart.Save(fanartPath); } }
/// <summary> /// The serialize to xml. /// </summary> /// <param name="movie">The movie.</param> public static void SerializeToXml(MovieScraperGroupModel scraperGroupModel) { string path = Get.FileSystemPaths.PathDirScraperGroupsMovies + scraperGroupModel.ScraperName; try { if (scraperGroupModel == null) { scraperGroupModel = new MovieScraperGroupModel(); } string json = JsonConvert.SerializeObject(scraperGroupModel); Gzip.CompressString(json, path + ".gz"); } catch (Exception ex) { Log.WriteToLog( LogSeverity.Error, 0, "Could not save scraper group", path + Environment.NewLine + ex.Message); } }
/// <summary> /// Handles the DoWork event of the bgwSaveMediaPathDb 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 static void bgwSaveMediaPathDb_DoWork(object sender, DoWorkEventArgs e) { SavingCount++; string path = Get.FileSystemPaths.PathDatabases + OutputName.MediaPathDb + Path.DirectorySeparatorChar; Directory.CreateDirectory(path); Folders.DeleteFilesInFolder(path); int count = 0; for (int index = 0; index < MediaPathDBFactory.MediaPathDB.Count; index++) { MediaPathModel mediaPath = MediaPathDBFactory.MediaPathDB[index]; string json = JsonConvert.SerializeObject(mediaPath); Gzip.CompressString(json, path + count + ".MediaPath.gz"); count++; } SavingCount--; }
/// <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 static void bgw_DoWork(object sender, DoWorkEventArgs e) { string path = Get.FileSystemPaths.PathDatabases + OutputName.MovieDb + Path.DirectorySeparatorChar; var movieModel = e.Argument as MovieModel; string title = FileNaming.RemoveIllegalChars(movieModel.Title); string writePath = path + title + ".movie"; string json = JsonConvert.SerializeObject(movieModel); Gzip.CompressString(json, writePath + ".gz"); if (movieModel.SmallPoster != null) { movieModel.SmallPoster.Save(path + title + ".poster.jpg"); } if (movieModel.SmallFanart != null) { movieModel.SmallFanart.Save(path + title + ".fanart.jpg"); } }
private static void SaveMovies(BindingList <MovieModel> database) { int max = database.Count; if (max == 0) { return; } SavingMovieMax += database.Count - 1; var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 6 }; Parallel.ForEach( database, parallelOptions, movie => { SavingCount++; var path = Get.FileSystemPaths.PathDatabases + OutputName.MovieDb + Path.DirectorySeparatorChar; var title = FileNaming.RemoveIllegalChars(movie.Title); string writePath; if (movie.Hidden) { writePath = path + title + ".hiddenmovie"; } else { writePath = path + title + ".movie"; } movie.DatabaseSaved = true; var json = JsonConvert.SerializeObject(movie); Gzip.CompressString(json, writePath + ".gz"); var posterPath = path + title + ".poster.jpg"; var fanartPath = path + title + ".fanart.jpg"; if (movie.SmallPoster != null) { movie.SmallPoster.Save(posterPath); } if (movie.SmallFanart != null) { movie.SmallFanart.Save(fanartPath); } Application.DoEvents(); SavingMovieValue++; }); frmSavingDB.MovieDBFinished(); SavingMovieDB = false; }