Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ChapterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace JarrettVance.ChapterTools
public class ChapterInfo
{
public string Title { get; set; }
public int TitleNumber { get; set; }
public int? ChapterSetId { get; set; }
public String ImdbId { get; set; }
public int? MovieDbId { get; set; }
Expand Down Expand Up @@ -44,7 +45,7 @@ public bool HasNames()

public override string ToString()
{
return string.Format("{0}, {1}, {2} chapter(s)", SourceName, Duration.ToShortString(), Chapters.Count);
return string.Format("Title {0} {1}, {2}, {3} chapter(s) ", TitleNumber, SourceName, Duration.ToShortString(), Chapters.Count);
}

public void ChangeFps(double fps)
Expand Down
109 changes: 55 additions & 54 deletions Extractors/DvdExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,69 @@

namespace JarrettVance.ChapterTools.Extractors
{
public class DvdExtractor : ChapterExtractor
{
public override string[] Extensions
public class DvdExtractor : ChapterExtractor
{
get { return new string[] { }; }
}
public override string[] Extensions
{
get { return new string[] { }; }
}

public override List<ChapterInfo> GetStreams(string location)
{
string path = Path.Combine(location, "VIDEO_TS");
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.");
if (!Directory.Exists(path))
throw new FileNotFoundException("The VIDEO_TS folder was not found on the DVD.");

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

Ifo2Extractor ex = new Ifo2Extractor();
ex.StreamDetected += (sender, args) => OnStreamDetected(args.ProgramChain);
ex.ChaptersLoaded += (sender, args) => OnChaptersLoaded(args.ProgramChain);
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 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);
}
}
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, titleSetTitleNumber);
pgc[0].TitleNumber = currentTitle;
if (string.IsNullOrEmpty(vol)) pgc[0].VolumeName = vol;
streams.Add(pgc[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);
if (!string.IsNullOrEmpty(vol)) pgc.VolumeName = vol;
streams.Add(pgc);
}
}

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

OnExtractionComplete();
return streams;
OnExtractionComplete();
return streams;
}
}
}
}
Loading