Commit adbeefe0 authored by Benjamin Adolphi's avatar Benjamin Adolphi Committed by Felix Paul Kühne

Filter files displayed by the FTP server browser

Unlike other server browsers, the FTP server browser displays all files that are found in a certain folder, which includes files that cannot be played by VLC like metadata files or subtitles. This commit implements filtering of displayed files so that only playable video and audio files are displayed.

In addition, this commit also fixes a bug where when a server browser implements the subtitleURL property, the VLCServerBrowsingController would not use the URL.
Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <>
(cherry picked from commit 75c03362)
(cherry picked from commit 04305f03bcc5f2bdd5fc95800d7b50928a051220)
parent b50e950a
......@@ -24,10 +24,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCNetworkServerBrowserItemFTP : NSObject <VLCNetworkServerBrowserItem>
- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL;
- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL subtitleURL:(NSURL *)subtitleURL;
@property (nonatomic, readwrite) NSArray<id<VLCNetworkServerBrowserItem>> *items;
@property (nonatomic, getter=isDownloadable, readonly) BOOL downloadable;
@property (nonatomic, readonly, nullable) NSURL *subtitleURL;
......@@ -12,6 +12,7 @@
#import "VLCNetworkServerBrowserFTP.h"
#import "WhiteRaccoon.h"
#import "NSString+SupportedMedia.h"
@interface VLCNetworkServerBrowserFTP () <WRRequestDelegate>
@property (nonatomic) NSURL *url;
......@@ -91,9 +92,22 @@
#pragma mark - white raccoon delegation
- (NSURL*)searchSubtitleForFile:(NSString *)filename inSubtitleList:(NSArray *)subtitleList
NSString *filenameNoExt = [[filename lastPathComponent] stringByDeletingPathExtension];
for (NSString *subtitle in subtitleList) {
if ([[[subtitle lastPathComponent] stringByDeletingPathExtension] isEqualToString:filenameNoExt])
return [self.url URLByAppendingPathComponent:subtitle];
return nil;
- (void)requestCompleted:(WRRequest *)request
if (request == _FTPListDirRequest) {
NSMutableArray *subtitleList = [[NSMutableArray alloc] init];
NSMutableArray *filteredList = [[NSMutableArray alloc] init];
NSArray *rawList = [(WRRequestListDirectory*)request filesInfo];
NSUInteger count = rawList.count;
......@@ -151,7 +165,7 @@
@implementation VLCNetworkServerBrowserItemFTP
@synthesize name = _name, container = _container, fileSizeBytes = _fileSizeBytes, URL = _URL;
- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL
- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL subtitleURL:(NSURL *)subtitleURL
self = [super init];
if (self) {
......@@ -166,6 +180,7 @@
_container = [dict[(id)kCFFTPResourceType] intValue] == 4;
_fileSizeBytes = dict[(id)kCFFTPResourceSize];
_URL = [baseURL URLByAppendingPathComponent:_name];
_subtitleURL = subtitleURL;
return self;
......@@ -171,7 +171,7 @@
NSString *URLofSubtitle = nil;
NSURL *remoteSubtitleURL = nil;
if ([loopItem respondsToSelector:@selector(subtitleURL)]) {
[loopItem subtitleURL];
remoteSubtitleURL = [loopItem subtitleURL];
if (remoteSubtitleURL == nil) {
NSArray *subtitlesList = [self _searchSubtitle:loopItem.URL.lastPathComponent];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment