浏览代码

ftp : displaying subtitles files in browser
(cherry picked from commit 2dc59b1b2c2ebed3795e67315344e91e3f0f15e2)

Pierre SAGASPE 9 年之前
父节点
当前提交
b50e950a36
共有 1 个文件被更改,包括 21 次插入2 次删除
  1. 21 2
      SharedSources/ServerBrowsing/FTP/VLCNetworkServerBrowserFTP.m

+ 21 - 2
SharedSources/ServerBrowsing/FTP/VLCNetworkServerBrowserFTP.m

@@ -100,8 +100,27 @@
 
         for (NSUInteger x = 0; x < count; x++) {
             NSDictionary *dict = rawList[x];
-            if (![[dict objectForKey:(id)kCFFTPResourceName] hasPrefix:@"."])
-                [filteredList addObject:[[VLCNetworkServerBrowserItemFTP alloc] initWithDictionary:dict baseURL:self.url]];
+
+            if ([[dict objectForKey:(id)kCFFTPResourceName] isSupportedSubtitleFormat])
+                [subtitleList addObject:[dict objectForKey:(id)kCFFTPResourceName]];
+        }
+
+        for (NSUInteger x = 0; x < count; x++) {
+            NSDictionary *dict = rawList[x];
+            NSString *filename = [dict objectForKey:(id)kCFFTPResourceName];
+            BOOL container = [[dict objectForKey:(id)kCFFTPResourceType] intValue] == 4;
+
+            if (![filename hasPrefix:@"."])
+            {
+                NSURL *subtitleURL = nil;
+
+                if ([filename isSupportedAudioMediaFormat] || [filename isSupportedMediaFormat])
+                    subtitleURL = [self searchSubtitleForFile:filename inSubtitleList:subtitleList];
+                else if ((!container) && ![filename isSupportedSubtitleFormat])
+                    continue;
+
+                [filteredList addObject:[[VLCNetworkServerBrowserItemFTP alloc] initWithDictionary:dict baseURL:self.url subtitleURL:subtitleURL]];
+            }
         }
         [[NSOperationQueue mainQueue] addOperationWithBlock:^{
             @synchronized(_items) {