Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

Commit

Permalink
2.2.7 - Fix bug that causes MAL Updater OS X to crash when Plex/Kodi …
Browse files Browse the repository at this point in the history
…support is enabled. Add Applescripting support
  • Loading branch information
chikorita157 committed Jun 29, 2015
1 parent 2155db6 commit d8cc38c
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Base.lproj/ExceptionsPref.xib
Expand Up @@ -336,7 +336,7 @@
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<popUpButtonCell key="dataCell" type="bevel" title="AnimeLab" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="bezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="Yv7-Cs-hvX" id="9VN-kZ-GfV">
<popUpButtonCell key="dataCell" type="bevel" title="SMPlayerX" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="bezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="a4U-X4-kWA" id="9VN-kZ-GfV">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="f5B-ZJ-OBx">
Expand All @@ -354,7 +354,7 @@
<menuItem title="VLC" id="IL3-8N-EC1">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="SMPlayerX" id="a4U-X4-kWA">
<menuItem title="SMPlayerX" state="on" id="a4U-X4-kWA">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Kodi" id="71P-mF-erW">
Expand All @@ -370,7 +370,7 @@
<menuItem title="AnimeNewsNetwork" id="01Q-Xx-pgR">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="AnimeLab" state="on" id="Yv7-Cs-hvX">
<menuItem title="AnimeLab" id="Yv7-Cs-hvX">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="AnimeSols" id="Pow-fG-CJq">
Expand Down
2 changes: 1 addition & 1 deletion Detection.m
Expand Up @@ -175,7 +175,7 @@ -(NSDictionary *)detectStream{
-(NSDictionary *)detectKodi{
// Kodi/Plex Theater Detection
NSString * address = [[NSUserDefaults standardUserDefaults] objectForKey:@"kodiaddress"];
NSString * port = [[NSUserDefaults standardUserDefaults] objectForKey:@"kodiport"];
NSString * port = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"kodiport"]];
if (address.length == 0) {
return nil;
}
Expand Down
17 changes: 17 additions & 0 deletions MAL Updater OS X.sdef
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">

