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 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 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 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; }