Browse Source

fixes #101 - Subtitles for TV

Luke Pulverenti 12 years ago
parent
commit
6cefbdcdbf

+ 11 - 4
MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs

@@ -21,7 +21,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
     /// </summary>
     /// </summary>
     public class FFProbeVideoInfoProvider : BaseFFProbeProvider<Video>
     public class FFProbeVideoInfoProvider : BaseFFProbeProvider<Video>
     {
     {
-        public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IProtobufSerializer protobufSerializer, ILogManager logManager, IServerConfigurationManager configurationManager) 
+        public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IProtobufSerializer protobufSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
             : base(logManager, configurationManager)
             : base(logManager, configurationManager)
         {
         {
             if (isoManager == null)
             if (isoManager == null)
@@ -253,16 +253,23 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
 
 
                 if (string.Equals(extension, ".srt", StringComparison.OrdinalIgnoreCase))
                 if (string.Equals(extension, ".srt", StringComparison.OrdinalIgnoreCase))
                 {
                 {
+                    if (video.VideoType == VideoType.VideoFile)
+                    {
+                        // For video files the subtitle filename must match video filename
+                        if (!string.Equals(Path.GetFileNameWithoutExtension(video.Path), Path.GetFileNameWithoutExtension(file.Path)))
+                        {
+                            continue;
+                        }
+                    }
+
                     streams.Add(new MediaStream
                     streams.Add(new MediaStream
                     {
                     {
-                        Index = startIndex,
+                        Index = startIndex++,
                         Type = MediaStreamType.Subtitle,
                         Type = MediaStreamType.Subtitle,
                         IsExternal = true,
                         IsExternal = true,
                         Path = file.Path,
                         Path = file.Path,
                         Codec = "srt"
                         Codec = "srt"
                     });
                     });
-
-                    startIndex++;
                 }
                 }
             }
             }