<dictionary title="MAL Updater OS X">
<suite name="MAL Updater OS X Suite" code="HaAp" description="MAL Updater OS X AppleScript support">
<command name="getstatus" code="GetStatu" description="Returns the currently playing status information.">
<cocoa class="ScriptingGetStatus"/>
<result type="text" description="Currently playing information in JSON. If there is nothing playing, it will return a blank array." />
</command>
<command name="scrobblenow" code="Scrobble" description="Tells MAL Updater OS X to perform an on demand scrobble.">
<cocoa class="ScriptingScrobbleNow"/>
</command>
<command name="toggleautoscrobble" code="toggleas" description="Tells MAL Updater OS X to toggle the auto scrobble state.">
<cocoa class="ScriptingToggleAutoScrobble"/>
</command>
</suite>
</dictionary>
18 changes: 18 additions & 0 deletions MAL Updater OS X.xcodeproj/project.pbxproj
Expand Up @@ -52,6 +52,8 @@
6FAA0C1F1A7E938400416079 /* ExceptionsCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FAA0C1E1A7E938400416079 /* ExceptionsCache.m */; };
6FBA5A081ABE460600B6DB79 /* AdvancedPrefController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FBA5A061ABE460600B6DB79 /* AdvancedPrefController.m */; };
6FBA5A0A1ABE484B00B6DB79 /* AdvancedPrefController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6FBA5A0C1ABE484B00B6DB79 /* AdvancedPrefController.xib */; };
6FD961411B419E3F00DE539C /* MALScripting.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FD961401B419E3F00DE539C /* MALScripting.m */; };
6FD961431B419E4C00DE539C /* MAL Updater OS X.sdef in Resources */ = {isa = PBXBuildFile; fileRef = 6FD961421B419E4C00DE539C /* MAL Updater OS X.sdef */; };
6FF033301A73F2C70096FC69 /* rules.png in Resources */ = {isa = PBXBuildFile; fileRef = 6FF0332F1A73F2C70096FC69 /* rules.png */; };
8227C1171A1D8D34005F3301 /* anitomy-osx.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8227C1161A1D8D34005F3301 /* anitomy-osx.framework */; };
8227C1181A1D8D47005F3301 /* anitomy-osx.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8227C1161A1D8D34005F3301 /* anitomy-osx.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -160,6 +162,9 @@
6FBA5A051ABE460600B6DB79 /* AdvancedPrefController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdvancedPrefController.h; sourceTree = "<group>"; };
6FBA5A061ABE460600B6DB79 /* AdvancedPrefController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvancedPrefController.m; sourceTree = "<group>"; };
6FBA5A0B1ABE484B00B6DB79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/AdvancedPrefController.xib; sourceTree = "<group>"; };
6FD9613F1B419E3F00DE539C /* MALScripting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MALScripting.h; sourceTree = "<group>"; };
6FD961401B419E3F00DE539C /* MALScripting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MALScripting.m; sourceTree = "<group>"; };
6FD961421B419E4C00DE539C /* MAL Updater OS X.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "MAL Updater OS X.sdef"; sourceTree = "<group>"; };
6FF0332F1A73F2C70096FC69 /* rules.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rules.png; sourceTree = "<group>"; };
8227C1161A1D8D34005F3301 /* anitomy-osx.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "anitomy-osx.framework"; path = "Frameworks/anitomy-osx.framework"; sourceTree = "<group>"; };
822AEB861A202931003DD682 /* FixSearchDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FixSearchDialog.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -205,6 +210,7 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
6FD9613E1B419E2F00DE539C /* Scripting Support */,
5C07DA621A8156210003A827 /* Window Controllers */,
6FAA87811A7EB68D00EFFAC1 /* Support Classes */,
5C8ACEB619F409C60001A101 /* Other Classes */,
Expand Down Expand Up @@ -279,6 +285,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
6FD961421B419E4C00DE539C /* MAL Updater OS X.sdef */,
82B9559919FD553900A032FB /* DetectStream */,
8294C45D19F99B2F009DE98B /* Images.xcassets */,
5C8ACEB919F409F90001A101 /* Images */,
Expand Down Expand Up @@ -415,6 +422,15 @@
name = "Support Classes";
sourceTree = "<group>";
};
6FD9613E1B419E2F00DE539C /* Scripting Support */ = {
isa = PBXGroup;
children = (
6FD9613F1B419E3F00DE539C /* MALScripting.h */,
6FD961401B419E3F00DE539C /* MALScripting.m */,
);
name = "Scripting Support";
sourceTree = "<group>";
};
8285DED41A1D529200D6A53F /* Exception/Correction */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -491,6 +507,7 @@
files = (
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
8294C45E19F99B2F009DE98B /* Images.xcassets in Resources */,
6FD961431B419E4C00DE539C /* MAL Updater OS X.sdef in Resources */,
6FBA5A0A1ABE484B00B6DB79 /* AdvancedPrefController.xib in Resources */,
6F27CE971A6869ED004E51F8 /* HotkeysPrefs.xib in Resources */,
6FF033301A73F2C70096FC69 /* rules.png in Resources */,
Expand Down Expand Up @@ -540,6 +557,7 @@
3A6AB37F120F313E00D51D2C /* Base64Category.m in Sources */,
6F12909B1A7D833100B8C3E6 /* AutoExceptions.m in Sources */,
6F28DC121A67085800AF063F /* MASShortcut.m in Sources */,
6FD961411B419E3F00DE539C /* MALScripting.m in Sources */,
6F5F6C701A71696D006D4607 /* MAL_Updater_OS_X_DataModel.xcdatamodeld in Sources */,
5C881EFB19F462B400E20425 /* NSString_stripHtml.m in Sources */,
829727981A8BB14E004F73AB /* MyAnimeList+Update.m in Sources */,
Expand Down
Binary file not shown.
21 changes: 21 additions & 0 deletions MALScripting.h
@@ -0,0 +1,21 @@
//
// MALScripting.h
// MAL Updater OS X
//
// Created by Tail Red on 6/19/15.
// Copyright 2015 Atelier Shiori. All rights reserved. Code licensed under New BSD License
//

#import <Foundation/Foundation.h>

@interface ScriptingGetStatus: NSScriptCommand

@end

@interface ScriptingScrobbleNow: NSScriptCommand

@end

@interface ScriptingToggleAutoScrobble: NSScriptCommand

@end
44 changes: 44 additions & 0 deletions MALScripting.m
@@ -0,0 +1,44 @@
//
// MALScripting.m
// MAL Updater OS X
//
// Created by Tail Red on 6/19/15.
// Copyright 2015 Atelier Shiori. All rights reserved. Code licensed under New BSD License
//

#import "MALScripting.h"
#import "MAL_Updater_OS_XAppDelegate.h"

@implementation ScriptingGetStatus
// AppleScript command for GetStatus
-(id)performDefaultImplementation {
MAL_Updater_OS_XAppDelegate * delegate = (MAL_Updater_OS_XAppDelegate *)[[NSApplication sharedApplication] delegate];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[delegate getNowPlaying] options:0 error:&error];
if (!jsonData) {}
else{
NSString *JSONString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding];
// Output JSON
return JSONString;
}
return @"";
}
@end

