Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheksesang <heksesang@users.sourceforge.net>2011-08-08 02:06:53 +0400
committerheksesang <heksesang@users.sourceforge.net>2011-08-08 02:06:53 +0400
commit9d298421a88940a34e02cc115620757aecdad8bc (patch)
tree8b3ca81999e29566a62c5db957313c1e4e44f866 /src/Subtitles
parent5471777a7952b806434e0c9a959cc08ee648dcaa (diff)
Fixed an issue where the subtitle language for subtitle files would sometimes be incorrectly determined if the subtitle filename contained full stops.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3606 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/Subtitles')
-rw-r--r--src/Subtitles/STS.cpp41
-rw-r--r--src/Subtitles/STS.h1
2 files changed, 42 insertions, 0 deletions
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp
index c15642e1f..429dc4d07 100644
--- a/src/Subtitles/STS.cpp
+++ b/src/Subtitles/STS.cpp
@@ -27,6 +27,7 @@
#include "RealTextParser.h"
#include <fstream>
+#include <regex>
// gathered from http://www.netwave.or.jp/~shikai/shikai/shcolor.htm
@@ -2748,6 +2749,46 @@ void CSimpleTextSubtitle::CreateSegments()
*/
}
+bool CSimpleTextSubtitle::Open(CString videoFn, CString subFn, int charSet, CString name)
+{
+ Empty();
+
+ CWebTextFile f;
+ if(!f.Open(subFn)) {
+ return(false);
+ }
+
+ videoFn.Replace('\\', '/');
+ subFn.Replace('\\', '/');
+ if(name.IsEmpty()) {
+
+ // The filname of the video file
+ CString videoName = videoFn.Left(videoFn.ReverseFind('.')).Mid(videoFn.ReverseFind('/') + 1);
+
+ // The filename of the subtitle file
+ CString subName = subFn.Left(subFn.ReverseFind('.')).Mid(subFn.ReverseFind('/') + 1);
+
+ if (subName.Find(videoName) != -1 && videoName.CompareNoCase(subName) != 0)
+ {
+ name = CString(subName);
+ if(name.Replace(videoName, _T("")) == 1)
+ {
+ name = name.TrimLeft('.');
+ }
+ else
+ {
+ name = _T("Undetermined");
+ }
+ }
+ else
+ {
+ name = _T("Undetermined");
+ }
+ }
+
+ return(Open(&f, charSet, name));
+}
+
bool CSimpleTextSubtitle::Open(CString fn, int CharSet, CString name)
{
Empty();
diff --git a/src/Subtitles/STS.h b/src/Subtitles/STS.h
index e205be8bb..714bb8fbd 100644
--- a/src/Subtitles/STS.h
+++ b/src/Subtitles/STS.h
@@ -309,6 +309,7 @@ public:
void Append(CSimpleTextSubtitle& sts, int timeoff = -1);
+ bool Open(CString videoFn, CString subFn, int charSet, CString name = _T(""));
bool Open(CString fn, int CharSet, CString name = _T(""));
bool Open(CTextFile* f, int CharSet, CString name);
bool Open(BYTE* data, int len, int CharSet, CString name);