Inheritance: ChapterExtractor
Exemple #1
0
        public static List<ChapterInfo> ReadPgcListFromFile(string file)
        {
            ChapterExtractor ex = null;
            string fileLower = file.ToLower();
            if (fileLower.EndsWith("txt"))
            ex = new TextExtractor();
            else if (fileLower.EndsWith("xpl"))
            ex = new XplExtractor();
            else if (fileLower.EndsWith("ifo"))
            ex = new Ifo2Extractor();
            else if (fileLower.EndsWith("mpls"))
            ex = new MplsExtractor();
            else if (fileLower.EndsWith("xml"))
            throw new Exception("Format not yet supported.");
            else if (fileLower.EndsWith("chapters"))
            {
            List<ChapterInfo> ret = new List<ChapterInfo>();
            ret.Add(ChapterInfo.Load(file));
            return ret;
            }
            else
            {
            throw new Exception("The selected file is not a recognized format.");
            }

            return ex.GetStreams(file);
        }
Exemple #2
0
        public override List <ChapterInfo> GetStreams(string location)
        {
            string path = Path.Combine(location, "VIDEO_TS");

            if (!Directory.Exists(path))
            {
                throw new FileNotFoundException("The VIDEO_TS folder was not found on the DVD.");
            }

            List <ChapterInfo> streams = new List <ChapterInfo>();

            Ifo2Extractor ex = new Ifo2Extractor();

            ex.StreamDetected += (sender, args) => OnStreamDetected(args.ProgramChain);
            ex.ChaptersLoaded += (sender, args) => OnChaptersLoaded(args.ProgramChain);


            string videoIFO = Path.Combine(path, "VIDEO_TS.IFO");

            if (File.Exists(videoIFO))
            {
                byte[] bytRead = new byte[4];
                long   VMG_PTT_STPT_Position = IfoUtil.ToFilePosition(IfoUtil.GetFileBlock(videoIFO, 0xC4, 4));
                int    titlePlayMaps         = IfoUtil.ToInt16(IfoUtil.GetFileBlock(videoIFO, VMG_PTT_STPT_Position, 2));
                //string longestIfo = GetLongestIFO(videoTSDir);
                for (int currentTitle = 1; currentTitle <= titlePlayMaps; ++currentTitle)
                {
                    long   titleInfoStart      = 8 + ((currentTitle - 1) * 12);
                    int    titleSetNumber      = IfoUtil.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 6L, 1)[0];
                    int    titleSetTitleNumber = IfoUtil.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 7L, 1)[0];
                    string vtsIFO = Path.Combine(path, string.Format("VTS_{0:D2}_0.IFO", titleSetNumber));
                    if (!File.Exists(vtsIFO))
                    {
                        Trace.WriteLine(string.Format("VTS IFO file missing: {0}", Path.GetFileName(vtsIFO)));
                        continue;
                    }
                    streams.Add(ex.GetStreams(vtsIFO)[0]);
                }
            }
            else
            {
                Trace.WriteLine("VIDEO_TS.IFO file is missing missing on the DVD.");
                //read all the ifo files
                foreach (string file in Directory.GetFiles(path, "VTS_*_0.IFO"))
                {
                    ChapterInfo pgc = ex.GetStreams(file)[0];
                    pgc.SourceName = Path.GetFileNameWithoutExtension(file);
                    streams.Add(pgc);
                }
            }

            streams = streams.OrderByDescending(p => p.Duration).ToList();

            OnExtractionComplete();
            return(streams);
        }
        public override List<ChapterInfo> GetStreams(string location)
        {
            string path = Path.Combine(location, "VIDEO_TS");

              if (!Directory.Exists(path))
            throw new FileNotFoundException("The VIDEO_TS folder was not found on the DVD.");

              List<ChapterInfo> streams = new List<ChapterInfo>();

              Ifo2Extractor ex = new Ifo2Extractor();
              ex.StreamDetected += (sender, args) => OnStreamDetected(args.ProgramChain);
              ex.ChaptersLoaded += (sender, args) => OnChaptersLoaded(args.ProgramChain);

              string vol = Pathing.VolumeInfo.GetVolumeLabel(new DirectoryInfo(location));

              string videoIFO = Path.Combine(path, "VIDEO_TS.IFO");
              if (File.Exists(videoIFO))
              {
            byte[] bytRead = new byte[4];
            long VMG_PTT_STPT_Position = IfoUtil.ToFilePosition(IfoUtil.GetFileBlock(videoIFO, 0xC4, 4));
            int titlePlayMaps = IfoUtil.ToInt16(IfoUtil.GetFileBlock(videoIFO, VMG_PTT_STPT_Position, 2));
            //string longestIfo = GetLongestIFO(videoTSDir);
            for (int currentTitle = 1; currentTitle <= titlePlayMaps; ++currentTitle)
            {
              long titleInfoStart = 8 + ((currentTitle - 1) * 12);
              int titleSetNumber = IfoUtil.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 6L, 1)[0];
              int titleSetTitleNumber = IfoUtil.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 7L, 1)[0];
              string vtsIFO = Path.Combine(path, string.Format("VTS_{0:D2}_0.IFO", titleSetNumber));
              if (!File.Exists(vtsIFO))
              {
            Trace.WriteLine(string.Format("VTS IFO file missing: {0}", Path.GetFileName(vtsIFO)));
            continue;
              }
              var pgc = ex.GetStreams(vtsIFO)[0];
              if (string.IsNullOrEmpty(vol)) pgc.VolumeName = vol;
              streams.Add(pgc);
            }
              }
              else
              {
            Trace.WriteLine("VIDEO_TS.IFO file is missing missing on the DVD.");
            //read all the ifo files
            foreach (string file in Directory.GetFiles(path, "VTS_*_0.IFO"))
            {
              ChapterInfo pgc = ex.GetStreams(file)[0];
              pgc.SourceName = Path.GetFileNameWithoutExtension(file);
              if (!string.IsNullOrEmpty(vol)) pgc.VolumeName = vol;
              streams.Add(pgc);
            }
              }

              streams = streams.OrderByDescending(p => p.Duration).ToList();

              OnExtractionComplete();
              return streams;
        }
 public void GetStreamsTest()
 {
     Ifo2Extractor ex = new Ifo2Extractor();
       ex.GetStreams(@"D:\Dev\ChapterGrabber\Nacho.IFO");
 }