Ejemplo n.º 1
0
 public static void ShowOnScreenKeyboard(IMeedioSystem MeedioSystem, IMeedioMessage Message, string Title, string PreText, bool Log, StreamWriter swWriteLog)
 {
     try
     {
         Message = MeedioSystem.NewMessage("osk.show");
         Message["text"] = PreText;
         Message["required"] = true;
         Message["title"] = Title;
         Message.Send();
     }
     catch (Exception e)
     {
         
         LogEntry(Log, swWriteLog, "[MeedioUtils] - Error launching on screen keyboard." + e);
     }
     return;
 }
        internal static void CreateBluRayIsoFullDisc(PluginClass pluginClass, string ISOName, string CurDir, string DataDirectory, IMeedioSystem MeedioSystem, IMeedioMessage Message)
        {
            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Creating disc image...", 0, .05, "center", pluginClass.vAlign, 10);
            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping Blu-Ray to ISO file");
            string TempMovieDir = Path.Combine(DataDirectory, ISOName);
            if (!Directory.Exists(TempMovieDir))
            {
                Directory.CreateDirectory(TempMovieDir);
            }
            string ISOFile = Path.Combine(TempMovieDir, ISOName + ".iso");
            string AnyTool2Path = (CurDir + "\\Anytool2.exe");

            //IF ANYDVD IS RUNNING, CREATE ISO WITH ANYDVD
            if (DVDUtils.IsAnyDVDRunning() == true)
            {
                DVDUtils.CreateISOwAnyDVD(AnyTool2Path, ISOFile, pluginClass.Drive, pluginClass.Log, pluginClass.swWriteLog);
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping Blu-Ray to ISO file with AnyDVD Ripper");
                while (!File.Exists(ISOFile))
                {
                    //wait for file to be created
                }
                SystemUtils.WaitForFileToStopGrowing(ISOFile, 30000);
            }
            //IF ANYDVD IS NOT RUNNING, CREATE ISO WITH IMGBURN
            if (DVDUtils.IsAnyDVDRunning() == false)
            {
                DVDUtils.CreateISOwIMGBURN(pluginClass.PathToImgBurn, ISOFile, pluginClass.Drive, "", pluginClass.Log, pluginClass.swWriteLog);
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping Blu-Ray to ISO file with ImgBurn");
            }

            //MOVE MOVIE FILE TO NETWORK ON NEW THREAD
            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Moving file to movie folder...", 0, .05, "center", pluginClass.vAlign, 10);
            PluginClass.argumentstruct MoveFileArguments = new PluginClass.argumentstruct(MeedioSystem, Message, ISOFile, pluginClass.newDir, TempMovieDir, pluginClass.BRTitle3, CurDir, pluginClass.Log, pluginClass.swWriteLog);
            ParameterizedThreadStart paramthreadstart = new ParameterizedThreadStart(obj => MediaFileMovers.MoveToMovieDir(pluginClass, obj));
            Thread MoveFileThread = new Thread(paramthreadstart);
            MoveFileThread.Start(MoveFileArguments);
        }
        internal static bool FindSupportPrograms(PluginClass pluginClass, IMeedioSystem MeedioSystem, IMeedioMessage Message)
        {
            //ESTABLISH REQUIRED SUPPORTING PROGRAMS
            string DataDirectory = MeedioUtils.GetPluginDataDir(pluginClass.PluginName, pluginClass.PluginType);
            List<string> ProgramList = new List<string>();
            if (pluginClass.DVDTVOptions == "Backup individual episodes as MKV files"
                || pluginClass.DVDMovieOptions == "Backup main movie as H264/MKV file")
            {
                ProgramList.Add("vcdmount.exe");
                ProgramList.Add("handbrakecli.exe");
            }
            if (pluginClass.BRTVOptions == "Backup disc as one ISO file"
                || pluginClass.BRMovieOptions == "Backup disc as one ISO file"
                && DVDUtils.IsAnyDVDRunning() == false)
            {
                ProgramList.Add("imgburn.exe");
            }
            if (pluginClass.BRTVOptions == "Backup individual episodes as ISO files"
                || pluginClass.BRMovieOptions == "Backup main movie as ISO file")
            {
                ProgramList.Add("imgburn.exe");
            }
            if (pluginClass.BRTVOptions == "Backup individual episodes as M2TS files"
                || pluginClass.BRMovieOptions == "Backup main movie as ISO file"
                || pluginClass.BRMovieOptions == "Backup main movie as M2TS file")
            {
                ProgramList.Add("tsmuxer.exe");
                ProgramList.Add("eac3to.exe");
            }

            foreach (string p in ProgramList)
            {
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Required program: " + p);
            }

            //READ TXT FILE FOR PROGRAM LISTING
            if (File.Exists(Path.Combine(DataDirectory, "SupportPrograms.txt")))
            {
                if (GetSupportProgramPath(pluginClass) != "")
                {
                    MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Searching for required programs...");
                    SupportPrograms.SearchForSupportPrograms(ProgramList, DataDirectory, pluginClass.Log, pluginClass.swWriteLog);
                    GetSupportProgramPath(pluginClass);
                }
            }

            //CREATE TXT FILE AND SEARCH FOR PROGRAMS
            if (!File.Exists(Path.Combine(DataDirectory, "SupportPrograms.txt")))
            {
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Searching for required programs...");
                SupportPrograms.SearchForSupportPrograms(ProgramList, DataDirectory, pluginClass.Log, pluginClass.swWriteLog);
                string MissingProgram = GetSupportProgramPath(pluginClass);
                if (GetSupportProgramPath(pluginClass) != "")
                {
                    //NOTIFY MISSING PROGRAM WITH DIALOG BOX
                    string Description = ("Please install " + MissingProgram + ". Program cannot continue.");
                    MeedioUtils.ShowDialogBox(MeedioSystem, Message, "Required Program Missing", Description, "", "", "", pluginClass.Log, pluginClass.swWriteLog);
                    PluginClass.mre.WaitOne(); //Pause and wait
                    PluginClass.mre.Reset();   //Reset thread wait
                    return false;
                }
            }
            return true;
        }
        //START MEEDIO PLUGIN THREAD
        public bool OnMessage(IMeedioSystem meedioSystem, IMeedioMessage message)
        {
            if (message.IsPluginLoaded())
            {
                meedioSystem.AddSubjectMask("disk.inserted");
                return true;
            }

            if (message.SubjectIs("disk.inserted") && dInsert == true)
            {

                dInsert = false;
                IDelay = false;
                RunCount = RunCount + 1;

                mainargumentstruct DvdIdArguments = new mainargumentstruct(meedioSystem, message);

                var parameterizedthreadstart = new ParameterizedThreadStart(obj => CoreThread.RunDVDIDMainThread(this, obj));

                mainthread = new Thread(parameterizedthreadstart);

                mainthread.Start(DvdIdArguments);

                return true;

            }

            //CODE TO RUN IF DISC IS INSERTED WHILE IMPORT DELAY IS RUNNING
            if (message.SubjectIs("disk.inserted") && dInsert == false && IDelay == true)
            {
                dInsert = false;
                IDelay = false;
                RunCount = RunCount + 1;

                try
                {
                    //wait for previous disc thread to end
                    mainthread.Join();

                    //Process new disc
                    mainargumentstruct DVDIDarguments = new mainargumentstruct(meedioSystem, message);
                    ParameterizedThreadStart parameterizedthreadstart = new ParameterizedThreadStart(obj => CoreThread.RunDVDIDMainThread(this, obj));
                    mainthread = new Thread(parameterizedthreadstart);
                    mainthread.Start(DVDIDarguments);
                    return true;
                }
                catch (Exception)
                {
                }
                return true;
            }

            if (message.SubjectIs("dialogbox.event.yes"))
            {
                tvShow = true;
                ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Dialog box message: " + message.Subject);
                ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Dialog box indicates TV episodes");
                mre.Set();  //Resume main code
                return true;
            }

            if (message.SubjectIs("dialogbox.event.no"))
            {
                tvShow = false;
                ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Dialog box message: " + message.Subject);
                ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Dialog box indicates movie dvd");
                mre.Set();  //Resume main code
                return true;
            }

            if (message.SubjectIs("osk.ok") || message.SubjectIs("osk.*"))
            {
                DVDTitle = (message["text"] as string);
                BRTitle3 = (message["text"] as string);
                ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - On screen keyboard message: " + message.Subject);
                ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Manually typed name: " + DVDTitle);
                mre.Set();  //Resume main code
                return true;
            }

            //PASTE MOVIE DIRECTORY TO CLIPBOARD FOR EXTERNAL PROGRAMS TO USE PATH
            //Clipboard.SetText(newDir);
            if (message.IsPluginClosing())
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                return true;
            }

            return true;
        }
 public mainargumentstruct(IMeedioSystem p1, IMeedioMessage p2)
 {
     MeedioSystem = p1;
     Message = p2;
 }
 public argumentstruct(IMeedioSystem p1, IMeedioMessage p2, string p3, string p5, string p6, string p7, string p8, bool p9, StreamWriter p10)
 {
     MeedioSystem = p1;
     Message = p2;
     MovieFile = p3;
     MovieDirectory = p5;
     TempMovieDir = p6;
     ProperMovieName = p7;
     CurDir = p8;
     Log = p9;
     swWriteLog = p10;
 }
 public static void ShowPopUpScreen(string PluginDirectory, IMeedioSystem MeedioSystem, IMeedioMessage Message, string caption, double Width, double Height, string HAlign, string VAlign, Int32 Time)
 {
     if (VAlign != "")
     {
         string PopUpScreenPath = Path.Combine(PluginDirectory, "PopUp.screen");
         IMeedioScreen PopUp = MeedioSystem.NewPopupScreen(PopUpScreenPath, null, Width, Height, HAlign, VAlign);
         PopUp.Data["caption"] = caption;
         PopUp.AutoCloseTime = Time;
         PopUp.Show();
     }
 }
 public static void ShowDialogBox(IMeedioSystem MeedioSystem, IMeedioMessage Message, string caption, string description, string dialogtype, string yescaption, string nocaption, bool Log, StreamWriter swWriteLog)
 {
     try
     {
         Message = MeedioSystem.NewMessage("dialogbox.show");
         Message["caption"] = caption;
         Message["description"] = description;
         //Message["height"] = "500";
         //Message["width"] = "500";
         //Message["align"] = "center";
         Message["dialog-type"] = dialogtype; // "yes/no" or "okcancel" or "information" or blank for OK button only
         if (dialogtype == "yes/no" && yescaption != "" && nocaption != "")
         {
             Message["yes-caption"] = yescaption;
             Message["no-caption"] = nocaption;
         }
         Message.Send();
         ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MeedioUtils] - Launching dialog box");
     }
     catch (Exception e)
     {
         ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MeedioUtils] - Error launching dialog box." + e);
     }
     return;
 }
        internal static bool PerformBluRayDiscTasks(PluginClass pluginClass, IMeedioSystem MeedioSystem, string CurDir, IMeedioMessage Message, string DataDirectory)
        {
            ///////////////////////BLU-RAY CODE//////////////////////
            if (pluginClass.BRMovieOptions != "Do not process movies" || pluginClass.BRTVOptions != "Do not process TV series" || pluginClass.CreateFolder != "Do Not Create Folder")
            {
                if (Directory.Exists(pluginClass.Drive + ":\\BDMV"))
                {
                    //IF BLURAY, GET MOVIE NAME FROM META XML FILE ON DISC
                    pluginClass.BRTitle3 = DVDUtils.GetBluRayTitle(pluginClass.Drive);
                    if (pluginClass.BRTitle3 != "")
                    {
                        MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Blu-Ray identified as " + pluginClass.BRTitle3,
                                                            0, .05, "center", pluginClass.vAlign, 10);
                    }

                    //IF NAME IS NOT FOUND, PROMPT USER FOR MOVIE NAME
                    bool manualTitle = false;
                    if (pluginClass.BRTitle3 == "" && pluginClass.PromptForName == true)
                    {
                        MeedioUtils.ShowOnScreenKeyboard(MeedioSystem, Message, "Please enter title", "", pluginClass.Log, pluginClass.swWriteLog);
                        PluginClass.mre.WaitOne(); //Pause and wait
                        PluginClass.mre.Reset(); //Reset thread wait
                        if (pluginClass.BRTitle3 != "")
                        {
                            manualTitle = true;
                        }
                    }

                    ///////////////////////BLU-RAY TV CODE//////////////////////
                    if (pluginClass.BRTVOptions != "Do not process TV series")
                    {
                        //DETERMINE IF BLU-RAY MIGHT CONTAIN TV EPISODES
                        String TVServerDirectory = "";
                        pluginClass.SeriesName = pluginClass.BRTitle3;
                        pluginClass.tvShow = DVDUtils.IsTVSeries(pluginClass.SeriesName, pluginClass.Log, pluginClass.swWriteLog);

                        if (pluginClass.tvShow == true)
                        {
                            //CONFIRM DVD IS TV SERIES WITH DIALOG BOX
                            string Description = (pluginClass.SeriesName +
                                                  " has been identified as a disc that may contain television episodes.  Please confirm if this is a TV or Movie DVD.");
                            MeedioUtils.ShowDialogBox(MeedioSystem, Message, "Please confirm disc type", Description,
                                                              "yes/no", "TV Series", "Movie", pluginClass.Log, pluginClass.swWriteLog);
                            PluginClass.mre.WaitOne(); //Pause and wait
                            PluginClass.mre.Reset(); //Reset thread wait

                            if (pluginClass.tvShow == true)
                            {
                                //SHOW ON SCREEN KEYBOARD AND CONFIRM SEASON NUMBER
                                string SeasonNumber = DVDUtils.GetSeasonNumber(pluginClass.D2, pluginClass.Log, pluginClass.swWriteLog);
                                MeedioUtils.ShowOnScreenKeyboard(MeedioSystem, Message, "Please confirm season number",
                                                                         SeasonNumber, pluginClass.Log, pluginClass.swWriteLog);
                                PluginClass.mre.WaitOne(); //Pause and wait
                                PluginClass.mre.Reset(); //Reset thread wait
                                string SeasonNumforFileName = pluginClass.BRTitle3.Trim().PadLeft(2, '0');
                                SeasonNumber = "Season " + pluginClass.BRTitle3.Trim().PadLeft(2, '0');

                                //SHOW ON SCREEN KEYBOARD AND CONFIRM DISC NUMBER
                                string DiscNumber = DVDUtils.GetSeasonDiscNumber(pluginClass.D2, pluginClass.Log, pluginClass.swWriteLog);
                                MeedioUtils.ShowOnScreenKeyboard(MeedioSystem, Message, "Please confirm disc number",
                                                                         DiscNumber, pluginClass.Log, pluginClass.swWriteLog);
                                PluginClass.mre.WaitOne(); //Pause and wait
                                PluginClass.mre.Reset(); //Reset thread wait
                                string DiscNumberforFileName = pluginClass.BRTitle3.Trim().PadLeft(2, '0');
                                DiscNumber = pluginClass.BRTitle3.Trim();

                                string SeriesforFileName = StringFunctions.replaceIllegalCharacters(pluginClass.SeriesName, " ");
                                string FileName = SeriesforFileName + " S" + SeasonNumforFileName + "D" + DiscNumberforFileName;
                                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Series name: " + pluginClass.SeriesName);

                                //CREATE DIRECTORY ON SERVER
                                pluginClass.SeriesName = (pluginClass.SeriesName + "\\" + SeasonNumber).Trim();
                                TVServerDirectory = DirectoryCreator.CreateDirectory(pluginClass, pluginClass.SeriesName, "", "", "TV");
                                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                             "[MAIN CODE] - TV server directory: " + TVServerDirectory);

                                //CREATE BLU-RAY ISO - FULL DISC
                                if (pluginClass.BRTVOptions == "Backup disc as one ISO file")
                                {
                                    DiscIsoCreators.CreateBluRayIsoFullDisc(pluginClass, FileName, CurDir, DataDirectory, MeedioSystem,
                                                                            Message);
                                }

                                //
                                //
                                //NEED CODE TO:
                                //"Backup individual episodes as ISO files";
                                //
                                //

                                //
                                //
                                //NEED CODE TO:
                                //"Backup individual episodes as M2TS files";
                                //
                                //

                                // EJECT DVD
                                if (pluginClass.EjectDvd == true)
                                {
                                    try
                                    {
                                        DVDUtils.MCICDROM.Eject(pluginClass.D2);
                                    }
                                    catch (Exception e)
                                    {
                                        MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                                     "[MAIN CODE] - Error on OnMessage: " + e.ToString());
                                    }
                                }
                            }

                            //OPTIONAL DELAY TO ALLOW TIME FOR ANOTHER DISC INSERT
                            if (pluginClass.ImportDelay != "0")
                            {
                                if (pluginClass.RunImportDelay(CurDir, MeedioSystem) == true)
                                {
                                    return true;
                                }
                            }

                            //RUN TV IMPORTS
                            if (pluginClass.importTVModule != "" && Directory.Exists(TVServerDirectory))
                            {
                                //RUN IF DIRECTORY IS NOT EMPTY
                                String[] fileEntries = Directory.GetFiles(TVServerDirectory, "*.*", SearchOption.AllDirectories);
                                int numFiles = fileEntries.Length;
                                if (numFiles > 0)
                                {
                                    if (numFiles > 1)
                                    {
                                        MeedioUtils.RunImports(pluginClass.importTVModule, MeedioSystem, pluginClass.Log, pluginClass.swWriteLog);
                                    }
                                }
                            }
                        }
                    }

                    ///////////////////////GENERAL MOVIE CODE//////////////////////
                    if (pluginClass.tvShow == false)
                    {
                        //GET YEAR FROM BRDISC FILE CREATION DATE
                        String BRPlaylistDirectory = (pluginClass.Drive + ":\\BDMV\\PLAYLIST");
                        String[] BRPlaylistFiles = Directory.GetFiles(BRPlaylistDirectory, "*.MPLS", SearchOption.AllDirectories);
                        String BRYear = "";
                        foreach (string f in BRPlaylistFiles)
                        {
                            try
                            {
                                DateTime BRDate = File.GetCreationTime(Path.GetFullPath(f));
                                int intYear = BRDate.Year;
                                BRYear = Convert.ToString(intYear);
                                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Year from file: " + BRYear);
                                break;
                            }
                            catch
                            {
                            }
                        }

                        //GET IMDb BASED ON NAME & YEAR
                        try
                        {
                            pluginClass.MovieIMDbID = "";
                            pluginClass.MovieIMDbID = ImdbIdentifier.GetIMDBID(pluginClass, pluginClass.BRTitle3, "", "", BRYear, "");
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - IMDb ID: " + pluginClass.MovieIMDbID);
                        }
                        catch (Exception e)
                        {
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                         "[MAIN CODE] - Get IMDBID - Error on OnMessage: " + e.ToString());
                        }

                        //GET IMDB TITLE IF TITLE WAS MANUALLY ENTERED
                        if (pluginClass.MovieIMDbID != "" && manualTitle == true)
                        {
                            pluginClass.BRTitle3 = ImdbIdentifier.GetIMDBTITLE(pluginClass.MovieIMDbID);
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                         "[MAIN CODE] - Manually entered name adjusted to IMDb title: " + pluginClass.BRTitle3);
                        }

                        //CREATE NEW DIRECTORY FOR BLU-RAY
                        pluginClass.newDir = DirectoryCreator.CreateDirectory(pluginClass, pluginClass.BRTitle3, "", pluginClass.MovieIMDbID, "BR");

                        //SAVE MOVIE POSTER TO FOLDER
                        if (pluginClass.MoviePoster != "Do Not Save Movie Poster")
                        {
                            if (pluginClass.MovieIMDbID == "" || pluginClass.MovieIMDbID == null)
                            {
                                pluginClass.MovieIMDbID = "No IMDB";
                            }
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Searching for movie poster...",
                                                                0, .05, "center", pluginClass.vAlign, 10);
                            List<string> urlList = ImpAwards.GetPoster(pluginClass.BRTitle3, BRYear, "Both", pluginClass.Log, pluginClass.swWriteLog);
                            pluginClass.GetDVDCover(urlList, pluginClass.BRTitle3, "No DVDID", pluginClass.MovieIMDbID, pluginClass.newDir);
                        }
                    }

                    ///////////////////////BLU-RAY MOVIE CODE//////////////////////
                    if (pluginClass.BRMovieOptions != "Do not process movies" && pluginClass.tvShow == false)
                    {
                        //RUN EAC3TO AND TSMUXER - OUTPUT M2TS FILE
                        if (pluginClass.BRMovieOptions == "Backup main movie as M2TS file")
                        {
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Creating M2TS file...", 0, .05,
                                                                "center", pluginClass.vAlign, 10);
                            string CleanMovieName = StringFunctions.replaceIllegalCharacters(pluginClass.BRTitle3, " ");
                            string TempMovieDir = Path.Combine(DataDirectory, CleanMovieName);
                            string ContainerFile = Path.Combine(TempMovieDir, CleanMovieName + ".m2ts");

                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Running eac3to and tsMuxeR");
                            TsMuxeR.runTSMuxer(pluginClass.Drive, pluginClass.BRTitle3, DataDirectory, pluginClass.newDir, pluginClass.eac3to, pluginClass.Tsmuxer, pluginClass.DownConvertAudio, pluginClass.PreferLPCM, "M2TS", pluginClass.Log, pluginClass.swWriteLog);

                            //MOVE MOVIE FILE TO NETWORK ON NEW THREAD
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message,
                                                                "Moving file to movie directory...", 0, .05, "center", pluginClass.vAlign,
                                                                10);
                            PluginClass.argumentstruct MoveFileArguments = new PluginClass.argumentstruct(MeedioSystem, Message, ContainerFile, pluginClass.newDir,
                                                                                  TempMovieDir, pluginClass.BRTitle3, CurDir, pluginClass.Log, pluginClass.swWriteLog);
                            ParameterizedThreadStart paramthreadstart =
                                new ParameterizedThreadStart(obj1 => MediaFileMovers.MoveToMovieDir(pluginClass, obj1));
                            Thread MoveFileThread = new Thread(paramthreadstart);
                            MoveFileThread.Start(MoveFileArguments);
                        }

                        //RUN EAC3TO AND TSMUXER - OUTPUT BLU-RAY STRUCTURE FOR ISO
                        if (pluginClass.BRMovieOptions == "Backup main movie as ISO file")
                        {
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Backing up main movie files...",
                                                                0, .05, "center", pluginClass.vAlign, 10);
                            string CleanMovieName = StringFunctions.replaceIllegalCharacters(pluginClass.BRTitle3, " ");
                            string TempMovieDir = Path.Combine(DataDirectory, CleanMovieName);
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Running eac3to and tsMuxeR");
                            TsMuxeR.runTSMuxer(pluginClass.Drive, pluginClass.BRTitle3, DataDirectory, pluginClass.newDir, pluginClass.eac3to, pluginClass.Tsmuxer, pluginClass.DownConvertAudio, pluginClass.PreferLPCM, "BRStructure", pluginClass.Log, pluginClass.swWriteLog);

                            //CREATE ISO FROM TSMUXER BLU-RAY STRUCTURE OUTPUT
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping Blu-Ray to ISO file");
                            if (!Directory.Exists(TempMovieDir))
                            {
                                Directory.CreateDirectory(TempMovieDir);
                            }
                            string ISOFile = Path.Combine(TempMovieDir, CleanMovieName + ".iso");

                            //CREATE ISO WITH IMGBURN
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Creating Blu-Ray image...", 0,
                                                                .05, "center", pluginClass.vAlign, 10);
                            DVDUtils.CreateISOwIMGBURN(pluginClass.PathToImgBurn, ISOFile, "", TempMovieDir, pluginClass.Log, pluginClass.swWriteLog);
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                         "[MAIN CODE] - Ripping Blu-Ray to ISO file with ImgBurn");

                            //MOVE MOVIE FILE TO NETWORK ON NEW THREAD
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message,
                                                                "Moving file to movie directory...", 0, .05, "center", pluginClass.vAlign,
                                                                10);
                            PluginClass.argumentstruct MoveFileArguments = new PluginClass.argumentstruct(MeedioSystem, Message, ISOFile, pluginClass.newDir,
                                                                                  TempMovieDir, pluginClass.BRTitle3, CurDir, pluginClass.Log, pluginClass.swWriteLog);
                            ParameterizedThreadStart paramthreadstart =
                                new ParameterizedThreadStart(obj1 => MediaFileMovers.MoveToMovieDir(pluginClass, obj1));
                            Thread MoveFileThread = new Thread(paramthreadstart);
                            MoveFileThread.Start(MoveFileArguments);
                        }

                        //CREATE BLU-RAY ISO - FULL DISC
                        if (pluginClass.BRMovieOptions == "Backup disc as one ISO file")
                        {
                            string ISOName = StringFunctions.replaceIllegalCharacters(pluginClass.BRTitle3, " ");
                            DiscIsoCreators.CreateBluRayIsoFullDisc(pluginClass, ISOName, CurDir, DataDirectory, MeedioSystem, Message);
                        }

                        //RUN EXTERNAL BLU-RAY PROGRAM
                        if (pluginClass.BRMovieOptions == "Backup with my specifed program" && pluginClass.brProgram != "" && Directory.Exists(pluginClass.newDir))
                        {
                            pluginClass.RunDVDProgram(pluginClass.brProgram, pluginClass.brParameters);
                        }

                        // EJECT DVD
                        if (pluginClass.EjectDvd == true)
                        {
                            try
                            {
                                DVDUtils.MCICDROM.Eject(pluginClass.D2);
                            }
                            catch (Exception e)
                            {
                                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                             "[MAIN CODE] - Error on OnMessage: " + e.ToString());
                            }
                        }

                        //OPTIONAL DELAY TO ALLOW TIME FOR ANOTHER DISC INSERT
                        if (pluginClass.ImportDelay != "0")
                        {
                            if (pluginClass.RunImportDelay(CurDir, MeedioSystem) == true)
                            {
                                return true;
                            }
                        }

                        //RUN IMPORTS
                        if (pluginClass.importModule != "" && Directory.Exists(pluginClass.newDir))
                        {
                            //RUN IF DIRECTORY IS NOT EMPTY
                            String[] fileEntries = Directory.GetFiles(pluginClass.newDir, "*.*", SearchOption.AllDirectories);
                            int numFiles = fileEntries.Length;
                            if (numFiles > 0)
                            {
                                if (numFiles == 1)
                                {
                                    foreach (string f in fileEntries)
                                    {
                                        if (Path.GetExtension(f) != ".jpg")
                                        {
                                            MeedioUtils.RunImports(pluginClass.importModule, MeedioSystem, pluginClass.Log, pluginClass.swWriteLog);
                                        }
                                    }
                                }
                                else
                                {
                                    if (numFiles > 1)
                                    {
                                        MeedioUtils.RunImports(pluginClass.importModule, MeedioSystem, pluginClass.Log, pluginClass.swWriteLog);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return false;
        }
        internal static void PerformDvdMovieTasks(PluginClass pluginClass, string dataDirectory, IMeedioMessage Message, string CurDir,
             IMeedioSystem meedioSystem)
        {
            ///////////////////////DVD MOVIE CODE//////////////////////

            if (pluginClass.DVDMovieOptions == "Do not process movies" || pluginClass.tvShow) return;

            if (pluginClass.DVDMovieOptions == "Backup disc as one ISO file")
            {
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Creating disc image...", 0, .05,
                                                    "center", pluginClass.vAlign, 10);
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping DVD to ISO file");
                string ISOName = StringFunctions.replaceIllegalCharacters(pluginClass.DVDTitle, " ");
                DiscIsoCreators.CreateDvdIsoFullDisc(pluginClass, ISOName, CurDir, dataDirectory);

                //MOVE MOVIE FILE TO NETWORK ON NEW THREAD
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Moving file to movie directory...", 0,
                                                    .05, "center", pluginClass.vAlign, 10);
                string TempMovieDir = Path.Combine(dataDirectory, pluginClass.DVDTitle);
                string ISOFile = Path.Combine(TempMovieDir, ISOName + ".iso");
                PluginClass.argumentstruct MoveFileArguments = new PluginClass.argumentstruct(meedioSystem, Message, ISOFile, pluginClass.newDir, TempMovieDir, pluginClass.DVDTitle, CurDir, pluginClass.Log, pluginClass.swWriteLog);
                ParameterizedThreadStart paramthreadstart =
                    new ParameterizedThreadStart(obj1 => MediaFileMovers.MoveToMovieDir(pluginClass, obj1));
                Thread MoveFileThread = new Thread(paramthreadstart);
                MoveFileThread.Start(MoveFileArguments);
            }

            if (pluginClass.DVDMovieOptions == "Backup main movie as H264/MKV file")
            {
                //CREATE TEMPORARY ISO FOR HANDBRAKE
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping DVD to ISO file");
                string ISOName = StringFunctions.replaceIllegalCharacters(pluginClass.DVDTitle, " ");
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Creating temporary disc image...", 0,
                                                    .05, "center", pluginClass.vAlign, 10);
                DiscIsoCreators.CreateDvdIsoFullDisc(pluginClass, ISOName, CurDir, dataDirectory);

                //LAUNCH THE REMAINING CODE IN A NEW THREAD SO NEW DISC CAN BE RIPPED (handbrake, move, run imports)
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Encoding file with HandBrake...", 0, .05,
                                                    "center", pluginClass.vAlign, 10);
                string TempMovieDir = Path.Combine(dataDirectory, pluginClass.DVDTitle);
                string ISOFile = Path.Combine(TempMovieDir, ISOName + ".iso");
                PluginClass.HBargumentstruct HBArguments = new PluginClass.HBargumentstruct(pluginClass.HandBrake, pluginClass.HandBrakeQuality, pluginClass.vcd, "", pluginClass.HexID, ISOFile,
                                                                    TempMovieDir, pluginClass.newDir, "", pluginClass.Log, pluginClass.swWriteLog, meedioSystem);
                ParameterizedThreadStart HBthreadstart = new ParameterizedThreadStart(pluginClass.RunHandBrake);
                Thread HBThread = new Thread(HBthreadstart);
                HBThread.Start(HBArguments);
            }

            if (pluginClass.DVDMovieOptions == "Backup main movie as MPG file")
            {
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Backing up main movie VOB files");
                string MPGName = StringFunctions.replaceIllegalCharacters(pluginClass.DVDTitle, " ");
                string MPGFile = Path.Combine(dataDirectory, MPGName + ".mpg");
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Backing up main movie as mpg...", 0, .05,
                                                    "center", pluginClass.vAlign, 10);
                DVDUtils.BackUpMainMovieDVDFiles(pluginClass.Drive, dataDirectory, pluginClass.Log, pluginClass.swWriteLog);
                DVDUtils.VOBFilesToMpeg(MPGFile, dataDirectory, pluginClass.Log, pluginClass.swWriteLog);

                //MOVE MOVIE FILE TO NETWORK ON NEW THREAD
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Moving file to movie directory...", 0,
                                                    .05, "center", pluginClass.vAlign, 10);
                PluginClass.argumentstruct MoveFileArguments = new PluginClass.argumentstruct(meedioSystem, Message, MPGFile, pluginClass.newDir, dataDirectory, pluginClass.DVDTitle, CurDir, pluginClass.Log, pluginClass.swWriteLog);
                ParameterizedThreadStart paramthreadstart =
                    new ParameterizedThreadStart(obj1 => MediaFileMovers.MoveToMovieDir(pluginClass, obj1));
                Thread MoveFileThread = new Thread(paramthreadstart);
                MoveFileThread.Start(MoveFileArguments);
            }

            //THE FOLLOWING CODE COPIES, BUT THE IFO FILE NEEDS TO BE ADJUSTED TO PROPERLY ADDRESS VOB FILES
            //if (DVDMovieOptions == "Backup main movie as IFO & VOB files")
            //{
            //    ToolBox.MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Backing up main movie VOB files");
            //    ToolBox.MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Backing up main movie files...", 0, .05, "center", vAlign, 10);
            //    ToolBox.DVDUtils.BackUpMainMovieDVDFiles(Drive, newDir, Log, swWriteLog);
            //}

            if (pluginClass.DVDMovieOptions == "Backup disc as IFO & VOB files")
            {
                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Backing up IFO and VOB files");
                MeedioUtils.ShowPopUpScreen(CurDir, meedioSystem, Message, "Backing up movie files...", 0, .05,
                                                    "center", pluginClass.vAlign, 10);
                DVDUtils.BackUpAllDVDFiles(pluginClass.Drive, pluginClass.newDir, pluginClass.Log, pluginClass.swWriteLog);
            }

            //RUN EXTERNAL DVD PROGRAM
            if (pluginClass.DVDMovieOptions == "Backup with my specifed program" && pluginClass.extProgram != "" && Directory.Exists(pluginClass.newDir))
            {
                pluginClass.RunDVDProgram(pluginClass.extProgram, pluginClass.extParameters);
            }
        }
        internal static bool PerformDvdDiscTasks(PluginClass pluginClass, IMeedioMessage Message, string CurDir, IMeedioSystem MeedioSystem, string DataDirectory)
        {
            //DETERMINE IF DISC IS A DVD
            if (pluginClass.DVDMovieOptions != "Do not process movies" || pluginClass.DVDTVOptions != "Do not process TV series" || pluginClass.CreateFolder != "Do Not Create Folder")
            {
                if (Directory.Exists(pluginClass.Drive + ":\\VIDEO_TS"))
                {
                    //IF DISC IS A REGULAR DVD RUN THE FOLLOWING CODE:
                    pluginClass.AnyDVD(false);

                    //GET DVD DISC ID
                    try
                    {
                        pluginClass.HexID = DVDUtils.GetDVDID(pluginClass.Drive, pluginClass.Log, pluginClass.swWriteLog);
                    }
                    catch (Exception e)
                    {
                        MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error getting DVDID: " + e.ToString());
                    }
                    pluginClass.AnyDVD(true);
                    if (DVDUtils.IsAnyDVDRunning() == true)
                    {
                        MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Waiting for AnyDVD to read disc.");
                        Thread.Sleep(5000); //wait for anydvd to process disc
                    }

                    //CHECK IF DISC IS TV SERIES
                    if (pluginClass.DVDTVOptions != "Do not process TV series")
                    {
                        //GET DVD NAME AND EPISODE NAME FOR TVDB SEARCH
                        try
                        {
                            pluginClass.SeriesName = DVDWebUtils.DVDTitle(pluginClass.HexID, pluginClass.Log, pluginClass.swWriteLog);
                            if (pluginClass.SeriesName.Contains(":"))
                            {
                                int Pos = pluginClass.SeriesName.IndexOf(":");
                                String S2 = pluginClass.SeriesName.Remove(Pos);
                                pluginClass.SeriesName = S2.Trim();
                            }
                        }
                        catch
                        {
                        }
                        //DETERMINE IF DVD MIGHT CONTAIN TV EPISODES
                        pluginClass.tvShow = DVDUtils.IsTVSeries(pluginClass.SeriesName, pluginClass.Log, pluginClass.swWriteLog);
                    }

                    if (DvdTvShowCoreAgent.PerformDvdTvTasks(pluginClass, Message, MeedioSystem, DataDirectory, CurDir)) return true;

                    ///////////////////////GENERAL MOVIE CODE//////////////////////
                    if (pluginClass.tvShow == false)
                    {
                        //GET MOVIE NAME & DIRECTOR & ACTOR
                        try
                        {
                            pluginClass.DVDTitle = DVDWebUtils.DVDTitle(pluginClass.HexID, pluginClass.Log, pluginClass.swWriteLog);
                            pluginClass.DvdDirectors = DVDWebUtils.DVDDirector(pluginClass.HexID, pluginClass.Log, pluginClass.swWriteLog);
                            pluginClass.DVDActors = DVDWebUtils.DVDFirstActor(pluginClass.HexID, pluginClass.Log, pluginClass.swWriteLog);
                            if (pluginClass.DVDTitle != "")
                            {
                                MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message,
                                                                    "DVD identified as " + pluginClass.DVDTitle, 0, .05, "center", pluginClass.vAlign,
                                                                    10);
                            }
                        }
                        catch (Exception e)
                        {
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error on OnMessage: " + e.ToString());
                        }

                        //IF NAME IS NOT FOUND, PROMPT FOR MOVIE NAME
                        bool manualTitle = false;
                        if (pluginClass.DVDTitle == "" && pluginClass.PromptForName == true)
                        {
                            MeedioUtils.ShowOnScreenKeyboard(MeedioSystem, Message, "Please enter movie title", "", pluginClass.Log, pluginClass.swWriteLog);
                            PluginClass.mre.WaitOne(); //Pause and wait for input
                            PluginClass.mre.Reset(); //Reset thread wait
                            if (pluginClass.DVDTitle != "")
                            {
                                manualTitle = true;
                            }
                        }

                        //MATCH MS DIRECTOR AND ACTOR TO IMDB ID
                        if (pluginClass.CreateFolder == "Movie Name.IMDbID" || pluginClass.CreateFolder == "Movie Name.DVDID.IMDbID")
                        {
                            try
                            {
                                pluginClass.MovieIMDbID = "";
                                pluginClass.MovieIMDbID = ImdbIdentifier.GetIMDBID(pluginClass, pluginClass.DVDTitle, pluginClass.DvdDirectors, pluginClass.DVDActors, "", pluginClass.HexID);
                                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - IMDb ID: " + pluginClass.MovieIMDbID);
                            }
                            catch (Exception e)
                            {
                                MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                             "[MAIN CODE] - Get IMDBID - Error on OnMessage: " + e.ToString());
                            }
                        }

                        //GET IMDB TITLE IF TITLE IS MANUALLY ENTERED
                        if (pluginClass.MovieIMDbID != "" && manualTitle == true)
                        {
                            pluginClass.DVDTitle = ImdbIdentifier.GetIMDBTITLE(pluginClass.MovieIMDbID);
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog,
                                                         "[MAIN CODE] - Manually entered name adjusted to IMDb title: " + pluginClass.DVDTitle);
                        }

                        //CREATE NEW DIRECTORY FOR DVD
                        pluginClass.newDir = DirectoryCreator.CreateDirectory(pluginClass, pluginClass.DVDTitle, pluginClass.HexID, pluginClass.MovieIMDbID, "DVD");

                        //SAVE MOVIE POSTER TO FOLDER
                        if (pluginClass.MoviePoster != "Do Not Save Movie Poster")
                        {
                            if (string.IsNullOrEmpty(pluginClass.MovieIMDbID))
                            {
                                pluginClass.MovieIMDbID = "No IMDB";
                            }
                            MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Searching for movie poster...",
                                                                0, .05, "center", pluginClass.vAlign, 10);
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Getting Cover Art");
                            String ReleaseYear = DVDWebUtils.GetReleaseYear(pluginClass.HexID, pluginClass.Log, pluginClass.swWriteLog);
                            List<string> urlList = ImpAwards.GetPoster(pluginClass.DVDTitle, ReleaseYear, "Both", pluginClass.Log, pluginClass.swWriteLog);
                            pluginClass.GetDVDCover(urlList, pluginClass.DVDTitle, pluginClass.HexID, pluginClass.MovieIMDbID, pluginClass.newDir);
                        }
                    }

                    DvdMovieCoreAgent.PerformDvdMovieTasks(pluginClass, DataDirectory, Message, CurDir, MeedioSystem);

                    // EJECT DVD
                    if (pluginClass.EjectDvd == true)
                    {
                        try
                        {
                            DVDUtils.MCICDROM.Eject(pluginClass.D2);
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ejecting DVD: " + pluginClass.Drive);
                        }
                        catch (Exception e)
                        {
                            MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error on OnMessage: " + e.ToString());
                        }
                    }

                    //OPTIONAL DELAY TO ALLOW TIME FOR ANOTHER DISC INSERT
                    if (pluginClass.ImportDelay != "0")
                    {
                        if (pluginClass.RunImportDelay(CurDir, MeedioSystem) == true)
                        {
                            return true;
                        }
                    }

                    //RUN IMPORTS
                    if (pluginClass.importModule != "" && Directory.Exists(pluginClass.newDir))
                    {
                        //RUN IF DIRECTORY IS NOT EMPTY
                        String[] fileEntries = Directory.GetFiles(pluginClass.newDir, "*.*", SearchOption.AllDirectories);
                        int numFiles = fileEntries.Length;
                        if (numFiles > 0)
                        {
                            if (numFiles == 1)
                            {
                                foreach (string f in fileEntries)
                                {
                                    if (Path.GetExtension(f) != ".jpg")
                                    {
                                        MeedioUtils.RunImports(pluginClass.importModule, MeedioSystem, pluginClass.Log, pluginClass.swWriteLog);
                                    }
                                }
                            }
                            else
                            {
                                if (numFiles > 1)
                                {
                                    MeedioUtils.RunImports(pluginClass.importModule, MeedioSystem, pluginClass.Log, pluginClass.swWriteLog);
                                }
                            }
                        }
                    }
                }
            }
            return false;
        }
        internal static bool PerformDvdTvTasks(PluginClass pluginClass, IMeedioMessage Message, IMeedioSystem MeedioSystem,
             string DataDirectory, string CurDir)
        {
            ///////////////////////DVD TV CODE//////////////////////
            if (pluginClass.tvShow == true)
            {
                String TVServerDirectory = "";
                //CONFIRM DVD IS TV SERIES WITH DIALOG BOX
                string Description = (pluginClass.SeriesName +
                                      " has been identified as a disc that may contain television episodes.  Please confirm if this is a TV or Movie DVD.");
                MeedioUtils.ShowDialogBox(MeedioSystem, Message, "Please confirm disc type", Description, "yes/no",
                                                  "TV Series", "Movie", pluginClass.Log, pluginClass.swWriteLog);
                PluginClass.mre.WaitOne(); //Pause and wait for input
                PluginClass.mre.Reset(); //Reset thread wait

                if (pluginClass.tvShow == true)
                {
                    //SHOW ON SCREEN KEYBOARD AND CONFIRM SEASON NUMBER
                    string SeasonNumber = DVDUtils.GetSeasonNumber(pluginClass.D2, pluginClass.Log, pluginClass.swWriteLog);
                    MeedioUtils.ShowOnScreenKeyboard(MeedioSystem, Message, "Please confirm season number", SeasonNumber, pluginClass.Log, pluginClass.swWriteLog);
                    PluginClass.mre.WaitOne(); //Pause and wait for input
                    PluginClass.mre.Reset(); //Reset thread wait
                    string SeasonNumforFileName = pluginClass.DVDTitle.Trim().PadLeft(2, '0');
                    SeasonNumber = "Season " + pluginClass.DVDTitle.Trim().PadLeft(2, '0');

                    //SHOW ON SCREEN KEYBOARD AND CONFIRM DISC NUMBER
                    string DiscNumber = DVDUtils.GetSeasonDiscNumber(pluginClass.D2, pluginClass.Log, pluginClass.swWriteLog);
                    MeedioUtils.ShowOnScreenKeyboard(MeedioSystem, Message, "Please confirm disc number", DiscNumber, pluginClass.Log, pluginClass.swWriteLog);
                    PluginClass.mre.WaitOne(); //Pause and wait for input
                    PluginClass.mre.Reset(); //Reset thread wait
                    string DiscNumberforFileName = pluginClass.DVDTitle.Trim().PadLeft(2, '0');
                    DiscNumber = pluginClass.DVDTitle.Trim();

                    string SeriesforFileName = StringFunctions.replaceIllegalCharacters(pluginClass.SeriesName, " ");
                    string FileName = SeriesforFileName + " S" + SeasonNumforFileName + "D" + DiscNumberforFileName;
                    MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Series name: " + pluginClass.SeriesName);

                    //CREATE DIRECTORY ON SERVER
                    pluginClass.SeriesName = (pluginClass.SeriesName + "\\" + SeasonNumber).Trim();
                    TVServerDirectory = DirectoryCreator.CreateDirectory(pluginClass, pluginClass.SeriesName, "", "", "TV");
                    MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - TV server directory: " + TVServerDirectory);

                    if (pluginClass.DVDTVOptions == "Backup individual episodes as mkv files")
                    {
                        //CREATE TEMPORARY ISO FOR HANDBRAKE
                        String OutputDirectory = "";
                        OutputDirectory = Path.Combine(DataDirectory, pluginClass.SeriesName);
                        if (!Directory.Exists(OutputDirectory))
                        {
                            Directory.CreateDirectory(OutputDirectory);
                        }
                        MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Creating temporary disc image...", 0,
                                                            .05, "center", pluginClass.vAlign, 10);
                        MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Creating temporary ISO file");
                        string ISOFile = Path.Combine(OutputDirectory, FileName + ".iso");
                        string mkisofsPath = (CurDir + "\\mkisofs.exe");
                        DVDUtils.CreateISOwMKISOFS(mkisofsPath, ISOFile, pluginClass.Drive, pluginClass.Log, pluginClass.swWriteLog);

                        //LAUNCH THE REMAINING CODE IN A NEW THREAD SO NEW DISC CAN BE RIPPED (handbrake, move, run imports)
                        MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Encoding file with HandBrake...", 0,
                                                            .05, "center", pluginClass.vAlign, 10);
                        PluginClass.HBargumentstruct HBArguments = new PluginClass.HBargumentstruct(pluginClass.HandBrake, pluginClass.HandBrakeQuality, pluginClass.vcd, "", pluginClass.HexID, ISOFile,
                                                                            OutputDirectory, TVServerDirectory, DiscNumber, pluginClass.Log, pluginClass.swWriteLog, MeedioSystem);
                        ParameterizedThreadStart HBthreadstart = new ParameterizedThreadStart(pluginClass.RunHandBrake);
                        Thread HBThread = new Thread(HBthreadstart);
                        HBThread.Start(HBArguments);
                    }

                    if (pluginClass.DVDTVOptions == "Backup disc as one ISO file")
                    {
                        MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Creating disc image...", 0, .05,
                                                            "center", pluginClass.vAlign, 10);
                        MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping DVD to ISO file");
                        DiscIsoCreators.CreateDvdIsoFullDisc(pluginClass, FileName, CurDir, DataDirectory);

                        //MOVE ISO FILE TO NETWORK ON NEW THREAD
                        MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Moving file to movie directory...",
                                                            0, .05, "center", pluginClass.vAlign, 10);
                        string TempMovieDir = Path.Combine(DataDirectory, FileName);
                        string ISOFile = Path.Combine(TempMovieDir, FileName + ".iso");
                        PluginClass.argumentstruct MoveFileArguments = new PluginClass.argumentstruct(MeedioSystem, Message, ISOFile, TVServerDirectory,
                                                                              TempMovieDir, pluginClass.SeriesName, CurDir, pluginClass.Log, pluginClass.swWriteLog);
                        ParameterizedThreadStart paramthreadstart =
                            new ParameterizedThreadStart(obj1 => MediaFileMovers.MoveToMovieDir(pluginClass, obj1));
                        Thread MoveFileThread = new Thread(paramthreadstart);
                        MoveFileThread.Start(MoveFileArguments);
                    }
                }

                //EJECT DVD
                DVDUtils.MCICDROM.Eject(pluginClass.D2);

                //OPTIONAL DELAY TO ALLOW TIME FOR ANOTHER DISC INSERT
                if (pluginClass.ImportDelay != "0")
                {
                    if (pluginClass.RunImportDelay(CurDir, MeedioSystem) == true)
                    {
                        return true;
                    }
                }

                //RUN TV IMPORTS
                if (pluginClass.importTVModule != "" && Directory.Exists(TVServerDirectory))
                {
                    //RUN IF DIRECTORY IS NOT EMPTY
                    String[] fileEntries = Directory.GetFiles(TVServerDirectory, "*.*", SearchOption.AllDirectories);
                    int numFiles = fileEntries.Length;
                    if (numFiles > 0)
                    {
                        MeedioUtils.RunImports(pluginClass.importTVModule, MeedioSystem, pluginClass.Log, pluginClass.swWriteLog);
                    }
                }
            }
            return false;
        }