コード例 #1
0
/// <summary>
/// Creates an SuidLister object and returns it for the calling program.
/// The SuidLister object that is created here can be reused.
/// </summary>
/// <param name="fileList">The FileObjectCollection processed by InfoDump.</param>
/// <returns>The SuidLister with the list of all SUIDs present.</returns>
        public static SuidLister getSuid(FileObjectCollection fileList)
        {
            SuidLister suidLister = new SuidLister();

            foreach (FileObject file in fileList.fileList)
            {
                //to change - actual suid;
                //string suids = "suid";
                // done

                suidLister.addSuid(file);
            }

            //returns suidLister object
            return(suidLister);
        }
コード例 #2
0
        /// <summary>
        /// Creates an SuidLister object and returns it for the calling program.
        /// The SuidLister object that is created here can be reused.
        /// </summary>
        /// <param name="fileList">The FileObjectCollection processed by InfoDump.</param>
        /// <returns>The SuidLister with the list of all SUIDs present.</returns>
        public static SuidLister getSuid(FileObjectCollection fileList)
        {
            SuidLister suidLister = new SuidLister();

              foreach (FileObject file in fileList.fileList)
              {

              //to change - actual suid;
              //string suids = "suid";
              // done

            suidLister.addSuid(file);

              }

            //returns suidLister object
              return suidLister;
        }
