Browse Source

plex: use file name provided by server to store media, not display name

(cherry picked from commit 73d4523610fac33d39b11a9e1513e34babf1a0e4)
Felix Paul Kühne 9 years ago
parent
commit
b5934d335c

+ 1 - 0
SharedSources/ServerBrowsing/Plex/VLCNetworkServerBrowserPlex.h

@@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
 @interface VLCNetworkServerBrowserItemPlex : NSObject <VLCNetworkServerBrowserItem>
 - (instancetype)initWithDictionary:(NSDictionary *)dictionary currentURL:(NSURL *)currentURL authentificication:(NSString *)auth;
 
+@property (nonatomic, readonly, nullable) NSString *filename;
 @property (nonatomic, readonly, nullable) NSString *duration;
 @property (nonatomic, readonly, nullable) NSURL *subtitleURL;
 @property (nonatomic, readonly, nullable) NSURL *thumbnailURL;

+ 1 - 0
SharedSources/ServerBrowsing/Plex/VLCNetworkServerBrowserPlex.m

@@ -190,6 +190,7 @@
 
         _duration = dictionary[@"duration"];
         _fileSizeBytes = dictionary[@"size"];
+        _filename = dictionary[@"namefile"];
 
         NSString *subtitleURLString = dictionary[@"keySubtitle"];
         if (subtitleURLString) {

+ 1 - 0
SharedSources/ServerBrowsing/VLCNetworkServerBrowser-Protocol.h

@@ -47,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, readonly, nullable) NSNumber *fileSizeBytes;
 
 @optional
+@property (nonatomic, readonly, nullable) NSString *filename;
 @property (nonatomic, readonly, nullable) NSString *duration;
 @property (nonatomic, readonly, nullable) NSURL *subtitleURL;
 @property (nonatomic, readonly, nullable) NSURL *thumbnailURL;

+ 6 - 1
SharedSources/ServerBrowsing/VLCServerBrowsingController.m

@@ -253,7 +253,12 @@
 
 - (void)_downloadItem:(id<VLCNetworkServerBrowserItem>)item
 {
-    NSString *filename = item.name;
+    NSString *filename;
+    if ([item respondsToSelector:@selector(filename)])
+        filename = item.filename;
+    else
+        filename = item.name;
+
     if (filename.pathExtension.length == 0) {
         /* there are few crappy UPnP servers who don't reveal the correct file extension, so we use a generic fake (#11123) */
         NSString *urlExtension = item.URL.pathExtension;