Skip to content

Commit

Permalink
2.0b4 - Update EasyNSURLConnection and Anitomy frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
moyitpro committed Mar 24, 2017
1 parent eef583a commit 9cded60
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Detection.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ -(NSDictionary *)detectKodi{
port = @"3005";
}
EasyNSURLConnection * request = [[EasyNSURLConnection alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%@/jsonrpc", address,port]]];
[request startJSONRequest:@"{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \"params\": { \"properties\": [\"title\", \"season\", \"episode\", \"showtitle\", \"tvshowid\", \"thumbnail\", \"file\", \"fanart\", \"streamdetails\"], \"playerid\": 1 }, \"id\": \"VideoGetItem\"}"];
[request startJSONRequest:@"{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \"params\": { \"properties\": [\"title\", \"season\", \"episode\", \"showtitle\", \"tvshowid\", \"thumbnail\", \"file\", \"fanart\", \"streamdetails\"], \"playerid\": 1 }, \"id\": \"VideoGetItem\"}" type:EasyNSURLConnectionJsonType];
if (request.getStatusCode == 200) {
NSDictionary * result;
NSError * error = nil;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// EasyNSURLConnection
//
// Created by 桐間紗路 on 2017/03/03.
// Copyright © 2017 Atelier Shiori. All rights reserved.
// Copyright © 2017 Atelier Shiori. All rights reserved. Licensed under MIT License.
//

#import <Cocoa/Cocoa.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,170 @@
//
// EasyNSURLConnection.h
// MAL Updater OS X
// EasyNSURLConnectionClass.h
//
// Created by Nanoha Takamachi on 2014/11/25.
// Copyright (c) 2014年 Atelier Shiori.
// Copyright (c) 2014年 Atelier Shiori. Licensed under MIT License.
//
// This class allows easy access to NSURLConnection Functions
//

#import <Foundation/Foundation.h>
/**
This defines the body types of a JSON request.
*/
typedef enum JsonType{
/**
This option will set the body type of a JSON request to "application/json".
*/
EasyNSURLConnectionJsonType = 0,
/**
This option will set the body type of a JSON request to "application/vnd.api+json". Some web APIs might require the use of this.
*/
EasyNSURLConnectionvndapiJsonType = 1
} EasyNSURLConnectionJsonTypes;

/**
This constant is used to set the request method to POST
*/
extern NSString * const EasyNSURLPostMethod;
/**
This constant is used to set the request method to PUT
*/
extern NSString * const EasyNSURLPutMethod;
/**
This constant is used to set the request method to PATCH
*/
extern NSString * const EasyNSURLPatchMethod;
/**
This constant is used to set the request method to DELETE
*/
extern NSString * const EasyNSURLDeleteMethod;

@interface EasyNSURLConnection : NSObject{
/**
The user agent of the request. Example: "MAL Updater OS X 2.2.13 (Macintosh; Mac OS X 10.12.3; en_US)"
@see setUserAgent:
*/
NSString * useragent;
/**
The post method of a request. (e.g. POST)
*/
NSString * postmethod;
/**
The request's headers.
*/
NSMutableArray * headers;
/**
The request's form data.
*/
NSMutableArray * formdata;
__weak NSHTTPURLResponse * response;
/**
The request's Response.
*/
__weak NSHTTPURLResponse * response;
/**
The request's response data.
*/
NSData * responsedata;
/**
Contains any errors when executing the request.
*/
__weak NSError * error;
/**
The URL of the request.
*/
NSURL * URL;
/**
States whether or not a request should use cookies or not.
*/
BOOL usecookies;
}
@property(weak) NSURLResponse * response;
@property(weak) NSError * error;
/**
Initalizes a EasyNSURLConnection instance.
@return EasyNSURLConnection An instance of EasyNSURLConnection.
*/
-(id)init;
/**
Initalizes a EasyNSURLConnection instance with a URL.
@param address The URL of a request.
@return EasyNSURLConnection An instance of EasyNSURLConnection.
*/
-(id)initWithURL:(NSURL *)address;
/**
Retruns the data from a response as NSData.
@return NSData The response data.
*/
-(NSData *)getResponseData;
/**
Retruns the data from a response as a string.
@return NSString The response data.
*/
-(NSString *)getResponseDataString;
/**
Convenience method to return a JSON response data as an NSArray or NSDictionary.
@return id The pharsed response data.
*/
-(id)getResponseDataJsonParsed;
/**
Returns the status code of a request.
@return int The status code of a request.
*/
-(long)getStatusCode;
/**
Returns the error of an executed request.
@return NSError The error of the executed request.
*/
-(NSError *)getError;
/**
Allows you to add a HTTP header to a request.
@param object The value of the header.
@param key The name of the header.
*/
-(void)addHeader:(id)object
forKey:(NSString *)key;
/**
Allows you to add a parameter containing data.
@param object The value of the parameter.
@param key The name of the parameter.
*/
-(void)addFormData:(id)object
forKey:(NSString *)key;
/**
Allows you to specify a custom User Agent
@param string The user agent.
*/
-(void)setUserAgent:(NSString *)string;
/**
Allows you to specify whether or not you should use existing cookies
@param choice Determines if a request should use cookies or not.
*/
-(void)setUseCookies:(BOOL)choice;
/**
Sets a URL
@param address Specifies a URL for the request.
*/
-(void)setURL:(NSURL *)address;
/**
Allows you to set the post method (e.g. POST, PUT, PATCH, DELETE). This is not required for GET requests.
@param method The method of the request.
*/
-(void)setPostMethod:(NSString *)method;
/**
Starts a GET synchronous request.
*/
-(void)startRequest;
/**
Starts a Form synchronous request. If aa post method is not specified, it will default to POST.
*/
-(void)startFormRequest;
-(void)startJSONRequest:(NSString *)body;
-(void)startJSONFormRequest;
/**
Starts a JSON synchronous request with any JSON input. If aa post method is not specified, it will default to POST.
@param body The JSON data in string format.
@param bodytype The body type of the JSON data in the body. See JsonType Enums to see aviliable options.
*/
-(void)startJSONRequest:(NSString *)body type:(int)bodytype;
/**
Starts a JSON synchronous request with any JSON input. If aa post method is not specified, it will default to POST.
@param bodytype The body type of the JSON data in the body. See JsonType Enums to see aviliable options.
*/
-(void)startJSONFormRequest:(int)bodytype;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>8A218a</string>
<string>8C1002</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>16A300</string>
<string>16C58</string>
<key>DTSDKName</key>
<string>macosx10.12</string>
<key>DTXcode</key>
<string>0800</string>
<string>0821</string>
<key>DTXcodeBuild</key>
<string>8A218a</string>
<string>8C1002</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Atelier Shiori. All rights reserved.</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
//

#import <Foundation/Foundation.h>

/**
This class allows you to use Anitomy with Objective-C or Swift Projects.
*/
@interface anitomy_bridge : NSObject
/*
Usage: NSDictionary * d = [[[anitomy_bridge init] alloc] tokenize:@"<filename>"]
Dictionary Contents: title, episode, episodetitle, episodetype, group, year, releaseversion, videoterm, videosource, season
/**
Tokenizes a media's file name. Convenience method so you don't have to initalize an instance of Anitomy.
@param filename The filename to tokenize.
@return NSDictionary Returns a dictionary containing information of a filename.
*/
+(NSDictionary *)tokenize:(NSString *) filename;
/**
Tokenizes a media's file name.
@param filename The filename to tokenize.
@return NSDictionary Returns a dictionary containing information of a filename.
*/
-(NSDictionary *)tokenize:(NSString *) filename;
@end
@end
10 changes: 5 additions & 5 deletions Frameworks/anitomy-osx.framework/Versions/A/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>16C67</string>
<string>16D32</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
Expand All @@ -29,17 +29,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>8A218a</string>
<string>8C1002</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>16A300</string>
<string>16C58</string>
<key>DTSDKName</key>
<string>macosx10.12</string>
<key>DTXcode</key>
<string>0800</string>
<string>0821</string>
<key>DTXcodeBuild</key>
<string>8A218a</string>
<string>8C1002</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Eren Okka</string>
</dict>
Expand Down
Binary file modified Frameworks/anitomy-osx.framework/Versions/A/anitomy-osx
Binary file not shown.
6 changes: 3 additions & 3 deletions Hachidori+Update.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ -(int)performupdate:(NSString *)titleid{
[tmpd setValue:attributes forKey:@"attributes"];
[request addFormData:tmpd forKey:@"data"];
// Do Update
[request startJSONFormRequest];
[request startJSONFormRequest:EasyNSURLConnectionvndapiJsonType];
// Set correcting status to off
correcting = false;
long statuscode = [request getStatusCode];
Expand Down Expand Up @@ -217,7 +217,7 @@ -(BOOL)updatestatus:(NSString *)titleid
[tmpd setValue:attributes forKey:@"attributes"];
[request addFormData:tmpd forKey:@"data"];
// Do Update
[request startJSONFormRequest];
[request startJSONFormRequest:EasyNSURLConnectionvndapiJsonType];
switch ([request getStatusCode]) {
case 200:
case 201:
Expand Down Expand Up @@ -262,7 +262,7 @@ -(BOOL)stopRewatching:(NSString *)titleid{
[tmpd setValue:attributes forKey:@"attributes"];
[request addFormData:tmpd forKey:@"data"];
// Do Update
[request startJSONFormRequest];
[request startJSONFormRequest:EasyNSURLConnectionvndapiJsonType];
switch ([request getStatusCode]) {
case 200:
case 201:
Expand Down
2 changes: 1 addition & 1 deletion Utility.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ +(int)checkDonationKey:(NSString *)key name:(NSString *)name{
//Ignore Cookies
[request setUseCookies:NO];
//Perform Search
[request startJSONFormRequest];
[request startJSONFormRequest:EasyNSURLConnectionJsonType];
// Get Status Code
long statusCode = [request getStatusCode];
if (statusCode == 200){
Expand Down

0 comments on commit 9cded60

Please sign in to comment.