Commit 14f364e4 authored by Pierre SAGASPE's avatar Pierre SAGASPE Committed by Felix Paul Kühne

shared local library: add xml file templet

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent c79dcf52
<?xml version = "1.0" encoding="UTF-8" standalone="yes" ?>
<MediaContainer size="%%NB_FILE%%" identifier="org.videolan.vlc-ios" libraryTitle="%%LIB_TITLE%%">
<!-- <Media title="" thumb="" duration="" size="" pathfile=""/> -->
%%FILES%%
</MediaContainer>
\ No newline at end of file
...@@ -31,8 +31,12 @@ ...@@ -31,8 +31,12 @@
UInt64 _contentLength; UInt64 _contentLength;
UInt64 _receivedContent; UInt64 _receivedContent;
} }
@property (nonatomic) VLCHTTPUploaderController *uploadController;
@end @end
@implementation VLCHTTPConnection @implementation VLCHTTPConnection
- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path - (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path
...@@ -131,7 +135,7 @@ ...@@ -131,7 +135,7 @@
NSString *documentRoot = [config documentRoot]; NSString *documentRoot = [config documentRoot];
NSString *relativePath = [filePath substringFromIndex:[documentRoot length]]; NSString *relativePath = [filePath substringFromIndex:[documentRoot length]];
if ([relativePath isEqualToString:@"/index.html"]) { if (([relativePath isEqualToString:@"/index.html"]) || ([relativePath isEqualToString:@"/libMediaVLC.xml"])) {
NSMutableArray *allMedia = [[NSMutableArray alloc] init]; NSMutableArray *allMedia = [[NSMutableArray alloc] init];
/* add all albums */ /* add all albums */
...@@ -170,6 +174,10 @@ ...@@ -170,6 +174,10 @@
} }
NSMutableArray *mediaInHtml = [[NSMutableArray alloc] initWithCapacity:allMedia.count]; NSMutableArray *mediaInHtml = [[NSMutableArray alloc] initWithCapacity:allMedia.count];
NSMutableArray *mediaInXml = [[NSMutableArray alloc] initWithCapacity:allMedia.count];
self.uploadController = [[VLCHTTPUploaderController alloc] init];
NSString *hostName = [self.uploadController hostname];
NSString *pathLibrary =[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *duration; NSString *duration;
for (NSManagedObject *mo in allMedia) { for (NSManagedObject *mo in allMedia) {
...@@ -189,6 +197,9 @@ ...@@ -189,6 +197,9 @@
[[(MLFile *)mo url] stringByReplacingOccurrencesOfString:@"file://"withString:@""], [[(MLFile *)mo url] stringByReplacingOccurrencesOfString:@"file://"withString:@""],
[(MLFile *)mo title], [(MLFile *)mo title],
duration, (float)([(MLFile *)mo fileSizeInBytes] / 1e6)]]; duration, (float)([(MLFile *)mo fileSizeInBytes] / 1e6)]];
[mediaInXml addObject:[NSString stringWithFormat:@"<Media title=\"%@\" thumb=\"http://%@/download/%@/Thumbnails/File/%@.png\" duration=\"%@\" size=\"%li\" pathfile=\"http://%@/download/%@\"/>",
[(MLFile *)mo title], hostName, pathLibrary, [[NSString stringWithFormat:@"%@", mo.objectID.URIRepresentation] lastPathComponent], duration, [(MLFile *)mo fileSizeInBytes],
hostName, [[(MLFile *)mo url] stringByReplacingOccurrencesOfString:@"file://"withString:@""]]];
} }
else if ([mo isKindOfClass:[MLShow class]]) { else if ([mo isKindOfClass:[MLShow class]]) {
NSArray *episodes = [(MLShow *)mo sortedEpisodes]; NSArray *episodes = [(MLShow *)mo sortedEpisodes];
...@@ -223,6 +234,11 @@ ...@@ -223,6 +234,11 @@
showEp.episodeNumber, showEp.episodeNumber,
showEp.name, showEp.name,
duration, (float)([(MLFile *)[[showEp files] anyObject] fileSizeInBytes] / 1e6)]]; duration, (float)([(MLFile *)[[showEp files] anyObject] fileSizeInBytes] / 1e6)]];
[mediaInXml addObject:[NSString stringWithFormat:@"<Media title=\"%@ - S%@E%@\" thumb=\"http://%@/download/%@/Thumbnails/File/%@.png\" duration=\"%@\" size=\"%li\" pathfile=\"http://%@/download/%@\"/>",
[(MLShow *)mo name], showEp.seasonNumber, showEp.episodeNumber,
hostName, pathLibrary, [[NSString stringWithFormat:@"%@", showEp.objectID.URIRepresentation] lastPathComponent], duration,
[(MLFile *)[[showEp files] anyObject] fileSizeInBytes],
hostName, [[(MLFile *)[[showEp files] anyObject] url] stringByReplacingOccurrencesOfString:@"file://"withString:@""]]];
} }
[mediaInHtml addObject:@"</div></div>"]; [mediaInHtml addObject:@"</div></div>"];
} else if ([mo isKindOfClass:[MLLabel class]]) { } else if ([mo isKindOfClass:[MLLabel class]]) {
...@@ -256,6 +272,9 @@ ...@@ -256,6 +272,9 @@
[[file url] stringByReplacingOccurrencesOfString:@"file://"withString:@""], [[file url] stringByReplacingOccurrencesOfString:@"file://"withString:@""],
file.title, file.title,
duration, (float)([file fileSizeInBytes] / 1e6)]]; duration, (float)([file fileSizeInBytes] / 1e6)]];
[mediaInXml addObject:[NSString stringWithFormat:@"<Media title=\"%@\" thumb=\"http://%@/download/%@/Thumbnails/File/%@.png\" duration=\"%@\" size=\"%li\" pathfile=\"http://%@/download/%@\"/>",
file.title, hostName, pathLibrary, [[NSString stringWithFormat:@"%@", file.objectID.URIRepresentation] lastPathComponent], duration, [file fileSizeInBytes],
hostName, [[file url] stringByReplacingOccurrencesOfString:@"file://"withString:@""]]];
} }
[mediaInHtml addObject:@"</div></div>"]; [mediaInHtml addObject:@"</div></div>"];
} else if ([mo isKindOfClass:[MLAlbum class]]) { } else if ([mo isKindOfClass:[MLAlbum class]]) {
...@@ -289,18 +308,28 @@ ...@@ -289,18 +308,28 @@
[[(MLFile *)[[track files] anyObject] url] stringByReplacingOccurrencesOfString:@"file://"withString:@""], [[(MLFile *)[[track files] anyObject] url] stringByReplacingOccurrencesOfString:@"file://"withString:@""],
track.title, track.title,
duration, (float)([(MLFile *)[[track files] anyObject] fileSizeInBytes] / 1e6)]]; duration, (float)([(MLFile *)[[track files] anyObject] fileSizeInBytes] / 1e6)]];
[mediaInXml addObject:[NSString stringWithFormat:@"<Media title=\"%@\" thumb=\"http://%@/download/%@/Thumbnails/File/%@.png\" duration=\"%@\" size=\"%li\" pathfile=\"http://%@/download/%@\"/>",
track.title, hostName, pathLibrary, [[NSString stringWithFormat:@"%@", track.objectID.URIRepresentation] lastPathComponent], duration, [(MLFile *)[[track files] anyObject] fileSizeInBytes],
hostName, [[(MLFile *)[[track files] anyObject] url] stringByReplacingOccurrencesOfString:@"file://"withString:@""]]];
} }
[mediaInHtml addObject:@"</div></div>"]; [mediaInHtml addObject:@"</div></div>"];
} }
} }
NSString *deviceModel = [[UIDevice currentDevice] model]; NSString *deviceModel = [[UIDevice currentDevice] model];
NSDictionary *replacementDict = @{@"FILES" : [mediaInHtml componentsJoinedByString:@" "], NSDictionary *replacementDict;
@"WEBINTF_TITLE" : NSLocalizedString(@"WEBINTF_TITLE", nil),
@"WEBINTF_DROPFILES" : NSLocalizedString(@"WEBINTF_DROPFILES", nil), if ([relativePath isEqualToString:@"/libMediaVLC.xml"]) {
@"WEBINTF_DROPFILES_LONG" : [NSString stringWithFormat:NSLocalizedString(@"WEBINTF_DROPFILES_LONG", nil), deviceModel], replacementDict = @{@"FILES" : [mediaInXml componentsJoinedByString:@" "],
@"WEBINTF_DOWNLOADFILES" : NSLocalizedString(@"WEBINTF_DOWNLOADFILES", nil), @"NB_FILE" : [NSString stringWithFormat:@"%li", (unsigned long)mediaInXml.count],
@"WEBINTF_DOWNLOADFILES_LONG" : [NSString stringWithFormat: NSLocalizedString(@"WEBINTF_DOWNLOADFILES_LONG", nil), deviceModel]}; @"LIB_TITLE" : [[UIDevice currentDevice] name]};
} else
replacementDict = @{@"FILES" : [mediaInHtml componentsJoinedByString:@" "],
@"WEBINTF_TITLE" : NSLocalizedString(@"WEBINTF_TITLE", nil),
@"WEBINTF_DROPFILES" : NSLocalizedString(@"WEBINTF_DROPFILES", nil),
@"WEBINTF_DROPFILES_LONG" : [NSString stringWithFormat:NSLocalizedString(@"WEBINTF_DROPFILES_LONG", nil), deviceModel],
@"WEBINTF_DOWNLOADFILES" : NSLocalizedString(@"WEBINTF_DOWNLOADFILES", nil),
@"WEBINTF_DOWNLOADFILES_LONG" : [NSString stringWithFormat: NSLocalizedString(@"WEBINTF_DOWNLOADFILES_LONG", nil), deviceModel]};
return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path] return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
forConnection:self forConnection:self
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
260B41E11A75006300DA89C9 /* OneDriveWhite@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 260B41DB1A75006300DA89C9 /* OneDriveWhite@3x.png */; }; 260B41E11A75006300DA89C9 /* OneDriveWhite@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 260B41DB1A75006300DA89C9 /* OneDriveWhite@3x.png */; };
265D511C1922746C00E38383 /* VLCLocalPlexFolderListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */; }; 265D511C1922746C00E38383 /* VLCLocalPlexFolderListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */; };
265D511D1922746C00E38383 /* VLCPlexParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 265D511B1922746C00E38383 /* VLCPlexParser.m */; }; 265D511D1922746C00E38383 /* VLCPlexParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 265D511B1922746C00E38383 /* VLCPlexParser.m */; };
26F1BFD01A770408001DF30C /* libMediaVLC.xml in Resources */ = {isa = PBXBuildFile; fileRef = 26F1BFCF1A770408001DF30C /* libMediaVLC.xml */; };
26FAE63919240C2E00A43737 /* PlexServerIcon@1x.png in Resources */ = {isa = PBXBuildFile; fileRef = 26FAE63619240C2E00A43737 /* PlexServerIcon@1x.png */; }; 26FAE63919240C2E00A43737 /* PlexServerIcon@1x.png in Resources */ = {isa = PBXBuildFile; fileRef = 26FAE63619240C2E00A43737 /* PlexServerIcon@1x.png */; };
26FAE63A19240C2E00A43737 /* PlexServerIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 26FAE63719240C2E00A43737 /* PlexServerIcon@2x.png */; }; 26FAE63A19240C2E00A43737 /* PlexServerIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 26FAE63719240C2E00A43737 /* PlexServerIcon@2x.png */; };
29125E5617492219003F03E5 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 29125E5417492219003F03E5 /* index.html */; }; 29125E5617492219003F03E5 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 29125E5417492219003F03E5 /* index.html */; };
...@@ -510,6 +511,7 @@ ...@@ -510,6 +511,7 @@
265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCLocalPlexFolderListViewController.m; path = Sources/VLCLocalPlexFolderListViewController.m; sourceTree = SOURCE_ROOT; }; 265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCLocalPlexFolderListViewController.m; path = Sources/VLCLocalPlexFolderListViewController.m; sourceTree = SOURCE_ROOT; };
265D511A1922746C00E38383 /* VLCPlexParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCPlexParser.h; path = Sources/VLCPlexParser.h; sourceTree = SOURCE_ROOT; }; 265D511A1922746C00E38383 /* VLCPlexParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCPlexParser.h; path = Sources/VLCPlexParser.h; sourceTree = SOURCE_ROOT; };
265D511B1922746C00E38383 /* VLCPlexParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCPlexParser.m; path = Sources/VLCPlexParser.m; sourceTree = SOURCE_ROOT; }; 265D511B1922746C00E38383 /* VLCPlexParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCPlexParser.m; path = Sources/VLCPlexParser.m; sourceTree = SOURCE_ROOT; };
26F1BFCF1A770408001DF30C /* libMediaVLC.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = libMediaVLC.xml; sourceTree = "<group>"; };
26FAE63619240C2E00A43737 /* PlexServerIcon@1x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlexServerIcon@1x.png"; sourceTree = "<group>"; }; 26FAE63619240C2E00A43737 /* PlexServerIcon@1x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlexServerIcon@1x.png"; sourceTree = "<group>"; };
26FAE63719240C2E00A43737 /* PlexServerIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlexServerIcon@2x.png"; sourceTree = "<group>"; }; 26FAE63719240C2E00A43737 /* PlexServerIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlexServerIcon@2x.png"; sourceTree = "<group>"; };
29125E5417492219003F03E5 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; }; 29125E5417492219003F03E5 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; };
...@@ -1454,6 +1456,7 @@ ...@@ -1454,6 +1456,7 @@
29125E5317492219003F03E5 /* web */ = { 29125E5317492219003F03E5 /* web */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
26F1BFCF1A770408001DF30C /* libMediaVLC.xml */,
7D32B383185E293D006CA474 /* Raleway.woff */, 7D32B383185E293D006CA474 /* Raleway.woff */,
7AC8629E1765E90C0011611A /* jquery-1.10.1.min.js */, 7AC8629E1765E90C0011611A /* jquery-1.10.1.min.js */,
7AC8629F1765E90C0011611A /* jquery.fileupload.js */, 7AC8629F1765E90C0011611A /* jquery.fileupload.js */,
...@@ -3005,6 +3008,7 @@ ...@@ -3005,6 +3008,7 @@
7D27EC1919DF30CB00EF0370 /* phone@3x.png in Resources */, 7D27EC1919DF30CB00EF0370 /* phone@3x.png in Resources */,
7D98703A1A3DED4F009CF27D /* resetIcon@3x.png in Resources */, 7D98703A1A3DED4F009CF27D /* resetIcon@3x.png in Resources */,
7DBBF1A5183AB4300009A339 /* VLCMovieViewController~ipad.xib in Resources */, 7DBBF1A5183AB4300009A339 /* VLCMovieViewController~ipad.xib in Resources */,
26F1BFD01A770408001DF30C /* libMediaVLC.xml in Resources */,
7DEB3B7517649F2C0038FC70 /* menuButton.png in Resources */, 7DEB3B7517649F2C0038FC70 /* menuButton.png in Resources */,
7DEB3B7617649F2C0038FC70 /* menuButton@2x.png in Resources */, 7DEB3B7617649F2C0038FC70 /* menuButton@2x.png in Resources */,
7DEB3B791764A4040038FC70 /* input@2x.png in Resources */, 7DEB3B791764A4040038FC70 /* input@2x.png in Resources */,
......
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