More refactor subtitle formats

This commit is contained in:
niksedk 2019-03-17 14:29:46 +01:00
parent 05097ad9d0
commit 2fc8abcc75
5 changed files with 28 additions and 110 deletions

View File

@ -503,13 +503,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
return null;
}
public static SubtitleFormat[] GetBinaryFormats()
public static SubtitleFormat[] GetBinaryFormats(bool batchMode)
{
return new SubtitleFormat[]
{
new Ebu(), new Pac(), new PacUnicode(), new Cavena890(), new Spt(), new CheetahCaption(),
new Chk(), new Ayato(), new CapMakerPlus(), new Captionate(), new Ultech130(), new NciCaption(), new AvidStl(),
new WinCaps32(), new IsmtDfxp(), new Cavena890(), new Spt(), new IaiSub(), new ELRStudioClosedCaption(), new CaptionsInc()
new Ebu() { BatchMode = batchMode }, new Pac() { BatchMode = batchMode }, new PacUnicode(), new Cavena890() { BatchMode = batchMode },
new Spt(), new CheetahCaption(), new TSB4(), new Chk(), new Ayato(), new CapMakerPlus(), new Ultech130(), new NciCaption(),
new AvidStl(), new WinCaps32(), new IsmtDfxp(), new Cavena890(), new Spt(), new Sptx(), new IaiSub(),
new ELRStudioClosedCaption(), new CaptionsInc()
};
}
@ -517,7 +518,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
return new SubtitleFormat[]
{
new DlDd(),new Ted20(), new CapMakerPlus(), new Captionate(),
new DlDd(),new Ted20(), new Captionate(),
new TimeLineAscii(), new TimeLineFootageAscii(), new TimedTextImage(), new FinalCutProImage(),
new SpuImage(), new Dost(), new SeImageHtmlIndex(), new BdnXml()
};

View File

@ -317,7 +317,7 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
foreach (var f in SubtitleFormat.GetBinaryFormats())
foreach (var f in SubtitleFormat.GetBinaryFormats(true))
{
if (f.IsMine(null, fileName))
{
@ -609,7 +609,7 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
foreach (var f in SubtitleFormat.GetBinaryFormats())
foreach (var f in SubtitleFormat.GetBinaryFormats(true))
{
if (f.IsMine(null, fileName))
{
@ -1606,7 +1606,7 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
foreach (var f in SubtitleFormat.GetBinaryFormats())
foreach (var f in SubtitleFormat.GetBinaryFormats(true))
{
if (f.IsMine(null, fileName))
{

View File

@ -104,7 +104,7 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats())
foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats(true))
{
if (binaryFormat.IsMine(null, fileName))
{

View File

@ -17084,7 +17084,7 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
var formats = SubtitleFormat.GetBinaryFormats().Union(SubtitleFormat.GetTextOtherFormats()).Union(new SubtitleFormat[]
var formats = SubtitleFormat.GetBinaryFormats(true).Union(SubtitleFormat.GetTextOtherFormats()).Union(new SubtitleFormat[]
{
new TimeCodesOnly1(),
new TimeCodesOnly2()
@ -17236,111 +17236,28 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
var ebu = new Ebu();
if (ebu.IsMine(null, fileName))
foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats(false))
{
ebu.LoadSubtitle(_subtitleAlternate, null, fileName);
format = ebu;
if (binaryFormat.IsMine(null, fileName))
{
binaryFormat.LoadSubtitle(_subtitleAlternate, null, fileName);
format = binaryFormat;
break;
}
}
}
if (format == null)
{
var pac = new Pac();
if (pac.IsMine(null, fileName))
var lines = FileUtil.ReadAllTextShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)).SplitToLines();
foreach (var f in SubtitleFormat.GetTextOtherFormats())
{
pac.BatchMode = true;
pac.LoadSubtitle(_subtitleAlternate, null, fileName);
format = pac;
}
}
if (format == null)
{
var cavena890 = new Cavena890();
if (cavena890.IsMine(null, fileName))
{
cavena890.LoadSubtitle(_subtitleAlternate, null, fileName);
format = cavena890;
}
}
if (format == null)
{
var spt = new Spt();
if (spt.IsMine(null, fileName))
{
spt.LoadSubtitle(_subtitleAlternate, null, fileName);
format = spt;
}
}
if (format == null)
{
var sptx = new Sptx();
if (sptx.IsMine(null, fileName))
{
sptx.LoadSubtitle(_subtitleAlternate, null, fileName);
format = sptx;
}
}
if (format == null)
{
var cheetahCaption = new CheetahCaption();
if (cheetahCaption.IsMine(null, fileName))
{
cheetahCaption.LoadSubtitle(_subtitleAlternate, null, fileName);
format = cheetahCaption;
}
}
if (format == null)
{
var capMakerPlus = new CapMakerPlus();
if (capMakerPlus.IsMine(null, fileName))
{
capMakerPlus.LoadSubtitle(_subtitleAlternate, null, fileName);
format = capMakerPlus;
}
}
if (format == null)
{
var captionate = new Captionate();
if (captionate.IsMine(null, fileName))
{
captionate.LoadSubtitle(_subtitleAlternate, null, fileName);
format = captionate;
}
}
if (format == null)
{
var ultech130 = new Ultech130();
if (ultech130.IsMine(null, fileName))
{
ultech130.LoadSubtitle(_subtitleAlternate, null, fileName);
format = ultech130;
}
}
if (format == null)
{
var nciCaption = new NciCaption();
if (nciCaption.IsMine(null, fileName))
{
nciCaption.LoadSubtitle(_subtitleAlternate, null, fileName);
format = nciCaption;
}
}
if (format == null)
{
var tsb4 = new TSB4();
if (tsb4.IsMine(null, fileName))
{
tsb4.LoadSubtitle(_subtitleAlternate, null, fileName);
format = tsb4;
}
}
if (format == null)
{
var avidStl = new AvidStl();
if (avidStl.IsMine(null, fileName))
{
avidStl.LoadSubtitle(_subtitleAlternate, null, fileName);
format = avidStl;
if (f.IsMine(lines, fileName))
{
f.LoadSubtitle(_subtitleAlternate, lines, fileName);
format = f;
break;
}
}
}

View File

@ -548,7 +548,7 @@ namespace Nikse.SubtitleEdit.Logic
if (format == null)
{
foreach (var f in SubtitleFormat.GetBinaryFormats())
foreach (var f in SubtitleFormat.GetBinaryFormats(true))
{
if (f.IsMine(null, fileName))
{