Skip to content

Commit

Permalink
MP1-5171: Core: Player update to support MPC-HC subtitle engine 2.0.0…
Browse files Browse the repository at this point in the history
… name format
  • Loading branch information
epbk committed Aug 1, 2023
1 parent 36cf5e8 commit 7574389
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion mediaportal/Core/Player/VideoPlayerVMR7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,35 @@ public override string SubtitleLanguage(int iStream)
if (streamName == null)
{
return Strings.Unknown;
}

//MPC-HC 2.0.0
//"[Local] 4-3 bar test.English-Forced.srt\tEnglish"
Regex regexMPCHC = new Regex(@"\[([^\]]+)\]\s(?<file>[^\t]+)(\t(?<lng>.+))?");
Match match = regexMPCHC.Match(streamName);
if (match.Success)
{
// Group grLng = match.Groups["lng"];
// if (grLng.Success)
// return grLng.Value;
//
// string strVideNoExt = Path.GetFileNameWithoutExtension(this.m_strCurrentFile);
// string strSubNoExt = Path.GetFileNameWithoutExtension(match.Groups["file"].Value);
// if (strVideNoExt.Equals(strSubNoExt, StringComparison.CurrentCultureIgnoreCase))
// return "Undetermined";

string strVideNoExt = Path.GetFileNameWithoutExtension(this.m_strCurrentFile);
string strSubNoExt = Path.GetFileNameWithoutExtension(match.Groups["file"].Value);
if (strSubNoExt.Length > strVideNoExt.Length)
streamName = strSubNoExt.Substring(strVideNoExt.Length + 1);
else
streamName = string.Empty;

if (string.IsNullOrWhiteSpace(streamName))
streamName = strVideNoExt;

langName = streamName;
streamNameUND = streamName;
}

// remove prefix, which is added by Haali Media Splitter
Expand Down Expand Up @@ -1903,7 +1932,25 @@ public override string SubtitleName(int iStream)
if (streamName == null)
{
return Strings.Unknown;
}
}

//MPC-HC 2.0.0
//"[Local] 4-3 bar test.English-Forced.srt\tEnglish"
Regex regexMPCHC = new Regex(@"\[([^\]]+)\]\s(?<file>[^\t]+)(\t(?<lng>.+))?");
Match match = regexMPCHC.Match(streamName);
if (match.Success)
{
string strVideNoExt = Path.GetFileNameWithoutExtension(this.m_strCurrentFile);
string strSubNoExt = Path.GetFileNameWithoutExtension(match.Groups["file"].Value);
if (strSubNoExt.Length > strVideNoExt.Length)
streamName = strSubNoExt.Substring(strVideNoExt.Length + 1);
else
streamName = string.Empty;

streamNameFalse = streamName;
langName = streamName;
}

// remove prefix, which is added by Haali Media Splitter
streamName = Regex.Replace(streamName, @"^S: ", "");

Expand Down

0 comments on commit 7574389

Please sign in to comment.