Commit c4818954 authored by Pierre SAGASPE's avatar Pierre SAGASPE

plex : back of recovery the subtitles in plex library

(cherry picked from commit 493ad342)
parent eee1802d
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
* VLCNetworkServerBrowserPlex.h * VLCNetworkServerBrowserPlex.h
* VLC for iOS * VLC for iOS
***************************************************************************** *****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved. * Copyright (c) 2015-2018 VideoLAN. All rights reserved.
* $Id$ * $Id$
* *
* Authors: Tobias Conradi <videolan # tobias-conradi.de> * Authors: Tobias Conradi <videolan # tobias-conradi.de>
* Pierre Sagaspe <pierre.sagaspe # me.com>
* *
* Refer to the COPYING file of the official project for license. * Refer to the COPYING file of the official project for license.
*****************************************************************************/ *****************************************************************************/
...@@ -30,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -30,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, nullable) NSString *duration; @property (nonatomic, readonly, nullable) NSString *duration;
@property (nonatomic, readonly, nullable) NSURL *subtitleURL; @property (nonatomic, readonly, nullable) NSURL *subtitleURL;
@property (nonatomic, readonly, nullable) NSURL *thumbnailURL; @property (nonatomic, readonly, nullable) NSURL *thumbnailURL;
@property (nonatomic, readonly, nullable) NSURL *URLcontainer;
@property (nonatomic, getter=isDownloadable, readonly) BOOL downloadable; @property (nonatomic, getter=isDownloadable, readonly) BOOL downloadable;
@end @end
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
* VLCNetworkServerBrowserPlex.m * VLCNetworkServerBrowserPlex.m
* VLC for iOS * VLC for iOS
***************************************************************************** *****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved. * Copyright (c) 2015-2018 VideoLAN. All rights reserved.
* $Id$ * $Id$
* *
* Authors: Tobias Conradi <videolan # tobias-conradi.de> * Authors: Tobias Conradi <videolan # tobias-conradi.de>
* Pierre Sagaspe <pierre.sagaspe # me.com>
* *
* Refer to the COPYING file of the official project for license. * Refer to the COPYING file of the official project for license.
*****************************************************************************/ *****************************************************************************/
...@@ -104,7 +105,16 @@ ...@@ -104,7 +105,16 @@
NSMutableArray *newItems = [NSMutableArray new]; NSMutableArray *newItems = [NSMutableArray new];
for (NSDictionary *dict in dicts) { for (NSDictionary *dict in dicts) {
VLCNetworkServerBrowserItemPlex *item = [[VLCNetworkServerBrowserItemPlex alloc] initWithDictionary:dict currentURL:url authentificication:newAuth]; VLCNetworkServerBrowserItemPlex *item = [[VLCNetworkServerBrowserItemPlex alloc] initWithDictionary:dict currentURL:url authentificication:newAuth];
[newItems addObject:item]; /* warning: we make a http request per item and if the library is big or a weak network, it can slow down the process. */
if (item.URLcontainer) {
NSArray *dictItem = [self.plexParser PlexMediaServerParser:self.plexServerAddress port:self.plexServerPort navigationPath:item.URLcontainer.path authentification:self.plexAuthentification error:&error];
for (NSDictionary *dictx in dictItem) {
item = [[VLCNetworkServerBrowserItemPlex alloc] initWithDictionary:dictx currentURL:url authentificication:newAuth];
[newItems addObject:item];
}
} else {
[newItems addObject:item];
}
} }
NSString *titleValue = firstObject[@"libTitle"]; NSString *titleValue = firstObject[@"libTitle"];
...@@ -168,15 +178,28 @@ ...@@ -168,15 +178,28 @@
if (_container) { if (_container) {
NSString *keyPath = nil; NSString *keyPath = nil;
NSString *keyValue = dictionary[@"key"]; NSString *keyValue = dictionary[@"key"];
if ([keyValue rangeOfString:@"library"].location == NSNotFound) { if ([keyValue rangeOfString:@"library"].location == NSNotFound)
keyPath = [path stringByAppendingPathComponent:keyValue]; keyPath = [path stringByAppendingPathComponent:keyValue];
} else { else
keyPath = keyValue; keyPath = keyValue;
}
if (keyPath) { if (keyPath)
urlPath = [baseURL URLByAppendingPathComponent:keyPath].absoluteString; urlPath = [baseURL URLByAppendingPathComponent:keyPath].absoluteString;
}
} else { } else {
NSString *keyPath = nil;
NSString *keyValue = dictionary[@"key"];
if ([keyValue rangeOfString:@"library"].location == NSNotFound)
keyPath = [path stringByAppendingPathComponent:keyValue];
else
keyPath = keyValue;
if (keyPath)
urlPath = [baseURL URLByAppendingPathComponent:keyPath].absoluteString;
urlPath = [VLCPlexWebAPI urlAuth:urlPath authentification:auth];
_URLcontainer = [NSURL URLWithString:urlPath];
urlPath = dictionary[@"keyMedia"]; urlPath = dictionary[@"keyMedia"];
} }
...@@ -195,11 +218,10 @@ ...@@ -195,11 +218,10 @@
_filename = dictionary[@"namefile"]; _filename = dictionary[@"namefile"];
NSString *subtitleURLString = dictionary[@"keySubtitle"]; NSString *subtitleURLString = dictionary[@"keySubtitle"];
if (subtitleURLString) { if (subtitleURLString)
subtitleURLString = [VLCPlexWebAPI urlAuth:subtitleURLString authentification:auth]; subtitleURLString = [VLCPlexWebAPI urlAuth:subtitleURLString authentification:auth];
}
_subtitleURL = subtitleURLString.length ? [baseURL URLByAppendingPathComponent:subtitleURLString] : nil; _subtitleURL = subtitleURLString.length ? [NSURL URLWithString:subtitleURLString] : nil;
} }
return self; return self;
} }
...@@ -227,4 +249,4 @@ ...@@ -227,4 +249,4 @@
return [[VLCNetworkServerBrowserPlex alloc] initWithName:self.name url:self.URL auth:self.plexAuthentification]; return [[VLCNetworkServerBrowserPlex alloc] initWithName:self.name url:self.URL auth:self.plexAuthentification];
} }
@end @end
\ No newline at end of file
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