예제 #1
0
        /// <summary>
        /// The do import scan.
        /// </summary>
        public static void DoImportScan()
        {
            SeriesNameList = new BindingList <SeriesListModel>();
            Scan           = new SortedDictionary <string, ScanSeries>();

            // Get file list
            var filters = Get.InOutCollection.VideoExtentions;

            var paths = MediaPathDBFactory.GetMediaPathTvUnsorted();

            var filteredFiles = (from file in paths
                                 let pathAndFileName = Path.GetExtension(file.PathAndFileName).ToLower()
                                                       where filters.Any(filter => pathAndFileName.ToLower() == "." + filter.ToLower())
                                                       select file.PathAndFileName).ToList();

            // Process each file and add to ScanDB);
            foreach (var f in filteredFiles)
            {
                var episodeDetails = GetEpisodeDetails(f);

                if (episodeDetails.TvMatchSuccess)
                {
                    AddScanResult(episodeDetails);
                }
                else
                {
                    NotCatagorized.Add(new ScanNotCatagorized {
                        FilePath = f
                    });
                }
            }

            MasterMediaDBFactory.PopulateMasterTvMediaDatabase();
        }
예제 #2
0
        /// <summary>
        /// Handles the Click event of the ButRefresh 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 ButRefresh_Click(object sender, EventArgs e)
        {
            MediaPathDBFactory.GetMediaPathMoviesUnsorted().Clear();
            MediaPathDBFactory.GetMediaPathTvUnsorted().Clear();

            this.backgroundWorker = new BackgroundWorker();

            this.backgroundWorker.DoWork             += this.BackgroundWorker_DoWork;
            this.backgroundWorker.RunWorkerCompleted += this.BackgroundWorker_RunWorkerCompleted;

            this.backgroundWorker.RunWorkerAsync();

            this.EnableForm(false);
        }
예제 #3
0
 /// <summary>
 /// The setup bindings.
 /// </summary>
 public void SetupBindings()
 {
     this.grdMediaPathList.DataSource           = MediaPathDBFactory.MediaPathDB;
     this.grdMediaPathUnsortedMovies.DataSource = MediaPathDBFactory.GetMediaPathMoviesUnsorted();
     this.grdMediaPathUnsortedTv.DataSource     = MediaPathDBFactory.GetMediaPathTvUnsorted();
 }
예제 #4
0
        /// <summary>
        /// Add scan result.
        /// </summary>
        /// <param name="episodeDetails">
        /// The episode details.
        /// </param>
        public static void AddScanResult(EpisodeDetails episodeDetails)
        {
            var seriesName = episodeDetails.SeriesName;

            var name   = seriesName;
            var check1 = (from s in Scan where s.Key.ToLower() == name.ToLower() select s.Key).SingleOrDefault();

            // Process Series
            if (check1 == null)
            {
                Scan.Add(seriesName, new ScanSeries());

                var check2 = (from s in SeriesNameList where s.SeriesName.ToLower() == seriesName.ToLower() select s.SeriesName.ToLower()).ToList();

                if (!check2.Contains(seriesName.ToLower()) && !string.IsNullOrEmpty(seriesName))
                {
                    string dir  = Directory.GetParent(episodeDetails.FilePath).Name;
                    string path = string.Empty;
                    if (dir.StartsWith("season", true, System.Globalization.CultureInfo.CurrentCulture))
                    {
                        // Looks like it. Qualified series guess
                        path = Directory.GetParent(episodeDetails.FilePath).Parent.FullName;
                    }
                    else
                    {
                        // Best guess
                        path = Directory.GetParent(episodeDetails.FilePath).FullName;
                    }

                    SeriesNameList.Add(
                        new SeriesListModel {
                        WaitingForScan = true, SeriesName = seriesName, SeriesPath = path
                    });
                }
            }
            else
            {
                seriesName = check1;
            }

            // Process Series
            if (!Scan[seriesName].Seasons.ContainsKey(episodeDetails.SeasonNumber))
            {
                Scan[seriesName].Seasons.Add(episodeDetails.SeasonNumber, new ScanSeason());
            }

            if (
                !Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.ContainsKey(
                    episodeDetails.EpisodeNumber))
            {
                Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.Add(
                    episodeDetails.EpisodeNumber, new ScanEpisode());
            }

            Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[episodeDetails.EpisodeNumber].
            FilePath = episodeDetails.FilePath;

            if (episodeDetails.SecondaryNumbers.Count > 0)
            {
                foreach (int secondary in episodeDetails.SecondaryNumbers)
                {
                    if (
                        !Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.ContainsKey(
                            secondary))
                    {
                        Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.Add(
                            secondary, new ScanEpisode());
                    }

                    Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[secondary].FilePath =
                        episodeDetails.FilePath;
                    Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[secondary].Secondary =
                        true;
                    Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[secondary].SecondaryTo
                        = episodeDetails.EpisodeNumber;
                }
            }

            var findList =
                (from s in MediaPathDBFactory.GetMediaPathTvUnsorted()
                 where s.PathAndFileName == episodeDetails.FilePath
                 select s).ToList();

            foreach (var path in findList)
            {
                MediaPathDBFactory.GetMediaPathTvUnsorted().Remove(path);
            }
        }
예제 #5
0
        /// <summary>
        /// Add scan result.
        /// </summary>
        /// <param name="episodeDetails">
        /// The episode details.
        /// </param>
        public static void AddScanResult(EpisodeDetails episodeDetails)
        {
            var seriesName = episodeDetails.SeriesName;

            var name   = seriesName;
            var check1 = (from s in Scan where s.Key.ToLower() == name.ToLower() select s.Key).SingleOrDefault();

            // Process Series
            if (check1 == null)
            {
                Scan.Add(seriesName, new ScanSeries());

                var check2 = (from s in SeriesNameList where s.SeriesName.ToLower() == seriesName.ToLower() select s.SeriesName.ToLower()).ToList();

                if (!check2.Contains(seriesName.ToLower()))
                {
                    SeriesNameList.Add(
                        new SeriesListModel {
                        WaitingForScan = true, SeriesName = seriesName
                    });
                }
            }
            else
            {
                seriesName = check1;
            }

            // Process Series
            if (!Scan[seriesName].Seasons.ContainsKey(episodeDetails.SeasonNumber))
            {
                Scan[seriesName].Seasons.Add(episodeDetails.SeasonNumber, new ScanSeason());
            }

            if (
                !Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.ContainsKey(
                    episodeDetails.EpisodeNumber))
            {
                Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.Add(
                    episodeDetails.EpisodeNumber, new ScanEpisode());
            }

            Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[episodeDetails.EpisodeNumber].
            FilePath = episodeDetails.FilePath;

            if (episodeDetails.SecondaryNumbers.Count > 0)
            {
                foreach (int secondary in episodeDetails.SecondaryNumbers)
                {
                    if (
                        !Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.ContainsKey(
                            secondary))
                    {
                        Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes.Add(
                            secondary, new ScanEpisode());
                    }

                    Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[secondary].FilePath =
                        episodeDetails.FilePath;
                    Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[secondary].Secondary =
                        true;
                    Scan[seriesName].Seasons[episodeDetails.SeasonNumber].Episodes[secondary].SecondaryTo
                        = episodeDetails.EpisodeNumber;
                }
            }

            var findList =
                (from s in MediaPathDBFactory.GetMediaPathTvUnsorted()
                 where s.PathAndFileName == episodeDetails.FilePath
                 select s).ToList();

            foreach (var path in findList)
            {
                MediaPathDBFactory.GetMediaPathTvUnsorted().Remove(path);
            }
        }