@implementation ScriptingScrobbleNow
// AppleScript command for ScrobbleNow
-(id)performDefaultImplementation {
MAL_Updater_OS_XAppDelegate * delegate = (MAL_Updater_OS_XAppDelegate *)[[NSApplication sharedApplication] delegate];
[delegate updatenow:nil];
return nil;
}
@end

@implementation ScriptingToggleAutoScrobble
// AppleScript command for ToggleAutoScrobble
-(id)performDefaultImplementation{
MAL_Updater_OS_XAppDelegate * delegate = (MAL_Updater_OS_XAppDelegate *)[[NSApplication sharedApplication] delegate];
[delegate toggletimer:nil];
return nil;
}
@end
8 changes: 6 additions & 2 deletions MAL_Updater_OS_X-Info.plist
Expand Up @@ -15,15 +15,17 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.6</string>
<string>2.2.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.2.6</string>
<string>2.2.7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.entertainment</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSAppleScriptEnabled</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>© 2009-2015 Atelier Shiori. All rights reserved.</string>
<key>NSMainNibFile</key>
Expand All @@ -32,6 +34,8 @@
<string>NSApplication</string>
<key>NSUIElement</key>
<string>1</string>
<key>OSAScriptingDefinition</key>
<string>MAL Updater OS X.sdef</string>
<key>SUEnableSystemProfiling</key>
<true/>
<key>SUFeedURL</key>
Expand Down
1 change: 1 addition & 0 deletions MAL_Updater_OS_XAppDelegate.h
Expand Up @@ -98,5 +98,6 @@
-(IBAction)showAboutWindow:(id)sender;
-(bool)getisScrobbling;
-(bool)getisScrobblingActive;
-(NSDictionary *)getNowPlaying;
-(NSManagedObjectContext *)getObjectContext;
@end
12 changes: 12 additions & 0 deletions MAL_Updater_OS_XAppDelegate.m
Expand Up @@ -973,6 +973,18 @@ - (void)appendToAnimeInfo:(NSString*)text

[[animeinfo textStorage] appendAttributedString:attr];
}
-(NSDictionary *)getNowPlaying{
// Outputs Currently Playing information into JSON
NSMutableDictionary * output = [NSMutableDictionary new];
if ([MALEngine.getLastScrobbledTitle length] > 0){
[output setObject:[MALEngine getAniID] forKey:@"id"];
[output setObject:[MALEngine getLastScrobbledTitle] forKey:@"scrobbledtitle"];
[output setObject:[MALEngine getLastScrobbledActualTitle] forKey:@"scrobbledactualtitle"];
[output setObject:[MALEngine getLastScrobbledEpisode] forKey:@"scrobbledEpisode"];
[output setObject:[MALEngine getLastScrobbledSource] forKey:@"source"];
}
return output;
}
#pragma mark Share Services
-(void)generateShareMenu{
//Clear Share Menu
Expand Down

0 comments on commit d8cc38c

Please sign in to comment.