internal static void CreateDvdIsoFullDisc(PluginClass pluginClass, string ISOName, string CurDir, string DataDirectory) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Ripping DVD to ISO file"); string TempMovieDir = Path.Combine(DataDirectory, ISOName); if (!Directory.Exists(TempMovieDir)) { Directory.CreateDirectory(TempMovieDir); } string ISOFile = Path.Combine(TempMovieDir, ISOName + ".iso"); string mkisofsPath = (CurDir + "\\mkisofs.exe"); DVDUtils.CreateISOwMKISOFS(mkisofsPath, ISOFile, pluginClass.Drive, pluginClass.Log, pluginClass.swWriteLog); }
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 RunDVDIDMainThread(PluginClass pluginClass, Object obj) { Thread.Sleep(5000); //Wait for drive to read disc to prevent duplicate runs PluginClass.mainargumentstruct arguments = (PluginClass.mainargumentstruct)obj; IMeedioMessage Message = arguments.Message; IMeedioSystem MeedioSystem = arguments.MeedioSystem; bool ProgramsExist = true; pluginClass.NewDirReady = false; string CurDir = MeedioUtils.GetPluginPath(pluginClass.PluginName, pluginClass.PluginType); string DataDirectory = MeedioUtils.GetPluginDataDir(pluginClass.PluginName, pluginClass.PluginType); if (pluginClass.RunCount == 1) //CODE TO RUN ON FIRST PASS ONLY { //SETUP DEBUG LOG if (pluginClass.Log == true) { pluginClass.swWriteLog = MeedioUtils.SetDebugLog(pluginClass.PluginName, pluginClass.PluginType); } //VERIFY THAT SUPPORTING PROGRAMS ARE INSTALLED MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Searching for supporting programs...", 0, .05, "center", pluginClass.vAlign, 10); ProgramsExist = SupportProgramsLocator.FindSupportPrograms(pluginClass, MeedioSystem, Message); //SETUP POPUP DISPLAYS if (pluginClass.DisplayStatus == "Do not display status") pluginClass.vAlign = ""; if (pluginClass.DisplayStatus == "Display status at bottom of screen") pluginClass.vAlign = "bottom"; if (pluginClass.DisplayStatus == "Display status at top of screen") pluginClass.vAlign = "top"; } if (ProgramsExist != true) return; ///////////////////////////////////////PROCESS DISC//////////////////////////////// MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, ""); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Run count: " + pluginClass.RunCount); //GET DRIVE LETTER FROM DISK INSERT NOTIFICATION if (Message.Contains("drive")) { pluginClass.Drive = Message["drive"] as string; pluginClass.D2 = pluginClass.Drive + ":"; //GET DRIVE LETTER PLUS ":" FOR DISK EJECT MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, "Reading drive " + pluginClass.Drive, 0, .05, "center", pluginClass.vAlign, 10); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Reading drive: " + pluginClass.Drive); } if (DvdDiscCoreAgent.PerformDvdDiscTasks (pluginClass, Message, CurDir, MeedioSystem, DataDirectory)) return; if (BluRayDiscCoreAgent.PerformBluRayDiscTasks (pluginClass, MeedioSystem, CurDir, Message, DataDirectory)) return; //RESET COUNT TO AVOID ANYDVD LOOPING if (Message.SubjectIs("disk.inserted") && pluginClass.dInsert == false) { pluginClass.dInsert = true; } }
internal static string GetIMDBID(PluginClass pluginClass, string MovieName, string AMGDirector, string AMGActor, string Year, string DVDID) { String id = ""; IMDbLib newSearch = new IMDbLib("USA"); //Make this a module option IList<IIMDbSearchResult> MovieList = null; IIMDbMovie imdblist = null; List<string> titleList = new List<string>(); MovieList = newSearch.SearchMovies(MovieName); try { for (int i = 0; i < MovieList.Count; i++) { if (i < MovieList.Count) { titleList.Add(MovieList[i].IMDb_ID); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - IMDb Search Results: " + MovieList[i].Title.ToString()); } } if (Year == "") { Year = DVDWebUtils.GetReleaseYear(DVDID, pluginClass.Log, pluginClass.swWriteLog); if (titleList.Count > 1) { foreach (string t in titleList) { imdblist = newSearch.GetMovieDetails(t); String iDir = imdblist.People.GetDirectorString(); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Directors: " + iDir); if (!iDir.ToLower().Contains(AMGDirector.ToLower())) continue; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - " + imdblist.Title + ": " + "Directors Matched"); String iActor = imdblist.People.GetActorsString(false); //true to get roles MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Actors: " + iActor); if (!iActor.ToLower().Contains(AMGActor.ToLower())) continue; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - " + imdblist.Title + ": " + "Actors Matched"); id = imdblist.IMDb_ID; break; } } else { foreach (string t in titleList) { imdblist = newSearch.GetMovieDetails(t); if (imdblist.Title.ToLower() == MovieName.ToLower() || imdblist.Title.ToLower().Contains(MovieName.ToLower()) || MovieName.ToLower().Contains(imdblist.Title.ToLower())) { id = t; } } } } if (Year != "" && id == "") { foreach (string t in titleList) { imdblist = newSearch.GetMovieDetails(t); String sYear2 = imdblist.Year; String sYear = sYear2.Replace("/", "").Trim(); int iYear = Convert.ToInt16(Year); int iYearMinusOne = iYear - 1; int iYearMinusTwo = iYear - 2; String sYearMinusTwo = Convert.ToString(iYearMinusTwo); String sYearMinusOne = Convert.ToString(iYearMinusOne); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Search Year: " + Year); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Search Year: " + sYearMinusOne); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Search Year: " + sYearMinusTwo); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - IMdb Year: " + sYear); if (imdblist.Title.ToLower() == MovieName.ToLower() || imdblist.Title.ToLower().Contains(MovieName.ToLower()) || MovieName.ToLower().Contains(imdblist.Title.ToLower())) { if (sYear == Year || sYear == sYearMinusOne || sYear == sYearMinusTwo) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - " + imdblist.Title + ": " + "Years Matched"); id = imdblist.IMDb_ID; break; } } } } } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Get IMDb 2 - Error on OnMessage: " + e.ToString()); } return id.ToString(); }
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; }
internal static string GetSupportProgramPath(PluginClass pluginClass) { string ProgramInstalled = ""; string DataDirectory = MeedioUtils.GetPluginDataDir(pluginClass.PluginName, pluginClass.PluginType); if (pluginClass.DVDTVOptions == "Backup individual episodes as MKV files" || pluginClass.DVDMovieOptions == "Backup main movie as H264/MKV file") { try { pluginClass.HandBrake = SupportPrograms.GetProgramPath("handbrakecli.exe", DataDirectory); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Path to HandBrake: " + pluginClass.HandBrake); if (pluginClass.HandBrake == "") ProgramInstalled = "HandBrake"; } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error finding HandBrake: " + e.ToString()); ProgramInstalled = "HandBrake"; } try { pluginClass.vcd = SupportPrograms.GetProgramPath("vcdmount.exe", DataDirectory); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Path to Virtual Clone Drive: " + pluginClass.vcd); if (pluginClass.vcd == "") ProgramInstalled = "Virtual Clone Drive"; } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error finding Virtual Clone Drive: " + e.ToString()); ProgramInstalled = "Virtual Clone Drive"; } } if (pluginClass.BRTVOptions == "Backup disc as one ISO file" || pluginClass.BRMovieOptions == "Backup disc as one ISO file" && DVDUtils.IsAnyDVDRunning() == false) { try { pluginClass.PathToImgBurn = SupportPrograms.GetProgramPath("imgburn.exe", DataDirectory); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Path to ImgBurn: " + pluginClass.PathToImgBurn); if (pluginClass.PathToImgBurn == "") ProgramInstalled = "ImgBurn"; } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error finding ImgBurn: " + e.ToString()); ProgramInstalled = "ImgBurn"; } } if (pluginClass.BRTVOptions == "Backup individual episodes as ISO files" || pluginClass.BRMovieOptions == "Backup main movie as ISO file") { try { pluginClass.PathToImgBurn = SupportPrograms.GetProgramPath("imgburn.exe", DataDirectory); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Path to ImgBurn: " + pluginClass.PathToImgBurn); if (pluginClass.PathToImgBurn == "") ProgramInstalled = "ImgBurn"; } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error finding ImgBurn: " + e.ToString()); ProgramInstalled = "ImgBurn"; } } 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") { try { pluginClass.eac3to = SupportPrograms.GetProgramPath("eac3to.exe", DataDirectory); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Path to Eac3To: " + pluginClass.eac3to); if (pluginClass.eac3to == "") ProgramInstalled = "Eac3To"; } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error finding eac3To: " + e.ToString()); ProgramInstalled = "Eac3To"; } try { pluginClass.Tsmuxer = SupportPrograms.GetProgramPath("tsmuxer.exe", DataDirectory); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Path to TsMuxeR: " + pluginClass.Tsmuxer); if (pluginClass.Tsmuxer == "") ProgramInstalled = "TsMuxeR"; } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error finding TsMuxeR: " + e.ToString()); ProgramInstalled = "TsMuxeR"; } } return ProgramInstalled; }
internal static void MoveToTVDir(PluginClass pluginClass, Object obj) { try { PluginClass.TVargumentstruct arguments = (PluginClass.TVargumentstruct)obj; string OutputDirectory = arguments.OutputDirectory; string TVServerDirectory = arguments.TVServerDirectory; bool Log = arguments.Log; StreamWriter swWriteLog = arguments.swWriteLog; IMeedioSystem MeedioSystem = arguments.MeedioSystem; MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Attempting to move TV files."); string[] TVFileList = Directory.GetFiles(OutputDirectory, "*.mkv", SearchOption.AllDirectories); foreach (string f in TVFileList) { string TVFile = Path.GetFullPath(f).ToString(CultureInfo.InvariantCulture); var TVInfo = new FileInfo(TVFile); long tvSize = TVInfo.Length; MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - MKV File Size: " + tvSize); long dirSpace = DriveInfo.DirAvailbleSpace(TVServerDirectory); MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Available Space in Directory: " + dirSpace); if (dirSpace > tvSize) { try { File.Move(TVFile, (TVServerDirectory + "\\" + Path.GetFileName(f))); if (File.Exists(TVFile) && File.Exists(TVServerDirectory + "\\" + Path.GetFileName(f))) { File.Delete(TVFile); } } catch { } } else { MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Not enough space in: " + TVServerDirectory); } } //Delete unneeded directories string DataDirectory = MeedioUtils.GetPluginDataDir(pluginClass.PluginName, pluginClass.PluginType); try { string[] DataFiles = Directory.GetFiles(DataDirectory, "*.*", SearchOption.AllDirectories); foreach (string f in DataFiles) { if (!f.Contains("log") || !f.Contains("SupportPrograms")) { File.Delete(Path.GetFullPath(f)); } } } catch (Exception e) { MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Error trying to delete directories: " + e.ToString()); } try { string[] DataDirs = Directory.GetDirectories(DataDirectory, "*", SearchOption.AllDirectories); foreach (string d in DataDirs) { Directory.Delete(Path.GetFullPath(d)); } } catch (Exception e) { MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Error trying to delete directories: " + e.ToString()); } //RUN TV IMPORTER if (pluginClass.importTVModule != "") { MeedioUtils.RunImports(pluginClass.importTVModule, MeedioSystem, Log, swWriteLog); } } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error trying to move files: " + e.ToString()); } }
internal static void MoveToMovieDir(PluginClass pluginClass, Object obj) { try { var arguments = (PluginClass.argumentstruct)obj; IMeedioSystem MeedioSystem = arguments.MeedioSystem; IMeedioMessage Message = arguments.Message; string MovieFile = arguments.MovieFile; string MovieDirectory = arguments.MovieDirectory; string TempMovieDir = arguments.TempMovieDir; string ProperMovieName = arguments.ProperMovieName; string CurDir = arguments.CurDir; bool Log = arguments.Log; StreamWriter swWriteLog = arguments.swWriteLog; MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Attempting to move movie files."); FileInfo movieInfo = new FileInfo(MovieFile); long movieSize = movieInfo.Length; MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Movie File Size: " + movieSize); long dirSpace = DriveInfo.DirAvailbleSpace(MovieDirectory); MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Available Space in Directory: " + dirSpace); if (dirSpace > movieSize) { try { string fName1 = Path.GetFileName(MovieFile); string fName2 = fName1.Replace("_", " "); File.Move(MovieFile, (MovieDirectory + "\\" + fName2)); if (File.Exists(MovieFile) && File.Exists(MovieDirectory + "\\" + fName2)) { File.Delete(MovieFile); } string DataDirectory = MeedioUtils.GetPluginDataDir(pluginClass.PluginName, pluginClass.PluginType); try { string[] DataFiles = Directory.GetFiles(DataDirectory, "*.*", SearchOption.AllDirectories); foreach (string f in DataFiles) { if (!f.Contains("log") || !f.Contains("SupportPrograms")) { File.Delete(Path.GetFullPath(f)); } } } catch (Exception e) { MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Error trying to delete files: " + e.ToString()); } try { string[] DataDirs = Directory.GetDirectories(DataDirectory, "*", SearchOption.AllDirectories); foreach (string d in DataDirs) { Directory.Delete(Path.GetFullPath(d)); } } catch (Exception e) { MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Error trying to delete directories: " + e.ToString()); } } catch { } } else { MeedioUtils.LogEntry(Log, swWriteLog, "[MAIN CODE] - Not enough space in: " + MovieDirectory); } string Description = (ProperMovieName + " is now available for viewing."); MeedioUtils.ShowPopUpScreen(CurDir, MeedioSystem, Message, Description, 0, .05, "center", pluginClass.vAlign, 10); } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error trying to move files: " + e.ToString()); } }
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 string CreateDirectory(PluginClass pluginClass, string MovieName, string DVDID, string IMDbID, string BRorDVDorTV) { String MovieDir = ""; if (BRorDVDorTV == "TV") { MovieDir = DriveInfo.DirWithMostSpace(pluginClass.TVDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - TV Directory: " + MovieDir); } if (BRorDVDorTV == "DVD") { MovieDir = DriveInfo.DirWithMostSpace(pluginClass.DvdDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - DVD Directory: " + MovieDir); } if (BRorDVDorTV == "BR") { MovieDir = DriveInfo.DirWithMostSpace(pluginClass.BrDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - BluRay Directory: " + MovieDir); } if (pluginClass.CreateFolder != "Do Not Create Folder" && MovieDir != "") { String TD2 = ""; if (StringFunctions.containsIllegalCharacters(pluginClass.DVDIDDivider) == true) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Your selected tag divider is an illegal character. Changing to default \"~\""); TD2 = StringFunctions.replaceIllegalCharacters(pluginClass.DVDIDDivider, "~"); pluginClass.DVDIDDivider = TD2; } if (pluginClass.DVDIDDivider.Length == 0) { TD2 = ("~"); pluginClass.DVDIDDivider = TD2; } String TD3 = ""; if (StringFunctions.containsIllegalCharacters(pluginClass.IMDbIDDivider) == true) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Your selected tag divider is an illegal character. Changing to default \"~\""); TD3 = StringFunctions.replaceIllegalCharacters(pluginClass.IMDbIDDivider, "~"); pluginClass.IMDbIDDivider = TD2; } if (pluginClass.IMDbIDDivider.Length == 0) { TD3 = ("~"); pluginClass.IMDbIDDivider = TD3; } //replace illegal characters in movie name String T2 = ""; if (StringFunctions.containsIllegalCharacters(MovieName) == true && BRorDVDorTV != "TV") { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - " + MovieName + " contains illegal characters. Removing illegal characters."); T2 = StringFunctions.replaceIllegalCharacters(MovieName, " "); MovieName = T2; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Your movie title has been adjusted to: " + MovieName); } try { if (pluginClass.CreateFolder == "Movie Name") { pluginClass.newDir = (MovieDir + "\\" + MovieName); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } if (pluginClass.CreateFolder == "Movie Name.DVDID") { if (DVDID == "") { pluginClass.newDir = (MovieDir + "\\" + MovieName); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } else { pluginClass.newDir = (MovieDir + "\\" + MovieName + pluginClass.DVDIDDivider + DVDID); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } } if (pluginClass.CreateFolder == "Movie Name.IMDbID") { if (IMDbID == "") { pluginClass.newDir = (MovieDir + "\\" + MovieName); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } else { pluginClass.newDir = (MovieDir + "\\" + MovieName + pluginClass.IMDbIDDivider + IMDbID); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } } if (pluginClass.CreateFolder == "Movie Name.DVDID.IMDbID") { if (IMDbID == "" && DVDID == "") { pluginClass.newDir = (MovieDir + "\\" + MovieName); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } if (IMDbID != "" && DVDID == "") { pluginClass.newDir = (MovieDir + "\\" + MovieName + pluginClass.IMDbIDDivider + IMDbID); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } if (IMDbID == "" && DVDID != "") { pluginClass.newDir = (MovieDir + "\\" + MovieName + pluginClass.DVDIDDivider + DVDID); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } if (IMDbID != "" && DVDID != "") { pluginClass.newDir = (MovieDir + "\\" + MovieName + pluginClass.DVDIDDivider + DVDID + pluginClass.IMDbIDDivider + IMDbID); pluginClass.DirExists = false; if (Directory.Exists(pluginClass.newDir)) { pluginClass.DirExists = true; MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory already exists: " + pluginClass.newDir); } if (pluginClass.DirExists == false) { Directory.CreateDirectory(pluginClass.newDir); MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - The following directory was created: " + pluginClass.newDir); } } } } catch (Exception e) { MeedioUtils.LogEntry(pluginClass.Log, pluginClass.swWriteLog, "[MAIN CODE] - Error creating directory: " + e.ToString()); } } return pluginClass.newDir; }
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; }