Beispiel #1
0
        private MediaPathFileModel CreateTextMediaPathFileModel()
        {
            var mediaPathFileModel = new MediaPathFileModel();

            mediaPathFileModel.PathAndFileName = @"D:\Movies\Toy Story 3\Toy.Story.3.TC.XviD-FLAWL3SS.avi";

            return(mediaPathFileModel);
        }
        public void PathTest()
        {
            var target = new MediaPathFileModel();

            target.PathAndFileName = @"c:\stuff\folder\this is a filename.avi";

            Assert.IsTrue(target.FilenameExt == ".avi");
            Assert.IsTrue(target.FilenameWithOutExt == "this is a filename");
            Assert.IsTrue(target.Path == @"c:\stuff\folder\");
        }
Beispiel #3
0
        /// <summary>
        /// Generatate unsorted list.
        /// </summary>
        /// <param name="progress"></param>
        public static void GeneratateUnsortedList(Progress progress)
        {
            mediaPathTvUnsorted.Clear();
            mediaPathMoviesUnsorted.Clear();


            var count = 0;

            try
            {
                foreach (MediaPathModel mediaPath in MediaPathDB)
                {
                    for (int index = 0; index < mediaPath.FileCollection.Count; index++)
                    {
                        progress.Message = string.Format("Processing {0}", mediaPath.FileCollection[index].PathAndFileName);

                        MediaPathFileModel filePath = mediaPath.FileCollection[index];

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.Movie)
                        {
                            if (new System.IO.FileInfo(filePath.PathAndFileName).Length > Get.InOutCollection.MinimumMovieSize)
                            {
                                if (!MasterMediaDBFactory.MovieDatabaseContains(filePath.PathAndFileName))
                                {
                                    mediaPathMoviesUnsorted.Add(filePath);
                                }
                            }
                        }

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.TV)
                        {
                            if (!MasterMediaDBFactory.TvDatabaseContains(filePath.PathAndFileName))
                            {
                                mediaPathTvUnsorted.Add(filePath);
                            }
                        }

                        count++;

                        var total = (long)MediaPathDB.Sum(pathColletion => pathColletion.FileCollection.Count);

                        progress.Percent = Convert.ToInt32((long)count * 100 / total);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "Could not Generated Unsorted List", ex.Message);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Adds the new entries.
        /// </summary>
        /// <param name="mediaPathModel">
        /// The media path model.
        /// </param>
        /// <param name="files">
        /// The files.
        /// </param>
        private static void AddNewEntries(MediaPathModel mediaPathModel, string[] files)
        {
            if (files == null)
            {
                return;
            }

            foreach (string f in files)
            {
                MediaPathFileModel.MediaPathFileType type = DetectType.FindType(
                    f, mediaPathModel.ContainsTv, mediaPathModel.ContainsMovies);

                AddFolderType importType;

                if (type == MediaPathFileModel.MediaPathFileType.Movie)
                {
                    importType = mediaPathModel.NameFileBy;
                }
                else
                {
                    importType = AddFolderType.NotApplicable;
                }

                MediaPathFileModel obj = MediaPathFileModel.Add(
                    f, type, importType, mediaPathModel.ScraperGroup, mediaPathModel.DefaultSource);

                string f1 = f;

                try
                {
                    var check = mediaPathModel.FileCollection.Any(file => file.PathAndFileName == f1);

                    if (!check)
                    {
                        mediaPathModel.FileCollection.Add(obj);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Generatate unsorted list.
        /// </summary>
        public static void GeneratateUnsortedList()
        {
            mediaPathTvUnsorted.Clear();
            mediaPathMoviesUnsorted.Clear();

            try
            {
                foreach (MediaPathModel mediaPath in MediaPathDB)
                {
                    for (int index = 0; index < mediaPath.FileCollection.Count; index++)
                    {
                        MediaPathFileModel filePath = mediaPath.FileCollection[index];

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.Movie)
                        {
                            if (new System.IO.FileInfo(filePath.PathAndFileName).Length > Get.InOutCollection.MinimumMovieSize)
                            {
                                if (!MasterMediaDBFactory.MovieDatabaseContains(filePath.PathAndFileName))
                                {
                                    mediaPathMoviesUnsorted.Add(filePath);
                                }
                            }
                        }

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.TV)
                        {
                            if (!MasterMediaDBFactory.TvDatabaseContains(filePath.PathAndFileName))
                            {
                                mediaPathTvUnsorted.Add(filePath);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "Could not Generated Unsorted List", ex.Message);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Remove a MediaPathModel from the MediaPathDB
        /// </summary>
        /// <param name="mediaPathModel">The media path model.</param>
        public static void RemoveFromDatabase(MediaPathModel mediaPathModel)
        {
            EnsureMediaPathDatabaseExists();
            // Remove movies from db
            for (int index = 0; index < mediaPathModel.FileCollection.Count; index++)
            {
                MediaPathFileModel filePath = mediaPathModel.FileCollection[index];

                if (filePath.Type == MediaPathFileModel.MediaPathFileType.Movie)
                {
                    string p = filePath.Path.TrimEnd('\\');
                    if (!
                        MovieDBFactory.MovieDatabase.Remove(
                            (from m in MovieDBFactory.MovieDatabase where m.GetBaseFilePath == p select m).
                            SingleOrDefault())
                        )
                    {
                        MovieDBFactory.HiddenMovieDatabase.Remove(
                            (from m in MovieDBFactory.HiddenMovieDatabase where m.GetBaseFilePath == p select m).
                            SingleOrDefault());
                    }
                }

                if (filePath.Type == MediaPathFileModel.MediaPathFileType.TV)
                {
                    if (MasterMediaDBFactory.TvDatabaseContains(filePath.PathAndFileName))
                    {
                        MasterMediaDBFactory.MasterTvMediaDatabase.Remove(filePath.PathAndFileName);
                    }
                }
            }

            // Remove media path
            MediaPathDB.Remove(mediaPathModel);

            // Update master
            MasterMediaDBFactory.PopulateMasterMovieMediaDatabase();
        }