コード例 #3
0
        /// <summary>
        /// Processes files to create File Objects for the main tasks of this program.
        /// Every tasks are denoted on each comment lines inside the method.
        /// </summary>
        /// <param name="list">The list that contains the fullpaths of the actual files.</param>
        /// <param name="listname">Name for the FileObjectCollection to be created.</param>
        public void AnalyzeList(List <string> list, string listname = "Various Files")
        {
            FileObjectCollection fileList   = new FileObjectCollection();
            TrackLister          tracklist  = new TrackLister();
            MakeFile             makeFile   = new MakeFile();
            ChapterGenerator     chapterGet = new ChapterGenerator();

            //ProgressState progressState = new ProgressState();

            //fileList.folderPath = path; //Deprecated
            fileList.name = listname; //Deprecated

            progressState.listName = fileList.name;

            analyzeProgress       = 1;
            analyzeProcessPercent = 0;

            foreach (string s in list)
            {
                FileObject file = new FileObject(s);

                analyzeProcessPercent         = analyzeProgress.ToPercentage(list.Count);
                progressState.progressPercent = analyzeProcessPercent;
                progressState.fileName        = file.filename;
                Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

                //Routine after splitting
                //Checks if current backgroundWorker operation is cancelled
                //Stops this program if true
                if (Analyze.backgroundWorker.CancellationPending)
                {
                    return;
                }

                try
                {
                    file = InfoDumper.infoDump(file);
                    if (Program.hasFFmpeg)
                    {
                        file = InfoDumper.ffInfoDump(file);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:\r\n\r\n" + ex.Message, "Error");
                }

                progressState.progressDetail = "Dumping MKV info...";

                Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

                file = chapterGet.chapterDump(file);
                if (!String.IsNullOrEmpty(file.ffInfo))
                {
                    file = chapterGet.mediaDump(file);
                }

                if (!Config.Configure.includeMkvInfoOnFiles)
                {
                    file.mkvInfo = null;
                }

                if (!Config.Configure.includeMediaInfoOnFiles)
                {
                    file.ffInfo = null;
                }

                fileList.addFile(file);

                //For Diagnoses purposes only
                if (Config.Configure.diagnose >= 30)
                {
                    Console.WriteLine("Chapter Atom count: {0}\n", file.chapterAtom.Count, file.mkvInfo);

                    foreach (ChapterAtom chapter in file.chapterAtom)
                    {
                        {
                            Console.WriteLine("File name: {0}\nChapter Number: {2}\nTime Start: {3}\nTime End: {4}\nSuid: {5}\n",
                                              file.filename,
                                              chapter.chapterInfo,
                                              chapter.chapterNum,
                                              chapter.timeStart,
                                              chapter.timeEnd,
                                              chapter.suid);
                        }
                    }
                }

                progressState.progressDetail = "Getting chapters' info...";

                Analyze.backgroundWorker.ReportProgress(progressArg, progressState);


                analyzeProgress++;
            }


            SuidLister suidList = getSuid(fileList);

            progressState.progressDetail = "Creating SUID list...";
            Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

            fileList = tracklist.arrangeTrack(fileList, suidList, this);

            progressState.progressDetail = "Arranging new tracklist for every file...";
            Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

            //For Diagnostic purposes only
            if (Config.Configure.diagnose >= 30)
            {
                foreach (Suid suid in suidList.suidList)
                {
                    {
                        Console.WriteLine("SUID filename: " + suid.fileName);
                        Console.WriteLine("SUID: " + suid.suid);
                        Console.WriteLine("\n");
                    }
                }

                Console.WriteLine("fileList.fileList.Count: " + fileList.fileList.Count + "\n");

                foreach (FileObject file in fileList.fileList)
                {
                    //Console.WriteLine("Merge Argument count: {0}\n", file.mergeArgument.Count);

                    foreach (MergeArgument merge in file.mergeArgument)
                    {
                        Console.WriteLine("Merge Argument:\nFile name: {0}\nTime Code: {1}\nFile Argument: {2}\nChapter Number: {3}\n",
                                          file.filename,
                                          merge.timeCode,
                                          merge.fileName,
                                          merge.chapterNum);
                    }

                    foreach (TimeCode time in file.timeCode)
                    {
                        Console.WriteLine("Time Code Argument: {0}\n", time.timeCode);
                    }

                    foreach (DelArgument del in file.delArgument)
                    {
                        Console.WriteLine("Del Argument: {0}\n", del.fileName);
                    }
                }
            }

            fileLists.Add(fileList);

            if (Config.Configure.doMakeXml)
            {
                makeFile.makeFile(fileList, this);

                progressState.progressDetail = "Dumping XML file...";
                Analyze.backgroundWorker.ReportProgress(progressArg, progressState);
            }

            if (Config.Configure.doMakeScript)
            {
                makeFile.makeXML(fileList, this);

                progressState.progressDetail = "Creating Merge Script...";
                Analyze.backgroundWorker.ReportProgress(progressArg, progressState);
            }
        }
コード例 #4
0
        /// <summary>
        /// Processes files to create File Objects for the main tasks of this program.
        /// Every tasks are denoted on each comment lines inside the method.
        /// </summary>
        /// <param name="list">The list that contains the fullpaths of the actual files.</param>
        /// <param name="listname">Name for the FileObjectCollection to be created.</param>
        /// <param name="processor">The Analyze object for progression report.</param>
        /// <param name="path">The path used as a working directory merge commands.</param>
        /// <param name="totalArguments">Optional. For progress report. The total number of lists to process.</param>
        public void processList(List <string> list, string listname, Analyze processor, string path = "C:\\", int totalArguments = 0)
        {
            FileObjectCollection fileList      = new FileObjectCollection();
            TrackLister          tracklist     = new TrackLister();
            MakeFile             makeFile      = new MakeFile();
            ChapterGenerator     chapterGet    = new ChapterGenerator();
            ProgressState        progressState = new ProgressState();

            fileList.folderPath = path;
            fileList.name       = listname;

            progressState.listName = fileList.name;

            progress       = 1;
            processPercent = 0;

            foreach (string s in list)
            {
                progressState.progressDetail = "Creating file entry...";

                Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                FileObject file = new FileObject(s);

                processPercent = progress.ToPercentage(list.Count);
                progressState.progressPercent = processPercent;
                progressState.fileName        = file.filename;
                Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                //Routine after splitting
                //Checks if current backgroundWorker operation is cancelled
                //Stops this program if true
                if (Analyze.backgroundWorker.CancellationPending)
                {
                    return;
                }

                if (file.extension == ".mkv")
                {
                    try
                    {
                        file = InfoDumper.infoDump(file);
                    }
                    catch (Exception ex)
                    {
                        Program.Message("Error:\r\n\r\n" + ex.Message, "Error");
                    }

                    progressState.progressDetail = "Dumping MKV info...";

                    Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                    file = chapterGet.chapterDump(file);

                    if (!Config.Configure.includeMkvInfoOnFiles)
                    {
                        file.mkvInfo = null;
                    }

                    if (!Config.Configure.includeMediaInfoOnFiles)
                    {
                        file.ffInfo = null;
                    }

                    progressState.progressDetail = "Getting chapters' info...";

                    Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                    fileList.hasMKV = true;
                }

                if (Program.hasFFmpeg)
                {
                    progressState.progressDetail = "Dumping media info...";

                    Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                    try
                    {
                        file = InfoDumper.ffInfoDump(file);
                    }
                    catch (Exception ex)
                    {
                        Program.Message("Error:\r\n\r\n" + ex.Message, "Error");
                    }

                    if (!String.IsNullOrEmpty(file.ffInfo))
                    {
                        file = chapterGet.mediaDump(file);
                    }
                }

                fileList.addFile(file);

                progress++;
            }

            if (fileList.hasMKV)
            {
                SuidLister suidList = CreateSuidLister(fileList);

                progressState.progressDetail = "Creating SUID list...";
                Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                fileList = tracklist.arrangeTrack(fileList, suidList, processor);

                progressState.progressDetail = "Arranging new tracklist for every file...";
                Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);

                //For Diagnostic purposes only
                if (Config.Configure.diagnose >= 30)
                {
                    foreach (Suid suid in suidList.suidList)
                    {
                        {
                            Console.WriteLine("SUID filename: " + suid.fileName);
                            Console.WriteLine("SUID: " + suid.suid);
                            Console.WriteLine("\n");
                        }
                    }

                    Console.WriteLine("fileList.fileList.Count: " + fileList.fileList.Count + "\n");

                    foreach (FileObject file in fileList.fileList)
                    {
                        //Console.WriteLine("Merge Argument count: {0}\n", file.mergeArgument.Count);

                        foreach (MergeArgument merge in file.mergeArgument)
                        {
                            Console.WriteLine("Merge Argument:\nFile name: {0}\nTime Code: {1}\nFile Argument: {2}\nChapter Number: {3}\n",
                                              file.filename,
                                              merge.timeCode,
                                              merge.fileName,
                                              merge.chapterNum);
                        }

                        foreach (TimeCode time in file.timeCode)
                        {
                            Console.WriteLine("Time Code Argument: {0}\n", time.timeCode);
                        }

                        foreach (DelArgument del in file.delArgument)
                        {
                            Console.WriteLine("Del Argument: {0}\n", del.fileName);
                        }
                    }
                }

                if (Config.Configure.doMakeScript)
                {
                    makeFile.makeFile(fileList, processor);

                    progressState.progressDetail = "Creating Merge Script...";
                    Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);
                }
            }

            if (Config.Configure.doMakeXml)
            {
                makeFile.makeXML(fileList, processor);

                progressState.progressDetail = "Dumping XML file...";
                Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState);
            }

            processor.fileLists.Add(fileList);
        }
