Fix issue with last line in some .smi files - thx Rex :)

This commit is contained in:
Nikolaj Olsson 2018-04-10 19:24:37 +02:00
parent bc085a9006
commit c105d40170
2 changed files with 8 additions and 4 deletions

View File

@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (string l in lines) foreach (string l in lines)
sb.AppendLine(l); sb.AppendLine(l);
if (sb.ToString().Contains("</SYNC>")) if (Name == "SAMI" && sb.ToString().Contains("</SYNC>"))
return false; return false;
return base.IsMine(lines, fileName); return base.IsMine(lines, fileName);
@ -265,7 +265,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
int syncEndPos = allInputLower.IndexOf(syncTag, index, StringComparison.Ordinal); int syncEndPos = allInputLower.IndexOf(syncTag, index, StringComparison.Ordinal);
int syncEndPosEnc = allInputLower.IndexOf(syncTagEnc, index, StringComparison.Ordinal); int syncEndPosEnc = allInputLower.IndexOf(syncTagEnc, index, StringComparison.Ordinal);
if ((syncStartPosEnc >= 0 && syncStartPosEnc < syncStartPos) || syncEndPos == -1) if (syncStartPosEnc >= 0 && syncStartPosEnc < syncStartPos || syncEndPos == -1)
syncEndPos = syncEndPosEnc; syncEndPos = syncEndPosEnc;
string text; string text;
@ -318,8 +318,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
while (text.Contains(" ")) while (text.Contains(" "))
text = text.Replace(" ", " "); text = text.Replace(" ", " ");
text = text.Replace("</BODY>", string.Empty).Replace("</SAMI>", string.Empty).TrimEnd(); text = text.Replace("</BODY>", string.Empty).Replace("</SAMI>", string.Empty).TrimEnd();
text = text.Replace("</body>", string.Empty).Replace("</sami>", string.Empty).TrimEnd();
int endSyncPos = text.ToUpper().IndexOf("</SYNC>", StringComparison.Ordinal); int endSyncPos = text.ToUpper().IndexOf("</SYNC>", StringComparison.OrdinalIgnoreCase);
if (text.IndexOf('>') > 0 && (text.IndexOf('>') < endSyncPos || endSyncPos == -1)) if (text.IndexOf('>') > 0 && (text.IndexOf('>') < endSyncPos || endSyncPos == -1))
text = text.Remove(0, text.IndexOf('>') + 1); text = text.Remove(0, text.IndexOf('>') + 1);
text = text.TrimEnd(); text = text.TrimEnd();
@ -327,7 +328,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (text.EndsWith("</sync>", StringComparison.OrdinalIgnoreCase)) if (text.EndsWith("</sync>", StringComparison.OrdinalIgnoreCase))
text = text.Substring(0, text.Length - 7).TrimEnd(); text = text.Substring(0, text.Length - 7).TrimEnd();
if (text.EndsWith("</p>", StringComparison.Ordinal) || text.EndsWith("</P>", StringComparison.Ordinal)) if (text.EndsWith("</p>", StringComparison.Ordinal) || text.EndsWith("</P>", StringComparison.OrdinalIgnoreCase))
text = text.Substring(0, text.Length - 4).TrimEnd(); text = text.Substring(0, text.Length - 4).TrimEnd();
text = RemoveDiv(text).Trim(); text = RemoveDiv(text).Trim();

View File

@ -13,6 +13,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public override bool IsMine(List<string> lines, string fileName) public override bool IsMine(List<string> lines, string fileName)
{ {
if (new SamiModern().IsMine(lines, fileName))
return false;
var text = GetSamiFromAvDicPlayerText(lines); var text = GetSamiFromAvDicPlayerText(lines);
var subtitle = new Subtitle(); var subtitle = new Subtitle();
base.LoadSubtitle(subtitle, text.SplitToLines(), fileName); base.LoadSubtitle(subtitle, text.SplitToLines(), fileName);