Esempio n. 1
0
 /// <summary>
 /// Handles the RunWorkerCompleted event of the bgw control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.ComponentModel.RunWorkerCompletedEventArgs"/> instance containing the event data.</param>
 private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     this.tmr.Stop();
     TvDBFactory.GeneratePictureGallery();
     TvDBFactory.InvokeCurrentEpisodeChanged(new EventArgs());
     this.Close();
 }
Esempio n. 2
0
        /// <summary>
        /// Loads the TV DB db
        /// </summary>
        private static void LoadTvDB()
        {
            string path = Get.FileSystemPaths.PathDatabases + OutputName.TvDb + Path.DirectorySeparatorChar;

            Directory.CreateDirectory(path);

            var files = FileHelper.GetFilesRecursive(path, "*.Series.gz");

            TvDBFactory.TvDatabase.Clear();

            foreach (var file in files)
            {
                string json = Gzip.Decompress(file);

                var series = JsonConvert.DeserializeObject(json, typeof(Series)) as Series;

                string title = FileNaming.RemoveIllegalChars(series.SeriesName);

                string poster = path + title + ".poster.jpg";
                string fanart = path + title + ".fanart.jpg";
                string banner = path + title + ".banner.jpg";

                if (File.Exists(poster))
                {
                    series.SmallPoster = ImageHandler.LoadImage(poster);
                }

                if (File.Exists(fanart))
                {
                    series.SmallFanart = ImageHandler.LoadImage(fanart);
                }

                if (File.Exists(banner))
                {
                    series.SmallBanner = ImageHandler.LoadImage(banner);
                }

                TvDBFactory.TvDatabase.Add(series.SeriesName, series);
            }

            TvDBFactory.GeneratePictureGallery();
            TvDBFactory.GenerateMasterSeriesList();
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TvUserControl"/> class.
        /// </summary>
        public TvUserControl()
        {
            InitializeComponent();

            this.picSeriesBanner.HeaderTitle = "Banner";

            this.picSeriesFanart.HeaderTitle = "Fanart";

            this.picSeriesPoster.HeaderTitle = "Poster";

            this.picEpisodeFrame.HeaderTitle = "Episode Frame";

            grdTvTitleList.DataSource = Factories.TvDBFactory.MasterSeriesNameList;

            TvDBFactory.GalleryChanged += this.TvDBFactory_GalleryChanged;
            TvDBFactory.GeneratePictureGallery();

            TvDBFactory.CurrentSeriesChanged += this.TvDBFactory_CurrentSeriesChanged;
            TvDBFactory.CurrentSeasonChanged += this.TvDBFactory_CurrentSeasonChanged;
        }
Esempio n. 4
0
        /// <summary>
        /// Loads the TV DB db
        /// </summary>
        private static void LoadTvDB()
        {
            string path = Get.FileSystemPaths.PathDatabases + OutputName.TvDb + Path.DirectorySeparatorChar;

            Directory.CreateDirectory(path);

            List <string> files = FileHelper.GetFilesRecursive(path, "*.Series.gz");

            TvDBFactory.TvDatabase.Clear();

            var hidden = path + "hidden.hiddenSeries.gz";

            if (File.Exists(hidden))
            {
                var json = Gzip.Decompress(hidden);
                TvDBFactory.HiddenTvDatabase =
                    JsonConvert.DeserializeObject(json, typeof(BindingList <Series>)) as BindingList <Series>;
            }

            var parallelOptions = new ParallelOptions {
                MaxDegreeOfParallelism = 6
            };

            Parallel.ForEach(
                files,
                parallelOptions,
                file =>
            {
                var json = Gzip.Decompress(file);

                var series = JsonConvert.DeserializeObject(json, typeof(Series)) as Series;

                string title = FileNaming.RemoveIllegalChars(series.SeriesName);

                string poster = path + title + ".poster.jpg";
                string fanart = path + title + ".fanart.jpg";
                string banner = path + title + ".banner.jpg";

                if (File.Exists(poster))
                {
                    series.SmallPoster = ImageHandler.LoadImage(poster);
                }

                if (File.Exists(fanart))
                {
                    series.SmallFanart = ImageHandler.LoadImage(fanart);
                }

                if (File.Exists(banner))
                {
                    series.SmallBanner = ImageHandler.LoadImage(banner);
                }

                foreach (var season in series.Seasons)
                {
                    for (int index = 0; index < season.Value.Episodes.Count; index++)
                    {
                        var episode = season.Value.Episodes[index];
                        if (episode.FilePath.PathAndFilename != string.Empty &&
                            !File.Exists(episode.FilePath.PathAndFilename))
                        {
                            Log.WriteToLog(
                                LogSeverity.Info,
                                LoggerName.GeneralLog,
                                "Internal > DatabaseIOFactory > LoadTvDB",
                                string.Format(
                                    "Deleting {0}. Episode not found on the filesystem",
                                    episode.FilePath.PathAndFilename));
                            // We should check for network path and make sure the file has actually been deleted or removed
                            File.Delete(file);
                            series.Seasons[season.Key].Episodes.Remove(episode);
                        }
                    }
                }

                lock (TvDBFactory.TvDatabase)
                {
                    TvDBFactory.TvDatabase.Add(series.SeriesName, series);
                }
            });

            TvDBFactory.GeneratePictureGallery();
            TvDBFactory.GenerateMasterSeriesList();
        }