コード例 #5
0
        /// <summary>
        /// Rearranges chapter tracks to include the inserted external file determined by SUID.
        /// Also determines MergeArguments order.
        /// </summary>
        /// <param name="fileList">The FileObjectCollection processed by ChapterGenerator.</param>
        /// <param name="suid">The SuidLister that contains all SUIDs.</param>
        /// <param name="processor">The Analyze object for progression report.</param>
        /// <returns>The FileObjectCollection with FileObjects that has rearranged chapter tracks.</returns>
        public FileObjectCollection arrangeTrack(FileObjectCollection fileList, SuidLister suid, Analyze processor)
        {
            //string mergeargument = "";

              foreach (FileObject file in fileList.fileList)
              {

            int count = 0;
            string tempFileName = "";
            string tempFullPath = "";

              //First loop to determine which chapters have external suid attached
            foreach (ChapterAtom chaptera in file.chapterAtom)
            {
              foreach (Suid suidi in suid.suidList)
              {

            if (suidi.suid == chaptera.suid)
            {
              chaptera.suidFileName = suidi.fileName;
              chaptera.suidFullPath = suidi.fullPath;

              //Console.WriteLine("SUID match.");
            }

              }

              //mergeargument = mergeargument + chaptera.timeStart + chaptera.timeEnd + chaptera.suidFileName;
            }

              //Second loop that uses index to properly determine which chapter needs to be added as a MergeArgument
            for (int i = 0; i < file.chapterAtom.Count; i++)
            {

              var current = file.chapterAtom[i];

              var previous = current;
              var next = current;

              if (i > 0)
              {
            previous = file.chapterAtom.ElementAt(i - 1);
              }

              if (i < (file.chapterAtom.Count - 1))
              {
            next = file.chapterAtom.ElementAt(i + 1);
              }

              /*
               * Diagnostic purposes only
               *
               * Console.WriteLine("Arrange Track");
               * Console.WriteLine("Current: " + current.suidFileName);
               * Console.WriteLine("Previous: " + previous.suidFileName);
               * Console.WriteLine("Next: " + next.suidFileName);
               * Console.WriteLine("\n");
               * */

              //The following routine should correctly determine when to split the the chapters optimally to insert the external SUID file
              if (current.suidFileName != null)
              {
            file.addMergeArg(current.suidFullPath, current.chapterNum, true);
            if (!file.shouldJoin)
              file.shouldJoin = true;
            if (!fileList.hasOrdered)
              fileList.hasOrdered = true;
            if (!processor.hasOrdered)
              processor.hasOrdered = true;
              }
              else
              {

            string timeCode = "";

              //TimeEnd Split Mode
            if (Config.Configure.splitModeTimeEnd && (next.suidFileName != null || i == file.chapterAtom.Count - 1))
            {
              count++;

              file.splitCount = count;

              timeCode = current.timeEnd;

            //to change, should dynamically change digit format to "ddd"
            // done
              tempFileName = Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix + "-" + count.ToString("D3") + ".mkv";
              tempFullPath = Path.Combine(fileList.folderPath, Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix) + "-" + count.ToString("D3") + ".mkv";

              file.addMergeArg(tempFullPath, current.chapterNum, false, timeCode, tempFileName, file.fullpath);
              if (i != file.chapterAtom.Count - 1)
                file.addTimeCode(timeCode);
              file.addDelArg(tempFullPath, tempFileName);
            }
              //TimeStart Split Mode
            else if (Config.Configure.splitModeTimeStart && (previous.suidFileName != null || i == 0))
            {
              count++;

              file.splitCount = count;

              timeCode = current.timeStart;

              tempFileName = Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix + "-" + count.ToString("D3") + ".mkv";
              tempFullPath = Path.Combine(fileList.folderPath, Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix) + "-" + count.ToString("D3") + ".mkv";

              file.addMergeArg(tempFullPath, current.chapterNum, false, timeCode, tempFileName, file.fullpath);
              if (i > 0)
                file.addTimeCode(timeCode);
              file.addDelArg(tempFullPath, tempFileName);

            }

              }

            }

              }

              return fileList;
        }
