浏览代码

plex: clean and remove of duplicate functions

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
(cherry picked from commit 86c8d1ca9b76adecd11b727516fbf35f81f30b41)
Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Pierre SAGASPE 10 年之前
父节点
当前提交
7367889685

+ 4 - 4
Sources/VLCLocalPlexFolderListViewController.m

@@ -277,7 +277,7 @@
         ObjList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
         ObjList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
         NSString *URLofSubtitle = nil;
         NSString *URLofSubtitle = nil;
         if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
         if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
-            URLofSubtitle = [_PlexParser getFileSubtitleFromPlexServer:ObjList modeStream:YES];
+            URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:ObjList modeStream:YES];
 
 
         NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[[ObjList objectAtIndex:0] objectForKey:@"keyMedia"]]];
         NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[[ObjList objectAtIndex:0] objectForKey:@"keyMedia"]]];
         if (itemURL) {
         if (itemURL) {
@@ -313,7 +313,7 @@
         mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
         mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
         NSString *URLofSubtitle = nil;
         NSString *URLofSubtitle = nil;
         if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
         if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
-            URLofSubtitle = [_PlexParser getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
+            URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
 
 
         NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"]]];
         NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"]]];
         if (itemURL) {
         if (itemURL) {
@@ -352,7 +352,7 @@
     NSString *tag = [[ObjList objectAtIndex:0] objectForKey:@"state"];
     NSString *tag = [[ObjList objectAtIndex:0] objectForKey:@"state"];
     NSString *cellStatusLbl = nil;
     NSString *cellStatusLbl = nil;
 
 
-    NSInteger status = [_PlexParser MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag authentification:_PlexAuthentification];
+    NSInteger status = [_PlexWebAPI MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag authentification:_PlexAuthentification];
 
 
     if (status == 200) {
     if (status == 200) {
         if ([tag isEqualToString:@"watched"]) {
         if ([tag isEqualToString:@"watched"]) {
@@ -396,7 +396,7 @@
     NSInteger size = [[[ObjList objectAtIndex:0] objectForKey:@"size"] integerValue];
     NSInteger size = [[[ObjList objectAtIndex:0] objectForKey:@"size"] integerValue];
     if (size  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
     if (size  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
         if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
         if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
-            [_PlexParser getFileSubtitleFromPlexServer:ObjList modeStream:NO];
+            [_PlexWebAPI getFileSubtitleFromPlexServer:ObjList modeStream:NO];
 
 
         [self _downloadFileFromMediaItem:ObjList];
         [self _downloadFileFromMediaItem:ObjList];
         [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
         [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];

+ 3 - 3
Sources/VLCPlexMediaInformationViewController.m

@@ -121,7 +121,7 @@
         mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:@""];
         mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:@""];
         NSString *URLofSubtitle = nil;
         NSString *URLofSubtitle = nil;
         if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
         if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
-            URLofSubtitle = [_PlexParser getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
+            URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
 
 
         NSURL *itemURL = [NSURL URLWithString:[_PlexWebAPI urlAuth:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"] autentification:_PlexAuthentification]];
         NSURL *itemURL = [NSURL URLWithString:[_PlexWebAPI urlAuth:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"] autentification:_PlexAuthentification]];
         if (itemURL) {
         if (itemURL) {
@@ -140,7 +140,7 @@
     NSInteger size = [[[mutableMediaObject objectAtIndex:0] objectForKey:@"size"] integerValue];
     NSInteger size = [[[mutableMediaObject objectAtIndex:0] objectForKey:@"size"] integerValue];
     if (size  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
     if (size  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
         if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
         if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
-            [_PlexParser getFileSubtitleFromPlexServer:mutableMediaObject modeStream:NO];
+            [_PlexWebAPI getFileSubtitleFromPlexServer:mutableMediaObject modeStream:NO];
 
 
         [self _downloadFileFromMediaItem:mutableMediaObject];
         [self _downloadFileFromMediaItem:mutableMediaObject];
     } else {
     } else {
@@ -181,7 +181,7 @@
     NSString *ratingKey = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"ratingKey"];
     NSString *ratingKey = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"ratingKey"];
     NSString *tag = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"state"];
     NSString *tag = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"state"];
 
 
-    NSInteger status = [_PlexParser MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag authentification:_PlexAuthentification];
+    NSInteger status = [_PlexWebAPI MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag authentification:_PlexAuthentification];
     if (status == 200) {
     if (status == 200) {
         if ([tag isEqualToString:@"watched"]) {
         if ([tag isEqualToString:@"watched"]) {
             tag = @"unwatched";
             tag = @"unwatched";

+ 0 - 2
Sources/VLCPlexParser.h

@@ -14,7 +14,5 @@
 
 
 - (NSMutableArray *)PlexMediaServerParser:(NSString *)adress port:(NSString *)port navigationPath:(NSString *)navPath authentification:(NSString *)auth;
 - (NSMutableArray *)PlexMediaServerParser:(NSString *)adress port:(NSString *)port navigationPath:(NSString *)navPath authentification:(NSString *)auth;
 - (NSMutableArray *)PlexExtractDeviceInfo:(NSData *)data;
 - (NSMutableArray *)PlexExtractDeviceInfo:(NSData *)data;
-- (NSInteger)MarkWatchedUnwatchedMedia:(NSString *)adress port:(NSString *)port videoRatingKey:(NSString *)ratingKey state:(NSString *)state authentification:(NSString *)auth;
-- (NSString *)getFileSubtitleFromPlexServer:(NSMutableArray *)mutableMediaObject modeStream:(BOOL)modeStream;
 
 
 @end
 @end

+ 0 - 59
Sources/VLCPlexParser.m

@@ -11,7 +11,6 @@
 
 
 #import "VLCPlexParser.h"
 #import "VLCPlexParser.h"
 #import "VLCPlexWebAPI.h"
 #import "VLCPlexWebAPI.h"
-#import "UIDevice+VLC.h"
 #import "VLCAlertView.h"
 #import "VLCAlertView.h"
 #import "VLCConstants.h"
 #import "VLCConstants.h"
 
 
@@ -194,62 +193,4 @@
     }
     }
 }
 }
 
 
-#pragma mark - API
-
-- (NSInteger)MarkWatchedUnwatchedMedia:(NSString *)adress port:(NSString *)port videoRatingKey:(NSString *)ratingKey state:(NSString *)state authentification:(NSString *)auth
-{
-    NSString *url = nil;
-
-    if ([state isEqualToString:@"watched"])
-        url = [NSString stringWithFormat:@"http://%@%@/:/unscrobble?identifier=com.plexapp.plugins.library&key=%@", adress, port, ratingKey];
-    else
-        url = [NSString stringWithFormat:@"http://%@%@/:/scrobble?identifier=com.plexapp.plugins.library&key=%@", adress, port, ratingKey];
-
-    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[[[VLCPlexWebAPI alloc] init] urlAuth:url autentification:auth]] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:20];
-    NSURLResponse *response = nil;
-    NSError *error = nil;
-    [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
-
-    NSInteger httpStatus = [(NSHTTPURLResponse *)response statusCode];
-
-    if (httpStatus != 200)
-        APLog(@"Mark Watched Unwatched Media Error status: %ld at URL : %@", (long)httpStatus, url);
-
-    return httpStatus;
-}
-
-- (NSString *)getFileSubtitleFromPlexServer:(NSMutableArray *)mutableMediaObject modeStream:(BOOL)modeStream
-{
-    NSString *FileSubtitlePath = nil;
-    NSString *fileName = [[[[mutableMediaObject objectAtIndex:0] objectForKey:@"namefile"] stringByDeletingPathExtension] stringByAppendingPathExtension:[[mutableMediaObject objectAtIndex:0] objectForKey:@"codecSubtitle"]];
-
-    VLCPlexWebAPI *PlexWebAPI = [[VLCPlexWebAPI alloc] init];
-    NSURL *url = [[NSURL alloc] initWithString:[PlexWebAPI urlAuth:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"] autentification:[[mutableMediaObject objectAtIndex:0] objectForKey:@"authentification"]]];
-
-    NSData *receivedSub = [NSData dataWithContentsOfURL:url];
-
-    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
-        NSArray *searchPaths =  nil;
-        if (modeStream)
-            searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-        else
-            searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-
-        NSString *directoryPath = [searchPaths objectAtIndex:0];
-        FileSubtitlePath = [directoryPath stringByAppendingPathComponent:fileName];
-        NSFileManager *fileManager = [NSFileManager defaultManager];
-        if (![fileManager fileExistsAtPath:FileSubtitlePath]) {
-            [fileManager createFileAtPath:FileSubtitlePath contents:nil attributes:nil];
-            if (![fileManager fileExistsAtPath:FileSubtitlePath])
-                APLog(@"file creation failed, no data was saved");
-        }
-        [receivedSub writeToFile:FileSubtitlePath atomically:YES];
-    } else {
-        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), fileName, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil];
-        [alert show];
-    }
-
-    return FileSubtitlePath;
-}
-
 @end
 @end