From 6f33710450383e9a09796aae3585e45fb9664506 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 17 Mar 2020 11:38:52 +0100 Subject: [PATCH] Support TV app and missing iTunes On a fresh installation of Catalina iTunes does not exist and so the AppleScript plugins that deal with refreshing iTunes fail in that situation. And even when iTunes is found on Catalina MetaZ should instead talk to the TV app. Catalina also included a new TV app which contains the Movie and TV Show library previously in iTunes. This commit adds plugins, services and clipboard support for the TV app on Catalina and all functionality that MetaZ provided for iTunes is now supported for the TV app. --- App/Info.plist | 16 ++++ .../Return TV app selected.applescript | 12 +++ .../Contents/Info.plist | 14 +++ .../Contents/Resources/Scripts/main.scpt | Bin 0 -> 2140 bytes .../Contents/Info.plist | 14 +++ .../Contents/Resources/Scripts/main.scpt} | Bin App/src/AppController.m | 39 ++++++-- App/src/FilesTableView.m | 83 ++++++++++++++---- App/src/main.m | 26 ++++++ Framework/src/MZConstants.h | 2 + Framework/src/MZConstants.m | 2 + Framework/src/MZPluginController.m | 81 +++++++++++------ Framework/src/MZScriptActionsPlugin.h | 1 + Framework/src/MZScriptActionsPlugin.m | 8 +- Framework/src/MZTag.m | 2 +- MetaZ.xcodeproj/project.pbxproj | 57 ++++++++---- .../Add to TV app.scptd/Contents/Info.plist | 14 +++ .../Contents/Resources/Scripts/main.scpt | Bin 0 -> 2566 bytes Plugins/AppleScript/Add to TV app.applescript | 14 +++ .../Add to TV app.scptd/Contents/Info.plist | 14 +++ .../Contents/Resources/Scripts/main.scpt | Bin 0 -> 2574 bytes .../Add to iTunes.scptd/Contents/Info.plist | 33 +++++++ .../Contents/Resources/Scripts/main.scpt} | Bin 2892 -> 2924 bytes .../Resources/description.rtfd/TXT.rtf | 5 ++ Plugins/AppleScript/Example Actions.scpt | Bin 4718 -> 4734 bytes Plugins/AppleScript/Quit MetaZ.scpt | Bin 1500 -> 1532 bytes Plugins/AppleScript/README.md | 15 ++-- Plugins/AppleScript/Update TV app.applescript | 46 ++++++++++ .../Update TV app.scptd/Contents/Info.plist | 14 +++ .../Contents/Resources/Scripts/main.scpt | Bin 0 -> 7688 bytes .../Update iTunes.scptd/Contents/Info.plist | 14 +++ .../Contents/Resources/Scripts/main.scpt} | Bin 8336 -> 8400 bytes Plugins/AppleScript/update.sh | 6 -- compile-applescripts.sh | 53 +++++++++++ 34 files changed, 504 insertions(+), 81 deletions(-) create mode 100644 App/resources/Return TV app selected.applescript create mode 100644 App/resources/Return TV app selected.scptd/Contents/Info.plist create mode 100644 App/resources/Return TV app selected.scptd/Contents/Resources/Scripts/main.scpt create mode 100644 App/resources/Return iTunes selected.scptd/Contents/Info.plist rename App/resources/{Return iTunes selected.scpt => Return iTunes selected.scptd/Contents/Resources/Scripts/main.scpt} (100%) create mode 100644 Plugins/Add to TV app.scptd/Contents/Info.plist create mode 100644 Plugins/Add to TV app.scptd/Contents/Resources/Scripts/main.scpt create mode 100644 Plugins/AppleScript/Add to TV app.applescript create mode 100644 Plugins/AppleScript/Add to TV app.scptd/Contents/Info.plist create mode 100644 Plugins/AppleScript/Add to TV app.scptd/Contents/Resources/Scripts/main.scpt create mode 100644 Plugins/AppleScript/Add to iTunes.scptd/Contents/Info.plist rename Plugins/AppleScript/{Add to iTunes.scpt => Add to iTunes.scptd/Contents/Resources/Scripts/main.scpt} (54%) create mode 100644 Plugins/AppleScript/Add to iTunes.scptd/Contents/Resources/description.rtfd/TXT.rtf create mode 100644 Plugins/AppleScript/Update TV app.applescript create mode 100644 Plugins/AppleScript/Update TV app.scptd/Contents/Info.plist create mode 100644 Plugins/AppleScript/Update TV app.scptd/Contents/Resources/Scripts/main.scpt create mode 100644 Plugins/AppleScript/Update iTunes.scptd/Contents/Info.plist rename Plugins/AppleScript/{Update iTunes.scpt => Update iTunes.scptd/Contents/Resources/Scripts/main.scpt} (65%) delete mode 100755 Plugins/AppleScript/update.sh create mode 100755 compile-applescripts.sh diff --git a/App/Info.plist b/App/Info.plist index ec7d9a07..94af85b5 100644 --- a/App/Info.plist +++ b/App/Info.plist @@ -175,6 +175,20 @@ com.apple.iTunes + + NSMessage + doTVApp + NSMenuItem + + default + Open selected tracks in MetaZ + + NSRequiredContext + + NSApplicationIdentifier + com.apple.TV + + OSAScriptingDefinition MetaZ.sdef @@ -186,6 +200,8 @@ https://metaz.io/appcast.xml SUPublicDSAKeyFile sparkle_public.pem + NSAppleEventsUsageDescription + Please give access to sync metadata with iTunes and TV app UTExportedTypeDeclarations diff --git a/App/resources/Return TV app selected.applescript b/App/resources/Return TV app selected.applescript new file mode 100644 index 00000000..f360f76d --- /dev/null +++ b/App/resources/Return TV app selected.applescript @@ -0,0 +1,12 @@ +tell application "TV" + set sel to selection + set ret to {} + set retRef to a reference to ret + set len to length of sel + repeat with n from 1 to len + set obj to item n of sel + set i to {mylocation:location of obj, myid:persistent ID of obj} + copy i to the end of retRef + end repeat +end tell +return ret diff --git a/App/resources/Return TV app selected.scptd/Contents/Info.plist b/App/resources/Return TV app selected.scptd/Contents/Info.plist new file mode 100644 index 00000000..753b524e --- /dev/null +++ b/App/resources/Return TV app selected.scptd/Contents/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Return-TV-selected + CFBundleName + Return TV selected + CFBundleShortVersionString + 1.0 + LSMinimumSystemVersion + 10.15 + + diff --git a/App/resources/Return TV app selected.scptd/Contents/Resources/Scripts/main.scpt b/App/resources/Return TV app selected.scptd/Contents/Resources/Scripts/main.scpt new file mode 100644 index 0000000000000000000000000000000000000000..5526d6b39692715624846c1153d23054948ba761 GIT binary patch literal 2140 zcmb_d=~7fj7(MsSIN)uX0W=`4xMUQBnE`jig=K&wRwfmfDl5MxI40<@6rff9%Om6w z@&b7Xal>74!wnbQ*BJNp%jv%2OjWe94>3x;53mWn<&|irQ#x+~h(4 z!LSG%xCl6`K(p>_XS+#37eV$+Ku8k;8PDBIZe$tO=GTjIa2WYJ&4UX~OI%(a^6YMIbn1-pCrU`C0S1Cm~relUC zSVNSdTwZwcf`-VXyMNJ`;V)8(GI_4#dDak`OrLD@Ovy9b#Ytv!<;*kXsm4r9*vw_7 z^B88y->ATBd7?4PKb#0wV~&eC96T5EG{I_&pc-Ezq6t=G1XY-i1)AV4CfR&c$zQ1S z2tlu-=jUx2mA;e(sFcS_9%Dir4uxne@H--yFOQTw%9S6<%73Wjq3t4>kw1^Q3JW#C zDyqQ>YO2u$=Q}E>!7@Zch$0{l5JOzCD2&7F+Lh_)NDXxM*tKK6{3vSq)oFq?aSXL` z-;?_k-@C4-L!-_Y5=BhzDY=&w5(2$W?qZSLQ7rP~2zKr2++y~%$mg!Z5-i3NO|aaH zutaWqa@%nK@XdP7ZhJ;`kU|?S+O)L(I8iqT>Xsm zI&vLw$=+7fB z8p3FBcIF##|9@KRI!I+Yjp5+%>cPoxP7Sc7JN1Rdnp(J5rqG5>(Nu5m7e@Vev*E}c z<^OvX9XoPcQP9}io9Xm@wV(QC#Ol}Y>K{mV)#rB9`(k2Xh$}=08?cE^pF%IcFoRn@ zuXPFo%o%i|n`H^6`aH2*p4i7tO@b4H(dWnq1MiKeg_u`iwIiqt>+cVX|%{G z8K%TmIqC8D%QG||tB;Ra8`@m%$vkH5F4|dHB_~`tVYHnx+J=pa1pkgJIX>?8MQEkf z8|0WAl_PRk4#`0ok^{0|_Q_t^BZIQrlViO4<_S}B)EdY>T1t*&t)=AfXKtG(hd9&3 zd?g37m&cPKHk%-;c9&2oKXa!)vnRDVYw@3nq2I{N27&u`o8 literal 0 HcmV?d00001 diff --git a/App/resources/Return iTunes selected.scptd/Contents/Info.plist b/App/resources/Return iTunes selected.scptd/Contents/Info.plist new file mode 100644 index 00000000..8657b2bc --- /dev/null +++ b/App/resources/Return iTunes selected.scptd/Contents/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Return-iTunes-selected + CFBundleName + Return iTunes selected + CFBundleShortVersionString + 1.0 + MZMaximumSystemVersion + 10.14 + + diff --git a/App/resources/Return iTunes selected.scpt b/App/resources/Return iTunes selected.scptd/Contents/Resources/Scripts/main.scpt similarity index 100% rename from App/resources/Return iTunes selected.scpt rename to App/resources/Return iTunes selected.scptd/Contents/Resources/Scripts/main.scpt diff --git a/App/src/AppController.m b/App/src/AppController.m index e13e5e1a..4a7d0217 100644 --- a/App/src/AppController.m +++ b/App/src/AppController.m @@ -711,6 +711,11 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende -(void)doiTunesMetadata:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { NSDictionary* prop = [pboard propertyListForType:iTunesMetadataPboardType]; + BOOL tv = NO; + if(!prop) { + prop = [pboard propertyListForType:TVAppMetadataPboardType]; + tv = YES; + } if(!prop) prop = [pboard propertyListForType:iTunesPboardType]; @@ -725,7 +730,14 @@ -(void)doiTunesMetadata:(NSPasteboard *)pboard userData:(NSString *)userData err [names addObject:[location path]]; NSString* persistentId = [track objectForKey:@"Persistent ID"]; - NSDictionary* data = [NSDictionary dictionaryWithObject:persistentId forKey:MZiTunesPersistentIDTagIdent]; + NSDictionary* data; + if (tv) { + data = [NSDictionary dictionaryWithObject:persistentId + forKey:MZTVAppPersistentIDTagIdent]; + } else { + data = [NSDictionary dictionaryWithObject:persistentId + forKey:MZiTunesPersistentIDTagIdent]; + } [dataDicts addObject:data]; } [[MZMetaLoader sharedLoader] loadFromFiles:names withMetaData:dataDicts]; @@ -733,7 +745,20 @@ -(void)doiTunesMetadata:(NSPasteboard *)pboard userData:(NSString *)userData err } -(void)doiTunes:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { - NSString* path = [[NSBundle mainBundle] pathForResource:@"Return iTunes selected" ofType:@"scpt"]; + [self doiTunes:@"Return iTunes selected" + tag:MZiTunesPersistentIDTagIdent + error:error]; +} + +-(void)doTVApp:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { + [self doiTunes:@"Return TV app selected" + tag:MZTVAppPersistentIDTagIdent + error:error]; +} + + +-(void)doiTunes:(NSString *)filename tag:(NSString *)tagName error:(NSString **)error { + NSString* path = [[NSBundle mainBundle] pathForResource:filename ofType:@"scptd"]; NSURL* url = [NSURL fileURLWithPath:path]; NSDictionary* errDict = nil; NSAppleScript* script = [[[NSAppleScript alloc] initWithContentsOfURL:url error:&errDict] autorelease]; @@ -773,7 +798,7 @@ -(void)doiTunes:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSSt [names addObject:[o objectForKey:@"mylocation"]]; if(!dataDicts) dataDicts = [NSMutableArray array]; - [dataDicts addObject:[NSDictionary dictionaryWithObject:[o objectForKey:@"myid"] forKey:MZiTunesPersistentIDTagIdent]]; + [dataDicts addObject:[NSDictionary dictionaryWithObject:[o objectForKey:@"myid"] forKey:tagName]]; } else { @@ -789,10 +814,12 @@ -(void)doiTunes:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSSt } else if([obj isKindOfClass:[NSString class]]) [[MZMetaLoader sharedLoader] loadFromFile:obj]; - else if([obj isKindOfClass:[NSDictionary class]]) + else if([obj isKindOfClass:[NSDictionary class]]) { + NSDictionary* data = [NSDictionary dictionaryWithObject:[obj objectForKey:@"myid"] + forKey:tagName]; [[MZMetaLoader sharedLoader] loadFromFile:[obj objectForKey:@"mylocation"] - withMetaData:[NSDictionary dictionaryWithObject:[obj objectForKey:@"myid"] - forKey:MZiTunesPersistentIDTagIdent]]; + withMetaData:data]; + } else { NSString* err = [NSString stringWithFormat:@"Unsupported return type %@", obj]; if(error) diff --git a/App/src/FilesTableView.m b/App/src/FilesTableView.m index 440131fa..deb5e406 100644 --- a/App/src/FilesTableView.m +++ b/App/src/FilesTableView.m @@ -47,8 +47,8 @@ - (id)initWithFrame:(NSRect)frame [self registerForDraggedTypes: [NSArray arrayWithObjects:MZFilesTableRows, MZMetaEditsDataType, iTunesMetadataPboardType, - iTunesPboardType, NSFilenamesPboardType, - NSStringPboardType, nil] ]; + TVAppMetadataPboardType, iTunesPboardType, + NSFilenamesPboardType, NSStringPboardType, nil] ]; } return self; } @@ -61,8 +61,8 @@ - (id)initWithCoder:(NSCoder*)decoder [self registerForDraggedTypes: [NSArray arrayWithObjects:MZFilesTableRows, MZMetaEditsDataType, iTunesMetadataPboardType, - iTunesPboardType, NSFilenamesPboardType, - NSStringPboardType, nil] ]; + TVAppMetadataPboardType, iTunesPboardType, + NSFilenamesPboardType, NSStringPboardType, nil] ]; } return self; } @@ -116,9 +116,11 @@ -(IBAction)copy:(id)sender -(IBAction)paste:(id)sender { NSPasteboard *pb = [NSPasteboard generalPasteboard]; + NSLog(@"Pasteboard Types %@", pb.types); NSArray *types = [NSArray arrayWithObjects:MZMetaEditsDataType, - iTunesMetadataPboardType, iTunesPboardType, NSFilenamesPboardType, - NSStringPboardType, nil]; + iTunesMetadataPboardType, TVAppMetadataPboardType, + iTunesPboardType, NSFilenamesPboardType, + NSStringPboardType, nil]; NSString *bestType = [pb availableTypeFromArray:types]; if (bestType != nil) { @@ -151,9 +153,16 @@ -(IBAction)paste:(id)sender for(MetaEdits* edit in edits) [self registerUndoName:edit.undoManager]; } - if([bestType isEqualToString:iTunesMetadataPboardType] || [bestType isEqualToString:iTunesMetadataPboardType]) + if([bestType isEqualToString:iTunesMetadataPboardType] || + [bestType isEqualToString:TVAppMetadataPboardType] || + [bestType isEqualToString:iTunesPboardType]) { NSDictionary* prop = [pb propertyListForType:iTunesMetadataPboardType]; + BOOL tv = NO; + if(!prop) { + prop = [pb propertyListForType:TVAppMetadataPboardType]; + tv = YES; + } if(!prop) prop = [pb propertyListForType:iTunesPboardType]; @@ -168,7 +177,14 @@ -(IBAction)paste:(id)sender [names addObject:[location path]]; NSString* persistentId = [track objectForKey:@"Persistent ID"]; - NSDictionary* data = [NSDictionary dictionaryWithObject:persistentId forKey:MZiTunesPersistentIDTagIdent]; + NSDictionary* data; + if (tv) { + data = [NSDictionary dictionaryWithObject:persistentId + forKey:MZTVAppPersistentIDTagIdent]; + } else { + data = [NSDictionary dictionaryWithObject:persistentId + forKey:MZiTunesPersistentIDTagIdent]; + } [dataDicts addObject:data]; } [[MZMetaLoader sharedLoader] loadFromFiles:names withMetaData:dataDicts]; @@ -193,9 +209,11 @@ -(IBAction)paste:(id)sender - (BOOL)pasteboardHasTypes { NSPasteboard *pb = [NSPasteboard generalPasteboard]; + NSLog(@"Pasteboard Types %@", pb.types); NSArray *types = [NSArray arrayWithObjects:MZMetaEditsDataType, - iTunesMetadataPboardType, iTunesPboardType, NSFilenamesPboardType, - NSStringPboardType, nil]; + iTunesMetadataPboardType, TVAppMetadataPboardType, + iTunesPboardType, NSFilenamesPboardType, + NSStringPboardType, nil]; NSString *bestType = [pb availableTypeFromArray:types]; if(bestType != nil && [bestType isEqualToString:MZMetaEditsDataType]) return [self numberOfSelectedRows] > 0; @@ -217,10 +235,14 @@ - (BOOL)pasteboardHasTypes { return NO; } } - if(bestType != nil && ([bestType isEqualToString:iTunesMetadataPboardType] || - [bestType isEqualToString:iTunesPboardType])) + if(bestType != nil && + ([bestType isEqualToString:iTunesMetadataPboardType] || + [bestType isEqualToString:TVAppMetadataPboardType] || + [bestType isEqualToString:iTunesPboardType])) { NSDictionary* prop = [pb propertyListForType:iTunesMetadataPboardType]; + if(!prop) + prop = [pb propertyListForType:TVAppMetadataPboardType]; if(!prop) prop = [pb propertyListForType:iTunesPboardType]; @@ -351,7 +373,8 @@ - (NSDragOperation)tableView:(NSTableView*)tv NSPasteboard* pboard = [info draggingPasteboard]; NSArray *types = [NSArray arrayWithObjects:MZFilesTableRows, - MZMetaEditsDataType, iTunesMetadataPboardType, iTunesPboardType, + MZMetaEditsDataType, iTunesMetadataPboardType, + TVAppMetadataPboardType, iTunesPboardType, NSFilenamesPboardType, NSStringPboardType, nil]; //NSDragOperation operation = [info draggingSourceOperationMask]; NSString *bestType = [pboard availableTypeFromArray:types]; @@ -380,7 +403,8 @@ - (NSDragOperation)tableView:(NSTableView*)tv } return NSDragOperationGeneric; } - if([bestType isEqualToString:iTunesMetadataPboardType] || + if([bestType isEqualToString:iTunesMetadataPboardType] || + [bestType isEqualToString:TVAppMetadataPboardType] || [bestType isEqualToString:iTunesPboardType]) { return NSDragOperationGeneric; @@ -395,8 +419,9 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info { NSPasteboard* pboard = [info draggingPasteboard]; NSArray *types = [NSArray arrayWithObjects:MZFilesTableRows, - MZMetaEditsDataType, iTunesMetadataPboardType, iTunesPboardType, - NSFilenamesPboardType, NSStringPboardType, nil]; + MZMetaEditsDataType, iTunesMetadataPboardType, + TVAppMetadataPboardType, iTunesPboardType, + NSFilenamesPboardType, NSStringPboardType, nil]; NSString *bestType = [pboard availableTypeFromArray:types]; if (bestType != nil) { @@ -409,9 +434,16 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info [[MZMetaLoader sharedLoader] moveObjects:edits toIndex:row]; return YES; } - if([bestType isEqualToString:iTunesMetadataPboardType] || [bestType isEqualToString:iTunesMetadataPboardType]) + if([bestType isEqualToString:iTunesMetadataPboardType] || + [bestType isEqualToString:TVAppMetadataPboardType] || + [bestType isEqualToString:iTunesPboardType]) { NSDictionary* prop = [pboard propertyListForType:iTunesMetadataPboardType]; + BOOL tv = NO; + if(!prop) { + prop = [pboard propertyListForType:TVAppMetadataPboardType]; + tv = YES; + } if(!prop) prop = [pboard propertyListForType:iTunesPboardType]; @@ -426,7 +458,9 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info } if(![filesController commitEditing]) return NO; - NSArray* params = [NSArray arrayWithObjects:prop, [NSNumber numberWithInteger:row], nil]; + NSArray* params = [NSArray arrayWithObjects:prop, + [NSNumber numberWithInteger:row], + [NSNumber numberWithBool:tv], nil]; [self performSelector:@selector(loadFiles:) withObject:params afterDelay:1]; return YES; } @@ -470,6 +504,10 @@ - (void)loadFiles:(NSArray *)params { id first = [params objectAtIndex:0]; NSInteger row = [[params objectAtIndex:1] integerValue]; + BOOL tv = NO; + if ([params count] == 3) { + tv = [[params objectAtIndex:2] boolValue]; + } if([first isKindOfClass:[NSDictionary class]]) { @@ -482,7 +520,14 @@ - (void)loadFiles:(NSArray *)params [names addObject:[location path]]; NSString* persistentId = [track objectForKey:@"Persistent ID"]; - NSDictionary* data = [NSDictionary dictionaryWithObject:persistentId forKey:MZiTunesPersistentIDTagIdent]; + NSDictionary* data; + if (tv) { + data = [NSDictionary dictionaryWithObject:persistentId + forKey:MZTVAppPersistentIDTagIdent]; + } else { + data = [NSDictionary dictionaryWithObject:persistentId + forKey:MZiTunesPersistentIDTagIdent]; + } [dataDicts addObject:data]; } [[MZMetaLoader sharedLoader] loadFromFiles:names toIndex:row withMetaData:dataDicts]; diff --git a/App/src/main.m b/App/src/main.m index 8ab30108..a46e46e0 100644 --- a/App/src/main.m +++ b/App/src/main.m @@ -163,6 +163,32 @@ int main(int argc, const char *argv[]) [[NSUserDefaults standardUserDefaults] setInteger:version forKey:@"version"]; } + NSString* lastRunVersionStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"lastRunVersion"]; + MZVersion* lastRunVersion = nil; + if (lastRunVersionStr) { + lastRunVersion = [MZVersion versionWithString:lastRunVersionStr]; + } + MZVersion* catalina = [MZVersion versionWithString:@"10.15.0"]; + MZVersion* system = [MZVersion systemVersion]; + if ([system isGreaterThanOrEqualTo:catalina] && + (!lastRunVersion || [lastRunVersion isLessThan:system])) + { + // Upgraded to Catalina + NSArray* actions = [[NSUserDefaults standardUserDefaults] arrayForKey:@"enabledActionPlugins"]; + NSMutableArray* enabled = [NSMutableArray array]; + for (NSString* key in actions) { + if([key isEqualToString:@"Add to iTunes"]) { + [enabled addObject:@"Add to TV app"]; + } else if ([key isEqualToString:@"Update iTunes"]) { + [enabled addObject:@"Update TV app"]; + } else { + [enabled addObject:key]; + } + } + [[NSUserDefaults standardUserDefaults] setObject:enabled forKey:@"enabledActionPlugins"]; + } + [[NSUserDefaults standardUserDefaults] setObject:system.description forKey:@"lastRunVersion"]; + [pool release]; return NSApplicationMain(argc, argv); } diff --git a/Framework/src/MZConstants.h b/Framework/src/MZConstants.h index 7660f696..3435d295 100644 --- a/Framework/src/MZConstants.h +++ b/Framework/src/MZConstants.h @@ -193,6 +193,7 @@ MZKIT_EXTERN NSString* const MZASINTagIdent; MZKIT_EXTERN NSString* const MZDVDSeasonTagIdent; MZKIT_EXTERN NSString* const MZDVDEpisodeTagIdent; MZKIT_EXTERN NSString* const MZiTunesPersistentIDTagIdent; +MZKIT_EXTERN NSString* const MZTVAppPersistentIDTagIdent; /* Notifications */ MZKIT_EXTERN NSString* const MZDataProviderLoadedNotification; @@ -222,6 +223,7 @@ MZKIT_EXTERN NSString* const MZNSErrorKey; // Standard alert ids MZKIT_EXTERN NSString* const MZDataProviderFileAlreadyLoadedWarningKey; +MZKIT_EXTERN NSString* const TVAppMetadataPboardType; MZKIT_EXTERN NSString* const iTunesMetadataPboardType; MZKIT_EXTERN NSString* const iTunesPboardType; diff --git a/Framework/src/MZConstants.m b/Framework/src/MZConstants.m index 613f3941..b434a8be 100644 --- a/Framework/src/MZConstants.m +++ b/Framework/src/MZConstants.m @@ -71,6 +71,7 @@ NSString* const MZDVDSeasonTagIdent = @"dvdSeason"; NSString* const MZDVDEpisodeTagIdent = @"dvdEpisode"; NSString* const MZiTunesPersistentIDTagIdent = @"iTunesPersistentID"; +NSString* const MZTVAppPersistentIDTagIdent = @"TVAppPersistentID"; /* Notifications */ NSString* const MZDataProviderLoadedNotification = @"MZDataProviderLoadedNotification"; @@ -100,6 +101,7 @@ NSString* const MZDataProviderFileAlreadyLoadedWarningKey = @"alerts.warnings.fileAlreadyLoaded"; NSString* const iTunesMetadataPboardType = @"com.apple.itunes.metadata"; +NSString* const TVAppMetadataPboardType = @"com.apple.tv.metadata"; NSString* const iTunesPboardType = @"CorePasteboardFlavorType 0x6974756E"; // Plugin UTI diff --git a/Framework/src/MZPluginController.m b/Framework/src/MZPluginController.m index 619256be..ff4bdb6b 100644 --- a/Framework/src/MZPluginController.m +++ b/Framework/src/MZPluginController.m @@ -22,6 +22,7 @@ const NSInteger errMZPluginFailedLSMinimumSystemVersionCheck = -7; const NSInteger errMZPluginFailedToLoadPrincipalClass = -8; const NSInteger errMZPluginFailedToCreatePrincipalClass = -9; +const NSInteger errMZPluginFailedMZMaximumSystemVersionCheck = -10; @interface MZWriteNotification : NSObject @@ -388,8 +389,9 @@ - (id)loadPluginSourceWithName:(NSString *)name fromURL:(NSURL *)pathURL error:( } ret = plugin; } - else if(UTTypeEqual(uti, kMZUTAppleScriptText) || UTTypeConformsTo(uti, kMZUTAppleScriptText) || - UTTypeEqual(uti, kMZUTAppleScript) || UTTypeConformsTo(uti, kMZUTAppleScript) || + else if(UTTypeEqual(uti, kUTTypeAppleScript) || UTTypeConformsTo(uti, kUTTypeAppleScript) || + UTTypeEqual(uti, kUTTypeOSAScript) || UTTypeConformsTo(uti, kUTTypeOSAScript) || + UTTypeEqual(uti, kUTTypeOSAScriptBundle) || UTTypeConformsTo(uti, kUTTypeOSAScriptBundle) || UTTypeEqual(uti, kMZUTAppleScriptBundle) || UTTypeConformsTo(uti, kMZUTAppleScriptBundle)) { NSURL* url = [NSURL URLWithString:[name gtm_stringByEscapingForURLArgument] relativeToURL:pathURL]; @@ -470,7 +472,58 @@ - (BOOL)loadPluginFromSource:(id)source error:(NSError **)error; MZLoggerError(@"%@", msg); return NO; } - + + if([source respondsToSelector:@selector(objectForInfoDictionaryKey:)]) + { + NSString* minimumVersionStr = [source objectForInfoDictionaryKey:@"LSMinimumSystemVersion"]; + if(minimumVersionStr) + { + MZLoggerInfo(@"Minimum version %@", minimumVersionStr); + MZVersion* minimumVersion = [MZVersion versionWithString:minimumVersionStr]; + if([minimumVersion compare:[MZVersion systemVersion]] > NSOrderedSame) + { + NSString* msg = [NSString stringWithFormat: + @"Plugin %@ requires at least macOS version %@, but is being run on %@, and so is ignored.", + identifier, minimumVersion, [MZVersion systemVersion]]; + if(error) + { + NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys: + msg, NSLocalizedDescriptionKey, + identifier, @"MZPlugin", + nil]; + *error = [NSError errorWithDomain:@"MZPluginController" code:errMZPluginFailedLSMinimumSystemVersionCheck userInfo:info]; + } + else + MZLoggerError(@"%@", msg); + return NO; + } + } + NSString* maximumVersionStr = [source objectForInfoDictionaryKey:@"MZMaximumSystemVersion"]; + if(maximumVersionStr) + { + MZLoggerInfo(@"Maximum version %@", maximumVersionStr); + MZVersion* maximumVersion = [MZVersion versionWithString:maximumVersionStr]; + if([maximumVersion compare:[MZVersion systemVersion]] < NSOrderedSame) + { + NSString* msg = [NSString stringWithFormat: + @"Plugin %@ can only run on macOS versions up to %@, but is being run on %@, and so is ignored.", + identifier, maximumVersion, [MZVersion systemVersion]]; + if(error) + { + NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys: + msg, NSLocalizedDescriptionKey, + identifier, @"MZPlugin", + nil]; + *error = [NSError errorWithDomain:@"MZPluginController" code:errMZPluginFailedMZMaximumSystemVersionCheck userInfo:info]; + } + else + MZLoggerError(@"%@", msg); + return NO; + } + } + + } + MZPlugin* plugin; NSError* err = nil; if(![source loadAndReturnError:&err]) @@ -493,28 +546,6 @@ - (BOOL)loadPluginFromSource:(id)source error:(NSError **)error; if([source isKindOfClass:[NSBundle class]]) { - NSString* minimumVersionStr = [source objectForInfoDictionaryKey:@"LSMinimumSystemVersion"]; - if(minimumVersionStr) - { - MZVersion* minimumVersion = [MZVersion versionWithString:minimumVersionStr]; - if([minimumVersion compare:[MZVersion systemVersion]] > NSOrderedSame) - { - NSString* msg = [NSString stringWithFormat: - @"Plugin %@ requires at least Mac OS X version %@, but is being run on %@, and so is ignored.", - identifier, minimumVersion, [MZVersion systemVersion]]; - if(error) - { - NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys: - msg, NSLocalizedDescriptionKey, - identifier, @"MZPlugin", - nil]; - *error = [NSError errorWithDomain:@"MZPluginController" code:errMZPluginFailedLSMinimumSystemVersionCheck userInfo:info]; - } - else - MZLoggerError(@"%@", msg); - return NO; - } - } Class cls = [source principalClass]; if(cls == Nil) { diff --git a/Framework/src/MZScriptActionsPlugin.h b/Framework/src/MZScriptActionsPlugin.h index 8a191de2..51bf2d94 100644 --- a/Framework/src/MZScriptActionsPlugin.h +++ b/Framework/src/MZScriptActionsPlugin.h @@ -21,5 +21,6 @@ - (id)initWithURL:(NSURL *)url; - (NSString *)label; - (BOOL)loadAndReturnError:(NSError **)error; +- (id)objectForInfoDictionaryKey:(NSString *)key; @end diff --git a/Framework/src/MZScriptActionsPlugin.m b/Framework/src/MZScriptActionsPlugin.m index 6f55f017..26042fdf 100644 --- a/Framework/src/MZScriptActionsPlugin.m +++ b/Framework/src/MZScriptActionsPlugin.m @@ -33,7 +33,8 @@ + (id)pluginWithURL:(NSURL *)url; - (id)initWithURL:(NSURL *)theURL; { - self = [super initWithBundle:nil]; + NSBundle* bundle = [NSBundle bundleWithURL:theURL]; + self = [super initWithBundle:bundle]; if(self) { url = [theURL retain]; @@ -101,6 +102,11 @@ - (BOOL)loadAndReturnError:(NSError **)error return YES; } +- (id)objectForInfoDictionaryKey:(NSString *)key; +{ + return [self.bundle objectForInfoDictionaryKey:key]; +} + - (void)registerObservers { [[NSNotificationCenter defaultCenter] diff --git a/Framework/src/MZTag.m b/Framework/src/MZTag.m index 87cea014..28e1eb3c 100644 --- a/Framework/src/MZTag.m +++ b/Framework/src/MZTag.m @@ -100,7 +100,7 @@ + (void)initialize [self registerTag:[MZIntegerTag tagWithIdentifier:MZDVDSeasonTagIdent scriptName:@"dvd season"]]; [self registerTag:[MZIntegerTag tagWithIdentifier:MZDVDEpisodeTagIdent scriptName:@"dvd episode"]]; [self registerTag:[MZStringTag tagWithIdentifier:MZiTunesPersistentIDTagIdent scriptName:@"itunes persistent id"]]; - + [self registerTag:[MZStringTag tagWithIdentifier:MZTVAppPersistentIDTagIdent scriptName:@"tv app persistent id"]]; } static NSMutableDictionary *sharedTags = nil; diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index 9d845a2e..42aee002 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -120,9 +120,7 @@ 1B44949910D57D6900B9C751 /* AtomicParsley in Resources */ = {isa = PBXBuildFile; fileRef = 1B44949810D57D6900B9C751 /* AtomicParsley */; }; 1B4499D210D9A5CE00B9C751 /* PresetSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B4499D110D9A5CE00B9C751 /* PresetSegmentedControl.m */; }; 1B449B8810DC7DE400B9C751 /* ChaptersTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B449B8710DC7DE400B9C751 /* ChaptersTableView.m */; }; - 1B492FA91F65537800A2FD3F /* Add to iTunes.scpt in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B492FA51F65537800A2FD3F /* Add to iTunes.scpt */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1B492FAB1F65537800A2FD3F /* Quit MetaZ.scpt in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B492FA71F65537800A2FD3F /* Quit MetaZ.scpt */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 1B492FAC1F65537800A2FD3F /* Update iTunes.scpt in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B492FA81F65537800A2FD3F /* Update iTunes.scpt */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1B4AF83B1170CFCC00E5C969 /* TheTVDBSearch.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B4AF83A1170CFCC00E5C969 /* TheTVDBSearch.m */; }; 1B4AF84511715C8400E5C969 /* languages.xml in Resources */ = {isa = PBXBuildFile; fileRef = 1B4AF84411715C8400E5C969 /* languages.xml */; }; 1B4C1F4016554B0100011621 /* MZHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B4C1F3C1655490D00011621 /* MZHTTPRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -149,7 +147,6 @@ 1B6E43CB108468B100DFE165 /* MZSearchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B6E43C9108468B100DFE165 /* MZSearchResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B6E43CC108468B100DFE165 /* MZSearchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B6E43CA108468B100DFE165 /* MZSearchResult.m */; }; 1B6E43DD10846DBC00DFE165 /* TagData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B6E43D610846BDA00DFE165 /* TagData.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 1B76F8ED241696C000CB8810 /* Return iTunes selected.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 1B76F8EC241696C000CB8810 /* Return iTunes selected.scpt */; }; 1B7B103C240603930018DB18 /* MetaZKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BA325C410545ACA00276F57 /* MetaZKit.framework */; }; 1B7B104C240604020018DB18 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7B1046240604020018DB18 /* Configuration.swift */; }; 1B7B104D240604020018DB18 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7B1047240604020018DB18 /* JSON.swift */; }; @@ -172,6 +169,12 @@ 1B7FF40924048024001457CE /* Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7FF40224048024001457CE /* Search.swift */; }; 1B7FF40A24048024001457CE /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7FF40424048024001457CE /* Token.swift */; }; 1B7FF40C24059A43001457CE /* Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7FF40B24059A43001457CE /* Search.swift */; }; + 1B80F1B524208527006D4D94 /* Add to iTunes.scptd in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B80F1B1242084EC006D4D94 /* Add to iTunes.scptd */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 1B80F1B624208527006D4D94 /* Update iTunes.scptd in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B80F1B2242084ED006D4D94 /* Update iTunes.scptd */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 1B80F1B92420A7CE006D4D94 /* Return TV app selected.scptd in Resources */ = {isa = PBXBuildFile; fileRef = 1B80F1B72420A7CE006D4D94 /* Return TV app selected.scptd */; }; + 1B80F1BA2420A7CE006D4D94 /* Return iTunes selected.scptd in Resources */ = {isa = PBXBuildFile; fileRef = 1B80F1B82420A7CE006D4D94 /* Return iTunes selected.scptd */; }; + 1B80F1C32420A8E6006D4D94 /* Add to TV app.scptd in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B80F1C12420A870006D4D94 /* Add to TV app.scptd */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 1B80F1C42420A8E6006D4D94 /* Update TV app.scptd in Copy Plugins */ = {isa = PBXBuildFile; fileRef = 1B80F1BE2420A859006D4D94 /* Update TV app.scptd */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1B82647410B3C25000DF101B /* MetaEditsUndoManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B82647210B3C25000DF101B /* MetaEditsUndoManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B82647510B3C25000DF101B /* MetaEditsUndoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B82647310B3C25000DF101B /* MetaEditsUndoManager.m */; }; 1B89050A163F6E48008C5C8B /* MZGetCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B890509163F6E48008C5C8B /* MZGetCommand.m */; }; @@ -495,11 +498,13 @@ dstPath = ""; dstSubfolderSpec = 13; files = ( + 1B80F1C32420A8E6006D4D94 /* Add to TV app.scptd in Copy Plugins */, + 1B80F1C42420A8E6006D4D94 /* Update TV app.scptd in Copy Plugins */, + 1B80F1B524208527006D4D94 /* Add to iTunes.scptd in Copy Plugins */, + 1B80F1B624208527006D4D94 /* Update iTunes.scptd in Copy Plugins */, 1B7B1052240605820018DB18 /* TheMovieDbNG.mzsearchprovider in Copy Plugins */, 1B7FF3F724047F27001457CE /* TheTVDB3.mzsearchprovider in Copy Plugins */, - 1B492FA91F65537800A2FD3F /* Add to iTunes.scpt in Copy Plugins */, 1B492FAB1F65537800A2FD3F /* Quit MetaZ.scpt in Copy Plugins */, - 1B492FAC1F65537800A2FD3F /* Update iTunes.scpt in Copy Plugins */, 1B3185B81841EB18001EDE79 /* OSXNotification.mzactions in Copy Plugins */, 1BD562471648F43A00F9C579 /* AlertWindow.mzactions in Copy Plugins */, 1B299DB714AE4D3A0048B7C0 /* TheMovieDb.mzsearchprovider in Copy Plugins */, @@ -652,11 +657,8 @@ 1B492F951F65530500A2FD3F /* Quit MetaZ.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; name = "Quit MetaZ.applescript"; path = "AppleScript/Quit MetaZ.applescript"; sourceTree = ""; }; 1B492F971F65530500A2FD3F /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = AppleScript/README.md; sourceTree = ""; }; 1B492F981F65530500A2FD3F /* Update iTunes.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; name = "Update iTunes.applescript"; path = "AppleScript/Update iTunes.applescript"; sourceTree = ""; }; - 1B492F9A1F65530500A2FD3F /* update.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = update.sh; path = AppleScript/update.sh; sourceTree = ""; }; - 1B492FA51F65537800A2FD3F /* Add to iTunes.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Add to iTunes.scpt"; path = "AppleScript/Add to iTunes.scpt"; sourceTree = ""; }; 1B492FA61F65537800A2FD3F /* Example Actions.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Example Actions.scpt"; path = "AppleScript/Example Actions.scpt"; sourceTree = ""; }; 1B492FA71F65537800A2FD3F /* Quit MetaZ.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Quit MetaZ.scpt"; path = "AppleScript/Quit MetaZ.scpt"; sourceTree = ""; }; - 1B492FA81F65537800A2FD3F /* Update iTunes.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Update iTunes.scpt"; path = "AppleScript/Update iTunes.scpt"; sourceTree = ""; }; 1B4AF74B116EF80500E5C969 /* Access.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Access.h; path = Plugins/TheTVDB/Access.h; sourceTree = SOURCE_ROOT; }; 1B4AF8391170CFCC00E5C969 /* TheTVDBSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TheTVDBSearch.h; sourceTree = ""; }; 1B4AF83A1170CFCC00E5C969 /* TheTVDBSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TheTVDBSearch.m; sourceTree = ""; }; @@ -739,7 +741,6 @@ 1B7223A5240219E7005DEE47 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = App/Base.lproj/MainMenu.xib; sourceTree = ""; }; 1B7223A6240219E8005DEE47 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = App/Base.lproj/PresetsPanel.xib; sourceTree = ""; }; 1B7223A7240219E8005DEE47 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = App/Base.lproj/SearchView.xib; sourceTree = ""; }; - 1B76F8EC241696C000CB8810 /* Return iTunes selected.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Return iTunes selected.scpt"; path = "App/resources/Return iTunes selected.scpt"; sourceTree = ""; }; 1B76F8EF24169BCA00CB8810 /* sign_applescript.bash */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = sign_applescript.bash; path = Scripts/sign_applescript.bash; sourceTree = ""; }; 1B78A499105032A50072D89E /* MZMethodData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZMethodData.h; sourceTree = ""; }; 1B78A49A105032A50072D89E /* MZMethodData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZMethodData.m; sourceTree = ""; }; @@ -769,6 +770,16 @@ 1B7FF40324048024001457CE /* TheTVDB3-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TheTVDB3-Bridging-Header.h"; sourceTree = ""; }; 1B7FF40424048024001457CE /* Token.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = ""; }; 1B7FF40B24059A43001457CE /* Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = ""; }; + 1B80F1B1242084EC006D4D94 /* Add to iTunes.scptd */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "Add to iTunes.scptd"; path = "AppleScript/Add to iTunes.scptd"; sourceTree = ""; }; + 1B80F1B2242084ED006D4D94 /* Update iTunes.scptd */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "Update iTunes.scptd"; path = "AppleScript/Update iTunes.scptd"; sourceTree = ""; }; + 1B80F1B72420A7CE006D4D94 /* Return TV app selected.scptd */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "Return TV app selected.scptd"; path = "App/resources/Return TV app selected.scptd"; sourceTree = ""; }; + 1B80F1B82420A7CE006D4D94 /* Return iTunes selected.scptd */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "Return iTunes selected.scptd"; path = "App/resources/Return iTunes selected.scptd"; sourceTree = ""; }; + 1B80F1BB2420A7E3006D4D94 /* Return TV app selected.applescript */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.applescript; name = "Return TV app selected.applescript"; path = "App/resources/Return TV app selected.applescript"; sourceTree = ""; }; + 1B80F1BD2420A859006D4D94 /* Add to TV app.applescript */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.applescript; name = "Add to TV app.applescript"; path = "AppleScript/Add to TV app.applescript"; sourceTree = ""; }; + 1B80F1BE2420A859006D4D94 /* Update TV app.scptd */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "Update TV app.scptd"; path = "AppleScript/Update TV app.scptd"; sourceTree = ""; }; + 1B80F1BF2420A859006D4D94 /* Update TV app.applescript */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.applescript; name = "Update TV app.applescript"; path = "AppleScript/Update TV app.applescript"; sourceTree = ""; }; + 1B80F1C12420A870006D4D94 /* Add to TV app.scptd */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "Add to TV app.scptd"; path = "AppleScript/Add to TV app.scptd"; sourceTree = ""; }; + 1B80F1C22420A8B9006D4D94 /* compile-applescripts.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "compile-applescripts.sh"; sourceTree = SOURCE_ROOT; }; 1B82647210B3C25000DF101B /* MetaEditsUndoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaEditsUndoManager.h; sourceTree = ""; }; 1B82647310B3C25000DF101B /* MetaEditsUndoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaEditsUndoManager.m; sourceTree = ""; }; 1B890508163F6E48008C5C8B /* MZGetCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZGetCommand.h; sourceTree = ""; }; @@ -1275,11 +1286,13 @@ children = ( 1B492FAD1F6553D300A2FD3F /* Compiled */, 1B492F921F65530500A2FD3F /* Add to iTunes.applescript */, + 1B80F1BD2420A859006D4D94 /* Add to TV app.applescript */, 1B492F931F65530500A2FD3F /* Example Actions.applescript */, 1B492F951F65530500A2FD3F /* Quit MetaZ.applescript */, - 1B492F971F65530500A2FD3F /* README.md */, 1B492F981F65530500A2FD3F /* Update iTunes.applescript */, - 1B492F9A1F65530500A2FD3F /* update.sh */, + 1B80F1BF2420A859006D4D94 /* Update TV app.applescript */, + 1B492F971F65530500A2FD3F /* README.md */, + 1B80F1C22420A8B9006D4D94 /* compile-applescripts.sh */, ); name = AppleScript; sourceTree = ""; @@ -1287,10 +1300,12 @@ 1B492FAD1F6553D300A2FD3F /* Compiled */ = { isa = PBXGroup; children = ( - 1B492FA51F65537800A2FD3F /* Add to iTunes.scpt */, + 1B80F1B1242084EC006D4D94 /* Add to iTunes.scptd */, + 1B80F1C12420A870006D4D94 /* Add to TV app.scptd */, + 1B80F1B2242084ED006D4D94 /* Update iTunes.scptd */, + 1B80F1BE2420A859006D4D94 /* Update TV app.scptd */, 1B492FA61F65537800A2FD3F /* Example Actions.scpt */, 1B492FA71F65537800A2FD3F /* Quit MetaZ.scpt */, - 1B492FA81F65537800A2FD3F /* Update iTunes.scpt */, ); name = Compiled; sourceTree = ""; @@ -1792,8 +1807,10 @@ 1BFEDDFD18349138008A17D3 /* PosterBackground.png */, 1BFEDDFE18349138008A17D3 /* PosterBackgroundError.png */, 1BFEDDFF18349138008A17D3 /* PosterBackgroundMultiple.png */, - 1B76F8EC241696C000CB8810 /* Return iTunes selected.scpt */, + 1B80F1B82420A7CE006D4D94 /* Return iTunes selected.scptd */, 1B63A36616458A1C00461FC9 /* Return iTunes selected.applescript */, + 1B80F1B72420A7CE006D4D94 /* Return TV app selected.scptd */, + 1B80F1BB2420A7E3006D4D94 /* Return TV app selected.applescript */, 1B8CB5DF14AA31C500F859F7 /* modified_header.tiff */, 1B8CB5E014AA31C500F859F7 /* modified_selected.tiff */, 1B8CB5E114AA31C500F859F7 /* modified.tiff */, @@ -2257,7 +2274,7 @@ 1BA3269D10546EC800276F57 /* InfoPlist.strings in Resources */, 1BA326A010546F4600276F57 /* MainMenu.xib in Resources */, 1BD6E752105DADCC00E40151 /* AddToQueue.tiff in Resources */, - 1B76F8ED241696C000CB8810 /* Return iTunes selected.scpt in Resources */, + 1B80F1BA2420A7CE006D4D94 /* Return iTunes selected.scptd in Resources */, 1BD6E753105DADCC00E40151 /* Pause.tiff in Resources */, 1BD6E754105DADCC00E40151 /* Play.tiff in Resources */, 1BFEDE0118349138008A17D3 /* PosterBackgroundError.png in Resources */, @@ -2282,6 +2299,7 @@ 1B03323A10B14B6B00B28E3A /* RevealOn.png in Resources */, 1B03325210B1592D00B28E3A /* StopProgress.png in Resources */, 1B03325410B15CB200B28E3A /* StopProgressHover.png in Resources */, + 1B80F1B92420A7CE006D4D94 /* Return TV app selected.scptd in Resources */, 1B03325610B15FF100B28E3A /* StopProgressOn.png in Resources */, 1BFEDE0018349138008A17D3 /* PosterBackground.png in Resources */, 1B42F21F10DD5D6D00AFEBF6 /* MiniProgressGradient.png in Resources */, @@ -2400,10 +2418,13 @@ inputFileListPaths = ( ); inputPaths = ( - "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Add to iTunes.scpt", + "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Add to iTunes.scptd", "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Quit MetaZ.scpt", - "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Update iTunes.scpt", - "$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Return iTunes selected.scpt", + "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Update iTunes.scptd", + "$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Return iTunes selected.scptd", + "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Add to TV app.scptd", + "$(BUILT_PRODUCTS_DIR)/$(PLUGINS_FOLDER_PATH)/Update TV app.scptd", + "$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Return TV app selected.scptd", ); name = "Sign AppleScript"; outputFileListPaths = ( diff --git a/Plugins/Add to TV app.scptd/Contents/Info.plist b/Plugins/Add to TV app.scptd/Contents/Info.plist new file mode 100644 index 00000000..b3deea39 --- /dev/null +++ b/Plugins/Add to TV app.scptd/Contents/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Add-to-TV + CFBundleName + Add to TV + CFBundleShortVersionString + 1.0 + LSMinimumSystemVersion + 10.15 + + diff --git a/Plugins/Add to TV app.scptd/Contents/Resources/Scripts/main.scpt b/Plugins/Add to TV app.scptd/Contents/Resources/Scripts/main.scpt new file mode 100644 index 0000000000000000000000000000000000000000..4299a8637fac29639aa6fa979a1b1d643630672a GIT binary patch literal 2566 zcmeHJ%TgOh6g@K%AZBPuybK0okMRo=A_*IBRF$d_<5YP;u`swQY*G_R*b|RN3KCAS z%Ln8mob0o3{>HI`!5F{eSNx8ho6|EGv;fAq+c?4z!zSr&$L&6~UaRS)3nsp<5BmAS_$hfgVLL zMp;h4l0W!I+?qV^`U*X7?Got4PDL=sXxD^`XqtFMV%$8=(NPiOjFfL+O zJ9fdrG)@z%C}AEoczo;32Sf)aF`=+Cnu9o+7G|YOf-MF(#3gXO=u;>~o%9QrH_g=Y+~rTb^ziz@E(j zp4jpPEjh&eN48cm|I^!QE*K2W`zT_4c9WQXa z>4l(FqZhh5sOf#E9fvSMQcW=`AB)VnDDvkp&N*U$N=R}Y`8>y_TeX!Qg~n+tFjqp& z#D4l6lE;cc#Ai93UCbQDuso87iW&10#8}sZk1(PLp=NL+%L7{;H0%Y1k%)%f*dg~V zxlf9hYXP_CaHJD`?CE1<6d}~9-Pk9;AuIPRCcT-nmCCtsj=oW+hWRLDqdvK<yM zYxPn&-`J3kf(fagq-bi5d>`riB0t$iKiTy`g>(;zE{~`S@=)v2V{ii{{#T;i^c7)Betw=arT+~m_3d$f@QfXOSUX;VP(tJ1|hO#X;UK7 zI7Ss8lwZ*=SLCw%f}C8kSd8utmR!*}-Zw0{ynZHIG>W9ll1uLprgmAu;pGmbFRWb4 wu8y3zICbIr$cdk4rhZuCZ6I}{11&#(-G-K#FAzJMf?F%hQ~TAcrKO+#0zPp1ssI20 literal 0 HcmV?d00001 diff --git a/Plugins/AppleScript/Add to TV app.applescript b/Plugins/AppleScript/Add to TV app.applescript new file mode 100644 index 00000000..fbc0ed9c --- /dev/null +++ b/Plugins/AppleScript/Add to TV app.applescript @@ -0,0 +1,14 @@ +using terms from application "MetaZ" + on queue completed document the_document + tell application "MetaZ" + set myid to content of tag "TV app persistent ID" of the_document + set loc to file of the_document + end tell + -- Only add if not already in iTunes + if myid is missing value then + tell application "TV" + add loc + end tell + end if + end queue completed document +end using terms from diff --git a/Plugins/AppleScript/Add to TV app.scptd/Contents/Info.plist b/Plugins/AppleScript/Add to TV app.scptd/Contents/Info.plist new file mode 100644 index 00000000..b3deea39 --- /dev/null +++ b/Plugins/AppleScript/Add to TV app.scptd/Contents/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Add-to-TV + CFBundleName + Add to TV + CFBundleShortVersionString + 1.0 + LSMinimumSystemVersion + 10.15 + + diff --git a/Plugins/AppleScript/Add to TV app.scptd/Contents/Resources/Scripts/main.scpt b/Plugins/AppleScript/Add to TV app.scptd/Contents/Resources/Scripts/main.scpt new file mode 100644 index 0000000000000000000000000000000000000000..2652a7da090164a080967772235d17ba570b417e GIT binary patch literal 2574 zcmeHJ%TgOh6g@K%AZBPuybK0okMRo=A_*IBRF$d_<5YP;u`swQY*G_R*b|RN3KCAS z%Ln8mob0o3{>HI`!5F{eSNx8ho6|EGv;fAq+c?4z!zSr&$L&6~UaRS)3nsp<5BmAS_$hfgVLL zMp;h4l0W!I+?qV^`U*X7?Got4PDL=sXxD^`XqtFMV%$8=(NPiOjFfL+O zJ9c3R(>M(WE~@-Fd`p-|4IbY*^8wMpNlYm0jOHSaCV6Sg%PrA7B~bmSW(&|nIK#`g)%%0KXYY8r5Tucloa8IIgY9Cz!i z3EXXZ`)mT_wn*z_sqW5Z+-h|j!}nBcAB`qa*>VaCjkRc@d>^*+fHFztX7`piZ?vl~9M8$QVi zgMPaifznZ%?1I5yzaqqZE>ah|Z~0QD~gT z0&^wQOzfxMA$hDAM0}Rh*~QFZ49g>VsF*Q7L5y`h_y{A45NZcEv^=ooLBn297>Q`u zjU95|lKZ51xfXDn4o7;?$DTe$MiD~2+Kqkk8?tiGV$z#ATdABI=ja>tYM75gHtLhx zO77Znw~_w$H2pJCzkO7ITnahk{J%kes?vwkzj^xf-{(G;jDx`Zzba_NwkcV2A9)rh1;(sNo z|F@K=nXDL;VaXMp + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Add-to-iTunes + CFBundleName + Add to iTunes + CFBundleShortVersionString + 1.0 + MZMaximumSystemVersion + 10.14 + WindowState + + bundleDividerCollapsed + + bundlePositionOfDivider + 0.0 + dividerCollapsed + + eventLogLevel + 2 + name + ScriptWindowState + positionOfDivider + 421 + savedFrame + 59 190 700 672 0 0 1440 877 + selectedTab + description + + + diff --git a/Plugins/AppleScript/Add to iTunes.scpt b/Plugins/AppleScript/Add to iTunes.scptd/Contents/Resources/Scripts/main.scpt similarity index 54% rename from Plugins/AppleScript/Add to iTunes.scpt rename to Plugins/AppleScript/Add to iTunes.scptd/Contents/Resources/Scripts/main.scpt index dc5f5e968b93e3f9bd1ed5403d489dc7a6676f2a..ccd8e6fbd70f67ee4634260553f2214f2b5acd54 100644 GIT binary patch delta 291 zcmX>j_C{<&E)%1|=CUbJ|G9H>N&Y{7=wI}lR&d^k9XPo5L@C^w;3zfO ziN`|k)&yfN1_lO31_h8j5I*3Qte2Rfd;3WeSL)hdcJQkC$ W^2ksA%45OkI9ZQZZL=S*0xJNMsV1%f delta 116 zcmeyT@=j$#1~-!c$K*n8|H%#9?2`|0^D=Ile2!a#g>7}3-Q-`~4jgQ&(;r^F^}uwp z6OV<~)mukI85kHC8Dv263|hMj7_`)#8H83iFt8pz4aBDym;_!jFfsT~UcqBA`8kio UO>mT&e4E)q z@74rkE(Qh$Mg|3tJP|6GPZ!TNaDSc`Wji a`&cX(9Vc&OQk#5{$$+l5=}Z=8JqZAK$Viv~ delta 222 zcmeyveTRF(YbF7Xi64U|F|tg~WaeeuG&zt_gN1E%n%(4DMh6bI)#(qf-g;m<`8BhJ z*40}_L>U+u7#U + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Update-TV + CFBundleName + Update TV + CFBundleShortVersionString + 1.0 + LSMinimumSystemVersion + 10.15 + + diff --git a/Plugins/AppleScript/Update TV app.scptd/Contents/Resources/Scripts/main.scpt b/Plugins/AppleScript/Update TV app.scptd/Contents/Resources/Scripts/main.scpt new file mode 100644 index 0000000000000000000000000000000000000000..e50cf6f1ccfeaa91d532d6444acbba8800e1cde2 GIT binary patch literal 7688 zcmeHMd3+Q_7XGFaV(6xFa43hsh@yxgA&Q6*IW(}MVz`gsio;|eflMY$CO{Ac0Ra&O z9refw24$&70d-QRCl{~*xcRCm9wepT;#M^$(A zmE`s9+}oR(p4nO-NdV%LMc{#jI1d|8YAjarfXz+inh7$}MWmi(mEq@u2x1CVSXneRwJsv=l9=J`6PjXH{8#Nyeg zYoRX1>fuC1u)-9Jr+z1)z9Lvf=G;aDG*kpnCeIUL%Rl)a@pku7zCwkDm2!z_gp(D) zYD2jiNR%JY*d|ai;v1&W7@i>SByggdB%ujB>(De6P0<2<&<|etP|SZ`9sz_=f&v~9 zwu^{fbVIhn$?jalqlSF%$oJLEg+l%4e0}H0cSvlF_+VK<9_I-s^6<*Hiv5|<>e)C2 z%@o0mR?pU{I870Zu1QFdZ*2L7V;EXc7*IIP?VMJTuO0ciS_PU#75K`LuW&+Z#1)48 z+D_kUJJoUf26@#y8O=R25;-gXgTGFe2fo6B65X{Yog?=oUhIqTN|Em3WRO$Piwg_&^`=N1XFn@vXJm2PZ3O>uf?RwXsxrrP_P^r>c-DnEGqI*pa_N= zwOG9j2lMT4mm4XlEl=6<6uIG6-XkjIQkWisiolGm378^(N0Cjath|d{-IKT|2qiIZ zFz*znvd;b;m3Po(KUXmFq$5vO!+yn@%S3JMAx}8+L`-(Kn6500L|73_wy4MD0Lyzt zFr%%<5L=2-ieNmU0UF8Uwme=n+EJBq4KNyG6v2%4L^P1Uq0A;!j<(DlEmtuZn}o4? zwAZBK8ZN{lR57A+slpgnS6!Pu=E!5!jwccw&!dh!3Y%p_u&l@z4CufT<}pqlQ5ffr zs0qz_Ev{1pi^V<{IHzJfCMbd#p|0bu$3#W&=ygz2oFWg~@-X#w*A^4q*XjE1Ax9pn zR;3Bj%u;<)%|iK&>T2*%TN3BJvdZ84svFwHe|3l{EM zZP`kSxT}sSZZv8|uH1;}ieREqCi!}kg`4>L8Ms*yjDKdbK)wYt6~U|vGFiLN!mWzn zIh*XwL>qa)mIv6qyDGTVRq)7*pL$73auCg*k{DKovSs^SQDC^AzT~bJl}yeLLpMdReE~;GB6_ zCicf2SfB{T4STQ~#IhSE)k%dJZ!ChFa2xgLVnIg)uL=lW`xfqP4 zs89r>+aL^M%Ewx@(|LXvU(cxI`JI`eW7vWOjNJVVKk&W8o(_M?VLOM1jW7F{x{0}O@EqPFz zb-On34h_%g(`R+-C9twhJnoBsE??vZfQ8MnRAF;;k-kLAWwA$=Xxo)*SgZ}WRPTpz zd7PZWDkomd#P5(FQnM%$1ex63@4D|2MF+~&yb)yO(BFD55CGB>&r=E$7r_LC#C_0#{c zLFveCl~-eSA5*ZM6V+U9MH87NGvyZalAH0M%#fR~L#E4(HgCBp)0SCB(yT2r+0tta zn-93MPqbKkSX9t zqUpLn7F4#}$Z0;>wp^;r$G|V(`TmHELxT>dU75S2U1paJ{gF68e_zYbsnC)sODjG~>zY$BoD0-}h|BM*Avpa$+a@hk?X6Gb@=fv z`pL8Vn1tiVxMQTN6zt;niotRXCdpV9Q)L({V`Q|9l2WoDA|(=* zky0!ntg|UZ3vd_7rf4N6%5;n0?Q9vtmdlCJZ0S{`Eu+}div^qAx$Lkd!j`VwZ7E@E zM99x)!}@M$$Z%UmaxVR$aKK*_2}JkdQ_McREyem-!-0@)kzJ`W5mWc + + + + CFBundleIdentifier + com.apple.ScriptEditor.id.Update-iTunes + CFBundleName + Update iTunes + CFBundleShortVersionString + 1.0 + MZMaximumSystemVersion + 10.14 + + diff --git a/Plugins/AppleScript/Update iTunes.scpt b/Plugins/AppleScript/Update iTunes.scptd/Contents/Resources/Scripts/main.scpt similarity index 65% rename from Plugins/AppleScript/Update iTunes.scpt rename to Plugins/AppleScript/Update iTunes.scptd/Contents/Resources/Scripts/main.scpt index 5c279cd1f731bb46669cd90dfe90a066075890ab..bc63e9f346ca2583e7244aee05239a6cb119b397 100644 GIT binary patch delta 564 zcmbQ>c)@W)JrkqC!jE5%oNNBKd?TLInS&-R*gKJNe!mSC8Qj;%8S?JxGV9dq9 zz`)3$0FnpdM+{o(&K#5FZZHU~aA06Pd>V*PF)#_dWMEI2|}Ru3oUXk@m-ElB6BqjkI@4VB;auK9XIVbh1ldn;-82NgH?2J(&jtTTUY??t-BQf delta 487 zcmccMIKgp4JrkqAA=CjJpIa /dev/null ; then + MIN="$(/usr/libexec/PlistBuddy -c "Print :LSMinimumSystemVersion" "${DIR}/${BASE}.scptd/Contents/Info.plist")" + MIN_V="$(cut -d "." -f2 <<<"$MIN")" + echo "Minimum $MIN $MIN_V" + fi + if /usr/libexec/PlistBuddy -c "Print :MZMaximumSystemVersion" "${DIR}/${BASE}.scptd/Contents/Info.plist" &> /dev/null ; then + MAX="$(/usr/libexec/PlistBuddy -c "Print :MZMaximumSystemVersion" "${DIR}/${BASE}.scptd/Contents/Info.plist")" + MAX_V="$(cut -d "." -f2 <<<"$MAX")" + echo "Maximum $MAX $MAX_V" + fi + fi + CHECK=1 + if [ -n "$MIN_V" ] && [ "$VERSION_V" -lt "$MIN_V" ]; then + CHECK=0 + fi + if [ -n "$MAX_V" ] && [ "$VERSION_V" -gt "$MAX_V" ]; then + CHECK=0 + fi + if [ "$CHECK" == "1" ]; then + echo "Can compile $k" + if [ -d "${DIR}/${BASE}.scptd" ]; then + osacompile -l AppleScript -d -o "${DIR}/${BASE}.scptd/Contents/Resources/Scripts/main.scpt" "$k" + else + osacompile -l AppleScript -d -o "${DIR}/${BASE}.scpt" "$k" + fi + else + echo "Can't compile $k : '$MIN' <= '$VERSION' <= '$MAX' '$MIN_V' <= '$VERSION_V' <= '$MAX_V'" + fi + unset MIN + unset MIN_V + unset MAX + unset MAX_V +fi