コード例 #6
0
        /// <summary>
        /// Rearranges chapter tracks to include the inserted external file determined by SUID.
        /// Also determines MergeArguments order.
        /// </summary>
        /// <param name="fileList">The FileObjectCollection processed by ChapterGenerator.</param>
        /// <param name="suid">The SuidLister that contains all SUIDs.</param>
        /// <param name="processor">The Analyze object for progression report.</param>
        /// <returns>The FileObjectCollection with FileObjects that has rearranged chapter tracks.</returns>
        public FileObjectCollection arrangeTrack(FileObjectCollection fileList, SuidLister suid, Analyze processor)
        {
            //string mergeargument = "";

            foreach (FileObject file in fileList.fileList)
            {
                int    count        = 0;
                string tempFileName = "";
                string tempFullPath = "";


                //First loop to determine which chapters have external suid attached
                foreach (ChapterAtom chaptera in file.chapterAtom)
                {
                    foreach (Suid suidi in suid.suidList)
                    {
                        if (suidi.suid == chaptera.suid)
                        {
                            chaptera.suidFileName = suidi.fileName;
                            chaptera.suidFullPath = suidi.fullPath;

                            //Console.WriteLine("SUID match.");
                        }
                    }

                    //mergeargument = mergeargument + chaptera.timeStart + chaptera.timeEnd + chaptera.suidFileName;
                }


                //Second loop that uses index to properly determine which chapter needs to be added as a MergeArgument
                for (int i = 0; i < file.chapterAtom.Count; i++)
                {
                    var current = file.chapterAtom[i];

                    var previous = current;
                    var next     = current;

                    if (i > 0)
                    {
                        previous = file.chapterAtom.ElementAt(i - 1);
                    }

                    if (i < (file.chapterAtom.Count - 1))
                    {
                        next = file.chapterAtom.ElementAt(i + 1);
                    }

                    /*
                     * Diagnostic purposes only
                     *
                     * Console.WriteLine("Arrange Track");
                     * Console.WriteLine("Current: " + current.suidFileName);
                     * Console.WriteLine("Previous: " + previous.suidFileName);
                     * Console.WriteLine("Next: " + next.suidFileName);
                     * Console.WriteLine("\n");
                     * */

                    //The following routine should correctly determine when to split the the chapters optimally to insert the external SUID file
                    if (current.suidFileName != null)
                    {
                        file.addMergeArg(current.suidFullPath, current.chapterNum, true);
                        if (!file.shouldJoin)
                        {
                            file.shouldJoin = true;
                        }
                        if (!fileList.hasOrdered)
                        {
                            fileList.hasOrdered = true;
                        }
                        if (!processor.hasOrdered)
                        {
                            processor.hasOrdered = true;
                        }
                    }
                    else
                    {
                        string timeCode = "";

                        //TimeEnd Split Mode
                        if (Config.Configure.splitModeTimeEnd && (next.suidFileName != null || i == file.chapterAtom.Count - 1))
                        {
                            count++;

                            file.splitCount = count;

                            timeCode = current.timeEnd;

                            //to change, should dynamically change digit format to "ddd"
                            // done
                            tempFileName = Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix + "-" + count.ToString("D3") + ".mkv";
                            tempFullPath = Path.Combine(fileList.folderPath, Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix) + "-" + count.ToString("D3") + ".mkv";

                            file.addMergeArg(tempFullPath, current.chapterNum, false, timeCode, tempFileName, file.fullpath);
                            if (i != file.chapterAtom.Count - 1)
                            {
                                file.addTimeCode(timeCode);
                            }
                            file.addDelArg(tempFullPath, tempFileName);
                        }
                        //TimeStart Split Mode
                        else if (Config.Configure.splitModeTimeStart && (previous.suidFileName != null || i == 0))
                        {
                            count++;

                            file.splitCount = count;

                            timeCode = current.timeStart;

                            tempFileName = Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix + "-" + count.ToString("D3") + ".mkv";
                            tempFullPath = Path.Combine(fileList.folderPath, Config.Configure.tempfileprefix + file.filenameNoExtension + Config.Configure.tempfilesuffix) + "-" + count.ToString("D3") + ".mkv";

                            file.addMergeArg(tempFullPath, current.chapterNum, false, timeCode, tempFileName, file.fullpath);
                            if (i > 0)
                            {
                                file.addTimeCode(timeCode);
                            }
                            file.addDelArg(tempFullPath, tempFileName);
                        }
                    }
                }
            }

            return(fileList);
        }